Torrid Fish

Back

Counter#

Counters are special sequential circuits that sequence though some prescribed set of outputs.

For example:

  • Binary counter: 000->001->010->…->111->000
  • BCD counter: 0000->0001->0010->…->->1001->0000

Counters are classified into two board categories according to the way they are clocked.

Ripple Counter#

The first flip-flop is clocked by the external clock pulse and then each successive flip-flop is clocked by the output of the preceding flip-flop.

Hence, this is an asynchronous sequential circuit.

Binary Ripple Counter#

This is a ripple counter because when the count is changed, the i+1i+1-th bit only changes after the ii-th bit has changed. ( The flip-flops’ outputs don’t change synchronously together. )

There are two ways to implement:

BCD Counter (Asynchronous)#

This is a asynchronous implementation of BCD counters.

By the characteristic equation of JKFF, we have:

Q(t+1)=JQ(t)+KQ(t)Q(t+1) = JQ'(t) +K'Q(t) {Q1(t+1)=Q1(t)C1=CountQ2(t+1)=Q8(t)Q2(t)C2=Q1Q4(t+1)=Q4(t)C4=Q2Q8(t+1)=Q2(t)Q4(t)Q8(t)C8=Q1\begin{cases} Q_1(t+1) = Q_1'(t) \\ C_1 = Count \\ Q_2(t+1) = Q_8'(t)Q_2'(t) \\ C_2 = Q_1 \\ Q_4(t+1) = Q_4'(t) \\ C_4 = Q_2 \\ Q_8(t+1) = Q_2(t)Q_4(t)Q_8'(t) \\ C_8 = Q_1 \\ \end{cases}

Since for a BCD counter, it should count to at most 9, so we retrict it by Q2(t+1)=Q8(t)Q2(t)Q_2(t+1) = Q_8'(t)Q_2'(t).

Notice that all the clks here are negative-edge triggered.

By using mutiple BCD counter, we can have a asynchronous multi-digit BCD counter.

Synchronous Counter#

All flip-flops are clocked simultaneously by the external clock pulse.

Synchronous Binary Counter#

Q0Q_0 is toggled every clock cycle. QiQ_i needs to be toggled in the next state if Q0Q_0 to Qi1Q_{i-1} are all one in the present state.

By DFF#

We can get the characteristic function of each DFF:

Qi(t+1)=Di=Qi(En Q0 ... Qi1)Q_i(t+1) = D_i = Q_i\oplus (En\space\land Q_0\space\land...\space Q_{i-1} )

By JKFF#

We can get the characteristic function of each JKFF:

Qi(t+1)=JiQi+KiQi=JiQi=KiQi=(En Q0 ... Qi1)QiQ_i(t+1) = J_iQ'_i+K_i'Q_i = J_i\oplus Q_i = K_i\oplus Q_i = (En\space\land Q_0\space\land...\space Q_{i-1} )\oplus Q_i

Exercise#

Construct an 8-bit synchronous binary counter using two instances of the 4-bit binary counter. Answer:

Up-Down Binary Counter#

The above counters we had made are up counter.

For a down counter :

  • Counts downward.
  • Least Significant Bit is complemented each time.
  • Other bit position is complemented if all lower bits are 0 (e.g. 1000 -> 0111)

Binary Counter with Parallel Load#

It is desirable if we may load an initial count and/or clear a counter.

This is an example of 4-bit binary counter with parallel load and active-low clear.

Let’s analyze the circuit.

{Ji=(Count  (A0 ... Ai1))(Load  Ii)Ki=(Count  (A0 ... Ai1))(Load  Ii)\begin{cases} J_i = (Count \space \land \space (A_0\space\land...\space A_{i-1}))\lor (Load \space \land \space I_i) \\ K_i = (Count \space \land \space (A_0\space\land...\space A_{i-1}))\lor (Load \space \land \space I_i') \\ \end{cases}

Also, we have that Count=CountLoadCount = Count \land Load', so we can say that Count=LoadCount = Load' under any cases.

Now, if Count=1Count = 1, then we get J,KJ, K the same as the binary counter above, so now it work as a counter.

Now, if Load=1Load = 1, then J,KJ, K are in opposite signal, so it just work as a flip-flop that is updating its data.

BCD Counter (Synchronous)#

Here, we can build BCD counter in an differnt way — By using a 4-bit binary counter.

The same as the BCD counter above, we need to control the upper bound of the counter to be 9, so as long as you count to 9, you need to load a 0 so it can restart.

By using mutiple BCD counter, we can have a synchronous multi-digit BCD counter.

Arbitrary Sequence Counter#

Given a counting sequence, implement it with sequential circuit.

Example 01#

Success:

Construct a counter that counts in the sequence 000, 001, 010, 100, 101, 110 repeatedly.

First, we can draw the state table and state diagram: Here, we regard the two unused state 111 and 011 as don’t care conditions, and we can simplify the eqation by using K-map. K-map:

Hence, we can get the logic equation:

{JA=BKA=BJB=CKB=1JC=BKC=1\begin{cases} J_A = B & K_A = B \\ J_B = C & K_B = 1 \\ J_C = B' & K_C = 1 \\ \end{cases}

Then we can draw the circuit:

Verilog Implementation#

Here is a example of 4-bit Counter with Reset:

tags: Logic Design EECS1010#