Hardware dual input counter

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

Hi everybody! The project I'm currently working on requires a counter with the ability to increment or decrement its value based on two non periodic clock/count direction signals (in contrast to a generic counter that only needs to work with one clock/count direction pair). I can think of several ways to implementing this in software for the ARM core, but I don't have much of a clue when it comes to hardware design, I only know basic theory. Any tips for the hardware noob?

   

 

   

Thanks in advance,

   

Gino

0 Likes
6 Replies
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Quite easy: use the UDB-based counter (v 3.0) which has got the capabilities you want.

   

 

   

Bob

0 Likes
Anonymous
Not applicable

Hi Bob. I think the UDB counter is appropiate for the last part of the problem. However, I'm not sure of how to feed the count signals to it, as I have two signals that could either increment or decrement the stored value independently, like this: count_pulse_A,count direction_A, count_pulse_B, count_direction B.

0 Likes
odissey1
Level 9
Level 9
First comment on KBA 1000 replies posted 750 replies posted

Gino,

   

add a hardware MUX after inp1 and inp2 to make a single output  

0 Likes
Anonymous
Not applicable

Thanks for the tip! I'm thinking I could have a problem if both signals try to update the counter value at once, only the one being passed by the multiplexer will affect the counter value. I need to figure a way to avoid loosing pulses when each of the inputs "take turns" at the multiplexer output.

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Use a LUT component to cover some strange situations like counting up and down simultaneously. Since this component can be used  registered you may use it as a hardware state-machine to control your up/down counter.

   

 

   

Bob

0 Likes
Anonymous
Not applicable

Thanks Bob. I'll take a look at the LUT documentation. I'll report back with some results as soon as possible.

0 Likes