0
\$\begingroup\$

I have an assignment to create a counter that counts in the following way depending on input y

if y = 0 -> 0, 6, 3, 2, 1, 0...

if y = 1 -> 0, 5, 4, 7, 2, 1, 0...

Also it has another input x if x = 0 it counts up (for example 0,6,3,2,1,0) and if x = 1 it counts down (0,1,2,3,6,0).

I know that i can solve this by creating a big table with following columns

x|y|Q1|Q2|Q3||Q1+|Q2+|Q3+
----------------------------
0|0|0 |0 |0 || 1 | 1 |0
0|0|0 |0 |1 || 0 | 0 |0
0|0|0 |1 |0 || 0 | 0 |1
0|0|0 |1 |1 || 0 | 1 |0

...

But is there any simpler (and more elegant ) solution?

I can only use JK flip-flops. This is sequential logic so i don't have to worry about voltage or things like that... Also if it means something we use HADES for this

\$\endgroup\$
1
\$\begingroup\$

The "trick" with JK flip-flops

Since we don't have a previous answer about designing state machines with JK flip-flops...

Designing with JK flip-flops is pretty much the same as design with D flip-flops (or T flip-flops or any other kind of flip-flops.) But with the JK flip-flop the excitation table is such that there is a trick that makes dealing with the state transition logic slightly simpler.

For any state machine/counter design you need the excitation table for your particular flip flop.

For JK flip flops the excitation table looks like

Previous State -> Present State    J K
0 -> 0                             0 X
0 -> 1                             1 X
1 -> 0                             X 1
1 -> 1                             X 0

The special property we are going to leverage is that when the previous state is 0 then the K input is a don't care, and when the previous state is 1 then the J input is always a don't care.

First you have to complete your table. Not only do you have to have the inputs and the Qs, you also need all the J and K entries:

x|y|Q1|Q2|Q3||Q1+|Q2+|Q3+||J1|K1|J2|K2|J3|K3
--------------------------------------------
0|0|0 |0 |0 || 1 | 1 |0  ||1 |X |...
0|0|0 |0 |1 || 0 | 0 |0  ||0 |X |
0|0|0 |1 |0 || 0 | 0 |1  ||0 |X |
0|0|0 |1 |1 || 0 | 1 |0  ||0 |X |
...

Now we need to draw the 6 K-Maps for J1,K1,J2,K2,J3, and K3. If we weren't using our "trick" we would need these to be 5-variable maps (x,y,Q1,Q2, and Q3).

But because J1 is don't care whenever Q1 is 1 we only need to do the map for J1 for the case that Q1 is 0. And of course, in that case we know that Q1 is 0, so we can just do a 4 variable map (with input variables x,y,Q2, and Q3).

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.