What is a Flip-flop?
A flipโflop is an edgeโtriggered bistable memory circuit that stores one bit of data. Unlike a latch, which is levelโsensitive and transparent while the enable signal is active, a flipโflop changes state only at a specific clock transition (rising or falling edge, also called, positive-edge or negative-edge, or simply posedge or negedge).
This synchronization with the clock makes flipโflops the fundamental building blocks of sequential logic, ensuring predictable timing and eliminating transparency issues.
What is a JK flip-flop?
A JK flip-flop is a clocked bistable memory element designed to store one bit of data. It has a two inputs, J and K, and two complementary outputs (\(\mathsf{Q}\) and \(\mathsf{\overline{Q}}\)). ). At the chosen clock edge (positive or negative), the next state is determined by the combination of \(\mathsf{J}\) and \(\mathsf{K}\):
- If \(\mathsf{J=0}\) and \(\mathsf{K=0}\), the output remains unchanged, holding the previous state.
- If \(\mathsf{J=0}\) and \(\mathsf{K=1}\), the output resets, driving \(\mathsf{Q=0}\).
- If \(\mathsf{J=1}\) and \(\mathsf{K=0}\), the output sets, driving \(\mathsf{Q=1}\).
- If \(\mathsf{J=1}\) and \(\mathsf{K=1}\),, the output toggles, switching to the opposite of its current state.
Between clock transitions, the outputs remain stable, holding the stored state until the next clock event. This concise representation highlights the versatility of the JK flip-flop: it combines the functionalities of both D and T flip-flops, offering set and reset, as well as hold and toggle behavior in a single device.
Symbolic Representation of a JK Flip-flop
The symbol for a JK flip-flop shows a dual data input \(\mathsf{J}\) and \(\mathsf{K}\), a clock input clk, and two complementary outputs (\(\mathsf{Q}\) and \(\mathsf{\overline{Q}}\)).
- The clock input is attached at a small notch on the symbol, indicating that the device is clockโcontrolled.
- For a positiveโedge triggered JK flipโflop, the clock port is marked with a straight line entering the notch, showing that the output updates on the rising edge of the clock.
- For a negativeโedge triggered JK flipโflop, the clock port carries a bubble at the notch, denoting that the output updates on the falling edge of the clock.
- The outputs remain stable between clock transitions, holding the stored bit until the next active edge.
State Table of a JK Flip-flop
This concise representation highlights the versatility of the JK flipโflop: at the active clock edge, the next state depends on the joint values of \(\mathsf{J}\) and \(\mathsf{K}\). When both inputs are equal, the device behaves like a T flipโflop โ holding its state when \(\mathsf{J=K=0}\) and toggling when \(\mathsf{J=K=1}\). When the inputs differ, the \(\mathsf{J}\) input acts like the data input of a D flipโflop โ driving the output high when \(\mathsf{J=1,K=0}\) and low when \(\mathsf{J=0,K=1}\). In this way, the JK flipโflop unifies the deterministic data behavior of the D flipโflop with the controlled toggle action of the T flipโflop, eliminating ambiguity and forbidden states while remaining strictly governed by the clock edge.
Timing Diagram of a JK Flip-flop
The timing diagram illustrates the behavior of a JK flipโflop with respect to its clock input. The signals shown are the clock (clk), the data input (\(\mathsf{D}\)), and the complementary outputs (\(\mathsf{Q}\) and \(\mathsf{\overline{Q}}\)).
- At each rising edge (
posedge) of the clock, the flipโflop samples the value present at \(\mathsf{J}\) and \(\mathsf{K}\) and responds accordingly. - The posedge at \(\mathsf{t_1}\) sees \(\mathsf{J=1,K=1}\) and hence toggles the output for the full cycle. The previous value at \(\mathsf{Q}\) as 0 which then changed to 1 for this cycle.
- At \(\mathsf{t_3}\), \(\mathsf{J=K=0}\) and hence the output holds it previous value which was 1.
- \(\mathsf{t_5}\) sees \(\mathsf{J}\) at 0 while \(\mathsf{K}\) at 1, hence the output acts like that of a D flip-flop and goes down to 0.
- The rising edge at time step \(\mathsf{t_7}\) is presented with \(\mathsf{J=1, K=0}\), hence, the output goes high to 1.
- The complementary output \(\mathsf{\overline{Q}}\) simultaneously takes the opposite value.
- Between clock edges, the outputs remain stable, holding the last captured state regardless of changes at the data input.
This diagram emphasizes the edgeโtriggered nature of the JK flipโflop: only at the positive clock transition do the inputs affect the outputs. Any changes in \(\mathsf{J}\) or \(\mathsf{K}\) while the clock is low or high (but not transitioning) have no immediate effect, ensuring predictable and synchronized operation in sequential circuits.
Hardware Implementation of a JK Flip-flop
A JK flipโflop can be implemented using a D flipโflop by appropriately driving the D input with a logic function of the \(\mathsf{J}\), \(\mathsf{K}\), and current output \(\mathsf{Q}\). The required input expression is:
\[\mathsf{D=JQ’+K’Q}\]
At the clock edge, this ensures the correct JK behavior: when \(\mathsf{J=0,K=0}\), the input to the D flipโflop equals \(\mathsf{Q}\), so the state holds; when \(\mathsf{J=0,K=1}\), the input forces \(\mathsf{Q}\) to reset to 0; when \(\mathsf{J=1,K=0}\), the input drives \(\mathsf{Q}\) to set at 1; and when \(\mathsf{J=1,K=2}\), the input becomes the complement of \(\mathsf{Q}\), producing a toggle. In this way, the D flipโflop, with its input modified by the \(\mathsf{J}\) and \(\mathsf{K}\) signals, replicates the full state transition behavior of a JK flipโflop, updating only at the active clock edge and remaining stable between transitions.