EEVblog Electronics Community Forum
Electronics => Beginners => Topic started by: IntegratedValve on January 17, 2014, 08:05:48 pm
-
My question for today regarding JK flip-flops. When setting both J and K to be (1, 1) the output should be complement of previous output Q. It works for one flow of states but then as soon as the output is complemented it will feedback to the input gates and destabilize the successive output states until J and K are set to something different.
As I understand flip-flops change state upon clock transition edge trigger. But is this transition period short enough so that after the Q output changes there will be not time for the feedback circuit to change the output again?
Does JK flip-flop when (J, K) = (1, 1) keeps complement the output Q on every edge trigger resulting in alternating output 1, 0, 1, 0, 1, 0, 1, ...?
-
Does JK flip-flop when (J, K) = (1, 1) keeps complement the output Q on every edge trigger resulting in alternating output 1, 0, 1, 0, 1, 0, 1, ...?
Yes that's the way it works.
Well, not every edge, just either the positive ones or negative ones depending on the implementation.
-
From Wikipedia:
Metastability
Flip-flops are subject to a problem called metastability, which can happen when two inputs, such as data and clock or clock and reset, are changing at about the same time. When the order is not clear, within appropriate timing constraints, the result is that the output may behave unpredictably, taking many times longer than normal to settle to one state or the other, or even oscillating several times before settling. Theoretically, the time to settle down is not bounded. In a computer system, this metastability can cause corruption of data or a program crash, if the state is not stable before another circuit uses its value; in particular, if two different logical paths use the output of a flip-flop, one path can interpret it as a 0 and the other as a 1 when it has not resolved to stable state, putting the machine into an inconsistent state.
So be careful of your timing if you want predictable results...
-
But then how does JK FF stabilize itself when J=1 and K=1? I mean it's not oscillating unpredictably at positive/xor negative edge trigger, is it? Or the transition time is short enough to only allow output to complement before feedback circuit does nasty things? Then how to calc this time period of the edge transition pulse?
-
But then how does JK FF stabilize itself when J=1 and K=1? I mean it's not oscillating unpredictably at positive/xor negative edge trigger, is it? Or the transition time is short enough to only allow output to complement before feedback circuit does nasty things? Then how to calc this time period of the edge transition pulse?
Set J to 1. Wait an appropriate time period for the circuit to settle. Set K to 1. Wait an appropriate period for the circuit to settle. Examine the output.
Do not try to change the state of J and K from 0 to 1 both at the same time.
-
I tried several times, it's not stable.
-
What's not stable?
You would have to post a circuit and an implementation.
Are you clocking your pulses? What clock frequency are you using?
-
What's not stable?
You would have to post a circuit and an implementation.
Are you clocking your pulses? What clock frequency are you using?
Pen and paper. No real circuit or simulation.
-
Pen and paper. No real circuit or simulation.
Maybe this will help:
http://hyperphysics.phy-astr.gsu.edu/hbase/electronic/jkflipflop.html (http://hyperphysics.phy-astr.gsu.edu/hbase/electronic/jkflipflop.html)
If you don't have an enabling clock input then the output will oscillate indefinitely for as long as both J and K remain 1.
-
Do not try to change the state of J and K from 0 to 1 both at the same time.
J&K only affect the output after a clock transition so you should be able to set both together. You just need to ensure they are not changing at the same time as the clock edge. There is, or should be, a "set-up" time in the datasheet of the J-K that you're using. For the 74LS76A it's 0ns (i.e OK as long as they don't all change together).
If you don't have an enabling clock input then the output will oscillate indefinitely for as long as both J and K remain 1.
Err, no.
-
If you don't have an enabling clock input then the output will oscillate indefinitely for as long as both J and K remain 1.
Err, no.
This is a pen and paper simulation. If you solve the circuit with J, K and Q all at 1, then Q will transition to 0. If you now solve the circuit again with J, K = 1, Q = 0, then Q will switch back to 1. Q will keep switching each time you solve the circuit.
-
Do not try to change the state of J and K from 0 to 1 both at the same time.
J&K only affect the output after a clock transition so you should be able to set both together. You just need to ensure they are not changing at the same time as the clock edge. There is, or should be, a "set-up" time in the datasheet of the J-K that you're using. For the 74LS76A it's 0ns (i.e OK as long as they don't all change together).
I see that after further reading. Unless you derive an implied clock from the rising edge of J or K, such that the circuit only changes state when a rising edge occurs on one of the inputs? (No idea if any physical realizations do this.)
-
This is a pen and paper simulation. If you solve the circuit with J, K and Q all at 1, then Q will transition to 0. If you now solve the circuit again with J, K = 1, Q = 0, then Q will switch back to 1. Q will keep switching each time you solve the circuit.
Ah, I see where you're coming from.
Are you looking at one of the master-slave equivalent circuits or the "4 nand" one.
EDIT: Sorry - single malt is nice but not good for concentration :)
The "4 nand" equivalent circuit is not all that useful because it needs the clock input to be a short positive going pulse to work - ie, it's not truly edge triggered and misbehaves when the clock input is high, as you have worked out. With the clock low no change on J or K will propagate to the output. You could make a useful flip-flop by running the clock through a differentiator (i.e small cap) to ensure that you just got a pulse corresponding to the edge.
-
I just set a truth table up in Excel which seems to work out fine as below, using the formula:
Qnext = (J and not Q) or (not K and Q)
I have not really gone through the exercise of converting this to just NAND gates and reducing it down to the minimum number.
(https://www.eevblog.com/forum/beginners/another-stupid-question/?action=dlattach;attach=77267;image)