Electronic – Can someone explain the following flip-flop circuit

digital-logicflipfloplatch

enter image description here

I'm having trouble understand what's going on in this circuit. The question asks "what is the value of Q if \$\bar{R} = 1\$ and \$\bar{S} = 0\$" (as shown).

enter image description here

In this case, how can I determine what Q looks like? I realize that this question may require knowledge from the one above, which is why I asked it first. Any information about where to go would be great.

Best Answer

I agree with the OP in that the critical part of the function of a D-latch lies in it's SR-latch, so I will focus on that part only for the moment.

Since we're dealing with NANDs here, I would derive the SR-latch function or truth table from that of a NAND with the inputs A and B and the output Z:

$$ \array{A&B&Z\\0&0&1\\0&1&1\\1&0&1\\1&1&0} $$

Looking at your SR-latch schematic, naming the upper NAND (driven by S') "T" and the lower NAND (driven by R') "U", we have the following relationships:

SR-latch

$$ A_T=\bar{S}, B_T=\bar{Q}, A_U=\bar{R}, B_U=Q $$

From that, we can start to draw a truth table for the SR-latch, from which we know only the inputs at this point:

$$ \array{A_T=\bar{S}&&A_U=\bar{R}&&B_U=Q=Z_T&&B_T=\bar{Q}=Z_U\\ 0&&0&&&&\\0&&1&&&&\\1&&0&&&&\\1&&1&&&&} $$

Looking back at the truth table for the NAND, we realise that if any of it's inputs A or B is 0, it's output Z is 1. From that, we can start to fill in the missing values in our SR-latch truth table:

$$ \array{A_T=\bar{S}&&A_U=\bar{R}&&B_U=Q=Z_T&&B_T=\bar{Q}=Z_U\\ 0&&0&&1&&1\\0&&1&&1&&\\1&&0&&&&1\\1&&1&&&&} $$

Now, looking at the NAND truth table again and realising that it's output Z is 0 if both A and B are 1, we continue filling in the missing values:

$$ \array{A_T=\bar{S}&&A_U=\bar{R}&&B_U=Q=Z_T&&B_T=\bar{Q}=Z_U\\ 0&&0&&1&&1\\0&&1&&1&&0\\1&&0&&0&&1\\1&&1&&&&} $$

Seems like we have got all entries except the one for when both S' and R' are 1, because this state is only dependent on the previous Q and Q' values. This is how the latch holds its value, because for that state, the NANDs' inputs look like

$$ \array{A_T=\bar{S}=1, B_T=\bar{Q}\\A_U=\bar{R}=1, B_U=Q} $$

from which follows that the outputs of these latches are

$$ \array{Z_T=!\bar{Q}=Q\\Z_U=!Q=\bar{Q}} $$

Labelling these "previous" Q and Q' values as Qp and Qp', we have the final truth table for our SR-latch:

$$ \array{A_T=\bar{S}&&A_U=\bar{R}&&B_U=Q=Z_T&&B_T=\bar{Q}=Z_U\\ 0&&0&&1&&1\\0&&1&&1&&0\\1&&0&&0&&1\\1&&1&&Q_p&&\bar{Q_p}} $$

If you prefer to look at some waveforms of this SR-latch built from NAND gates, the following might help:

SR-latch timing

The values for Q and Q' in this diagram can be derived from looking at the truth table of the SR latch:

  • a. S' goes low, causing Q to rise and Q' to fall.
  • b. S' rises, Q and Q' hold their current values.
  • c. R' falls, causing Q to go low and Q' to go high.
  • d. R' rises, Q and Q' hold their current values.
  • e. Both R' and S' fall at the same time, causing Q and Q' to go high.
  • f. S' "releases" (goes high) first, leaving the SR-latch in the same state as it was after c: Q goes low and Q' stays high.
  • g. R' rises, Q and Q' hold their current values.
  • h. Both R' and S' fall at the same time, causing Q and Q' to go high.
  • i. R' "releases" (goes high) first, which is then equivalent to state a: Q goes high and Q' goes low.
  • j. S' releases. Both Q and Q' hold their current values.

To the OP: If that is not clear or you'd like some more details (such as more schematics of the different states), please let me know in a comment - I'll see what I can do.