Menu

#22 JK flip-flop checks input state after clock

open
nobody
Simulator (6)
5
2011-07-05
2011-07-05
Anonymous
No

The JK flip-flop (I have it set to rising edge) checks the input state after the clock tick. The result is, if the inputs change simultaneously with the clock edge changing, it will respond to the clock tick as if the inputs were the new input, not the old.

It should store the input state on the falling clock edge and change the output based on that stored state on the rising edge. If the input changes after the falling clock edge (but before the rising edge), the new input should have no bearing on the output at the next rising edge.

I have attached a screen shot of the original circuit I discovered the error in. If you start from 000, the bug displays after 2 clock ticks when the first bit (N0) does not toggle. It should count 0, 3, 6, 0... Instead, it starts 0, 3, 7 and continues to count through a bunch of values that it should not.

I have screen shots of an identical circuit, except that the JK flip-flops are built using discrete components instead of the built-in module. It works exactly as expected (I would have attached it, except I don't see a way of attaching multiple files).

I have a third screen shot (again, not attached) with a single JK flip-flop from discrete components that also works as expected. You can find a schematic at: http://www.play-hookey.com/digital/jk_nand_flip-flop.html (halfway down the page).

Discussion

  • Nobody/Anonymous

    This is supposed to count in the following sequence: 0, 3, 6, 0...

     
  • Anonymous

    Anonymous - 2011-07-05

    Apologies for the double submit. I hit the wrong button when trying to add a second attachment.

     

    Last edit: Anonymous 2013-09-18
  • Rybec Arethdar

    Rybec Arethdar - 2011-07-06

    This problem does not seem to be predictable. In my last test, the JK flip-flop on the right acted as expected (this is the one that was having problems when I noticed this bug), while the other two exhibited the faulty behavior. I rebuilt the circuit, and carefully compared the values of the inputs and outputs. Starting both at 000 (with identical values in all wires), each circuit acted differently, even though they were identical (and neither gave the correct output). In a given session, each JK flip-flop seems to always act the same during that session, but each flip-flop does not act the same as every other flip-flop.

    I am sure this not a wiring issue because, in several tests, I checked the value of all wires to make sure that the flip-flops were getting the expected input. (I did this very carefully in the above test.)

    I have not tried uncoupling the inputs and testing. When I have time, I will play with this.

    Lord Rybec

     

Log in to post a comment.