# help designing a binary counter using JK flip flops

#### inkosi

Joined Dec 10, 2013
35
Hi. I have to design a binary counter with an arbitrary sequence (1, 5, 3, 8, etc.) using JK flip-flops. So first I made the state diagram, the excitation table and I got this:

Now I have problems designing the K-map... I know the kmaps I have drawn there are wrong but where exactly does each value of for example J2 correspond to? I thought they corresponded to the value of the present state... do they actually correspond from numbers from 0 onwards (like the first value of J2 is 000, next value is 001, then 010?) And also, what about the blank squares? Do I replace those with don't cares or are they supposed to be left blank?

Any help to clear my doubts would be appreciated

#### inkosi

Joined Dec 10, 2013
35
The sequence I was given was actually 1, 4, 3, 5, 7, 6, 2, 1... sorry for not being clearer

#### MrChips

Joined Oct 2, 2009
23,078
Ok.

Since 0-state is not used, this becomes a don't-care. Put an X in that box.

I am not sure how you arrive at X's in the other boxes. These should be 0 or 1.

Edit: I understand your X's now. You have already solved for J-K flipflops.
I haven't gone through your work completely but it appears to be correct.

Last edited:

#### inkosi

Joined Dec 10, 2013
35

#### MrChips

Joined Oct 2, 2009
23,078
Not sure what you mean.
You go to the present state, for example 000, and put an x in that box.
Go to the present state, for example 001, the required values of J2 = 1, K2 = x. Put this in the 001 box.

You have drawn the K-map correctly.

It is preferable to draw the truth table in sequential ascending order showing all states, 0-1-2-3-4-5-6-7.

#### inkosi

Joined Dec 10, 2013
35
Yeah I thought my kmaps would be like that... I was just confused by another student who told me something else. And yeah I definitely agree. When I did that question in rough it was a headache placing all values on the kmaps.

#### MrChips

Joined Oct 2, 2009
23,078
Your next step is to reduce the K-maps into combinational logic.
Show me how you would do one of the flip-flops.

#### inkosi

Joined Dec 10, 2013
35
I actually did those before as well.... but because I didn't put an X in the 000 state some of my expressions are wrong. I will re-do them with the X there:

the actual design ended up being a disaster... I assume this is a result of the expressions being wrong:

#### MrChips

Joined Oct 2, 2009
23,078
Omitting to put X in the 000 state will not give you the wrong answer.
Putting the X in the 000 state could allow you to arrive at a reduced solution.

I am not sure how you are labeling the K-maps with Q0Q1 and Q2=0 Q2=1.

Are you sure this shouldn't be reversed to Q2Q1 and Q0=0 Q0=1 ?

#### inkosi

Joined Dec 10, 2013
35
Oh wow. I didn't even realise that. I'll do this all over again and post what I get.

#### inkosi

Joined Dec 10, 2013
35

I think these are right .. however designing the final flip-flop diagram is proving to be a pain. It looks really messy especially because of the Jo and Ko expressions..

#### MrChips

Joined Oct 2, 2009
23,078
Looks good. As for J0 and K0, if that's what it takes then you just have to live with it.
Note that K0 is a negated XOR function. That would simplify the wiring using an XOR gate.
J0 can also be reduced to a NAND gate

#### inkosi

Joined Dec 10, 2013
35
Oh good call. I made this:

It looks a bit messy, but is it fine?

#### MrChips

Joined Oct 2, 2009
23,078
Don't know. Are you going to simulate it or build it to check the results?

#### inkosi

Joined Dec 10, 2013
35
Simulate using MultiSIM. I think it IS right, but I will definitely double check it.

#### WBahn

Joined Mar 31, 2012
26,398
Omitting to put X in the 000 state will not give you the wrong answer.
Putting the X in the 000 state could allow you to arrive at a reduced solution.

I am not sure how you are labeling the K-maps with Q0Q1 and Q2=0 Q2=1.

Are you sure this shouldn't be reversed to Q2Q1 and Q0=0 Q0=1 ?
It doesn't matter how he organizes it, as long as there is a 1:1 mapping between variable states and boxes and as long as they are in Gray code order.

#### MrChips

Joined Oct 2, 2009
23,078
He did incorrectly reverse the order of the labeling of the bits on the K-maps and that would make a difference, i.e. Q2 was switched with Q0.

#### WBahn

Joined Mar 31, 2012
26,398
I actually did those before as well.... but because I didn't put an X in the 000 state some of my expressions are wrong. I will re-do them with the X there:

You aren't fully exploiting the groupings. In J0 you can have two groups of four and you can have groups of four in both K1 and K2, which reduce them to single wires. While not readily apparent, you can use an XOR in K0 and J0.

#### WBahn

Joined Mar 31, 2012
26,398
He did incorrectly reverse the order of the labeling of the bits on the K-maps and that would make a difference, i.e. Q2 was switched with Q0.
Okay, I didn't look at it in that close of detail.

#### WBahn

Joined Mar 31, 2012
26,398
Oh good call. I made this:

It looks a bit messy, but is it fine?
It's very close, but K0 is not (Q2 XOR Q1), it is (Q2 XOR Q1)'. However, you can invert the output of an XOR by inverting any combination of an odd number of inputs and outputs. So that means that you have K0 = (Q2' XOR Q1) or you have K0 = (Q2 XOR Q1').

Also, while not critical, it is interesting to note that there is a certain symmetry here if you use J0 = (Q2 XOR Q1), namely K2 = J2', K1 = J1', and K0 = J0'.