I am trying to better understand how flip flops work. I am asked:
Desing a three-bit up/down counter using T-ff. It should include a
control input called Up(bar)/Down. If Up(bar)/down = 0, then the
circuit should behave as an up-counter. If Up(bar)/down = 1, then he
circuit should behave as a down-counter.
The solution to the problem is this:
My question is basically how they came to this conclusion. I know from a truth table the behavior of a t flip flop:
Q Q^+ | T
0 0 | 0
0 1 | 1
1 0 | 1
1 1 | 0
I don't understand how to make a T flipflop into a up counter or a down counter respectively.
You can work it out by going through the steps.
We know if T is at 1 then Q will toggle, if it's at 0 Q will stay the same.
Say we start off with Q0, Q1 and Q2 at 0, and the multiplexer input is set to 0 (so basically ignore the Qbar paths)
At the first clock pulse, since T0 is at 1, then Q0 will toggle from 0 to 1.
So we now have 1 0 0
At the second clock, since T1 is at 1, Q1 will toggle from 0 to 1. Q0 will toggle back to 0.
Now we have 0 1 0
At the third clock, Q1 will remain at 1 since T1 is at 0. Q0 will toggle back to 1.
Now we have 1 1 0
At the fourth clock, since the and gate now has both inputs (Q0 and Q1) at 1, then T2 will be at 1 therefore Q2 will toggle from 0 to 1. T1 is at one so Q1 will toggle back to 0, as will Q0.
Now we have 0 0 1
At the fifth clock, T2 = 0 so Q2 will remain at 1, T1 = 0 so Q1 stays at 0, and Q0 always toggles so it will change to 1.
Now we have 1 0 1
At the sixth clock, T2 = 0 so Q2 stays at 1, T1 = 1 so Q1 toggles to 1 and Q0 toggles to 0.
Now we have 0 1 1
At the seventh clock, T2 = 0 so Q2 stays at 1, T1 = 0 so Q1 stays at 1, and Q0 toggles to 1.
Now we have 1 1 1
At the eighth clock, both inputs to the and gate are high so T2 = 1, so Q2 toggles to 0. T1 is at 1 so Q1 toggles to 0, and Q0 toggles to 0.
Now we have 0 0 0 which is where we started.
If you change the multiplexer input to 1 and select the Qbar path, you can see how it would count down (just complement all the above results, e.g. 0 0 0 becomes 1 1 1, 1 0 0 becomes 0 1 1 and so on)