cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Highlighted
Observer
Observer
8,816 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
Highlighted
Xilinx Employee
Xilinx Employee
8,812 Views
Registered: ‎08-07-2007

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
Highlighted
Observer
Observer
8,809 Views
Registered: ‎09-12-2007

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
Highlighted
Xilinx Employee
Xilinx Employee
8,806 Views
Registered: ‎08-07-2007

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
Highlighted
Observer
Observer
8,782 Views
Registered: ‎09-12-2007

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