UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Observer cbranson
Observer
8,603 Views
Registered: ‎09-12-2007

Counter -- Initial Value

I am needing to use multiple counters in my design.  They are count limited (because I'm counting rows of pixels) and is incremented by an enable (that is tied to a active high signal that is high for the first clock cycle a pixel is available).  The only problem in using this is that the first time through the counter is always 1 shorter than the times following.  Is there a way to set the binary counter in system generator to start at a different value?  I want to tell it to start at my max value that way when it sees the first pixel it will be rolling over back to 1.
 
Thanks
0 Kudos
4 Replies
Xilinx Employee
Xilinx Employee
8,599 Views
Registered: ‎08-07-2007

Re: Counter -- Initial Value

The counter block is based on the CoreGen LogiCore Binary Counter core which operates the saem way.  The initial value can be set to something other than 0 the reset or rollover value is still 0.

Instead, you can use the load and reset ports to reset the clock at a certain value and immediately load a new value into the counter.  I don't think this can occur on one clock cycle with this block.  If this is required you may need to build your own counter with an accumulator block and some external logic.
0 Kudos
Observer cbranson
Observer
8,596 Views
Registered: ‎09-12-2007

Re: Counter -- Initial Value

Are you sure that it doesn't roll over back to the initial value?  I set the initial value to 1 and (in wave scope) the value goes back to 1 when it rolls over.
 
If I could get it to initially be 1, but roll over to 0 I'd have exactly what I need.
0 Kudos
Xilinx Employee
Xilinx Employee
8,593 Views
Registered: ‎08-07-2007

Re: Counter -- Initial Value

I wasn't completely correct in my first post.

If an initial value is used, on reset the counter resets to the initial value.  However on an overflowit will rollover to 0.
0 Kudos
Observer cbranson
Observer
8,569 Views
Registered: ‎09-12-2007

Re: Counter -- Initial Value

Thanks,
 
That's exactly what I needed to know.  Before I was counting 1 to 128.  Now I'm counting 0 to inf with 7 bits and an initial value of 127 which makes all of my executions the same length.
 
Thank you for the help.
 
0 Kudos