Loading lessons...
Serial Adder & Design with JK and T Flip-Flops
Serial Adder & Design with JK and T Flip-Flops
The previous lesson designed with D flip-flops, where the flip-flop inputs are simply the next state. This lesson designs with JK and T flip-flops, where the excitation table does real work, and compares the cost of the three choices. The worked circuit is the serial adder, which trades speed for hardware by adding one bit per clock with a single full adder.
1. Parallel vs Serial Addition
| Parallel adder | Serial adder | |
|---|---|---|
| Full adders for n bits | n | 1 |
| Clock cycles for n bits | 1 (combinational) | n |
| Storage | registers with parallel load | shift registers + 1 carry flip-flop |
| Use | fast arithmetic units | low-cost or bit-serial systems |
2. The Serial Adder
The two numbers are held in shift registers A and B. At each clock, the least significant bits x = A0 and y = B0 go into a full adder together with the stored carry z = Q. The sum bit is shifted into the left end of A, and the carry out is stored in a D flip-flop for the next bit. After n clocks register A holds the sum.
Serial adder block diagram
Trace a 4-bit serial adder with A = 0110, B = 0111 and carry cleared.
| Clock | x = A₀ | y = B₀ | Carry in Q | Sum S | Carry out | A after the shift |
|---|---|---|---|---|---|---|
| 1 | 0 | 1 | 0 | 1 | 0 | 1011 |
| 2 | 1 | 1 | 0 | 0 | 1 | 0101 |
| 3 | 1 | 1 | 1 | 1 | 1 | 1010 |
| 4 | 0 | 0 | 1 | 1 | 0 | 1101 |
- Each sum bit enters at the left of A while A shifts right, so after four clocks the four sum bits are in order.
- Check: 6 + 7 = 13 = 11012, with final carry 0.
3. The Serial Adder as a Sequential Circuit
The only memory is the carry, so the serial adder is a 2-state Mealy machine: state = carry, inputs x, y, output S.
State diagram of the serial adder
| Present Q | x y | Next Q | S |
|---|---|---|---|
| 0 | 00 | 0 | 0 |
| 0 | 01 | 0 | 1 |
| 0 | 10 | 0 | 1 |
| 0 | 11 | 1 | 0 |
| 1 | 00 | 0 | 1 |
| 1 | 01 | 1 | 0 |
| 1 | 10 | 1 | 0 |
| 1 | 11 | 1 | 1 |
Implement the carry of the serial adder with a JK flip-flop instead of a D flip-flop.
- From the JK excitation table: when Q = 0, J = Q+ and K = X; when Q = 1, K = (Q+)' and J = X.
- JQ: rows with Q = 0 have Q+ = 1 only for xy = 11. So JQ = xy (the Q = 1 rows are don't-cares).
- KQ: rows with Q = 1 have Q+ = 0 only for xy = 00. So KQ = x'y'.
- The sum output is still S = x oplus y oplus Q.
Compare: with a D flip-flop, D = Q+ = xy + xQ + yQ needs three AND gates and a 3-input OR; with JK, the carry logic is one AND and one NOR.
4. Design with JK Flip-Flops: Full Example
Design the circuit with two JK flip-flops A, B and input x for the state table:
| Present AB | Next AB, x = 0 | Next AB, x = 1 |
|---|---|---|
| 00 | 00 | 01 |
| 01 | 10 | 01 |
| 10 | 10 | 11 |
| 11 | 11 | 00 |
- Excitation table (one row per present state and input):
| A B x | A⁺ B⁺ | JA KA | JB KB |
|---|---|---|---|
| 0 0 0 | 0 0 | 0 X | 0 X |
| 0 0 1 | 0 1 | 0 X | 1 X |
| 0 1 0 | 1 0 | 1 X | X 1 |
| 0 1 1 | 0 1 | 0 X | X 0 |
| 1 0 0 | 1 0 | X 0 | 0 X |
| 1 0 1 | 1 1 | X 0 | 1 X |
| 1 1 0 | 1 1 | X 0 | X 0 |
| 1 1 1 | 0 0 | X 1 | X 1 |
- JA = ∑ m(2) + d(4, 5, 6, 7) = Bx'.
- KA = ∑ m(7) + d(0, 1, 2, 3) = Bx.
- JB = ∑ m(1, 5) + d(2, 3, 6, 7) = x.
- KB = ∑ m(2, 7) + d(0, 1, 4, 5) = A'x' + Ax = (A oplus x)'.
K-maps for the four JK inputs
Half of every JK map is don't-cares (the rows where that flip-flop is in the "other" state), which is why JK designs are usually the smallest.
5. The Same Design with D and T Flip-Flops
Implement the state table of Example 3 with D flip-flops and with T flip-flops, and compare the literal counts.
- D: DA = A+ = ∑ m(2, 4, 5, 6) = Bx' + AB'; DB = B+ = ∑ m(1, 3, 5, 6) = A'x + B'x + ABx'.
- T: T = Q oplus Q+. TA = ∑ m(2, 7) = A'Bx' + ABx; TB = ∑ m(1, 2, 5, 7) = B'x + Ax + A'Bx'.
- JK: Bx', Bx, x, (A oplus x)'.
| Flip-flop | Input equations | Literals |
|---|---|---|
| D | Bx' + AB'; A'x + B'x + ABx' | 11 |
| T | A'Bx' + ABx; B'x + Ax + A'Bx' | 13 |
| JK | Bx'; Bx; x; A'x' + Ax | 9 |
6. Unused States and Self-Starting Circuits
When a design has fewer states than 2n codes, the unused codes were treated as don't-cares. After designing, always check where the circuit goes if it ever lands in an unused state (for example at power-up or after noise):
- Substitute each unused code into the flip-flop equations and find its next state.
- If every unused state eventually reaches a valid state, the circuit is self-starting (self-correcting).
- If an unused state loops among unused states, the circuit can get stuck (lock-out); fix it by choosing some don't-cares differently, or by adding a reset.
Lesson 21 works this check in full for counters.
7. The Serial Adder and the JK Design in Verilog
The serial adder: on load, the registers are filled and the carry cleared; then each clock shifts one sum bit into A.
// Serial adder: two shift registers, one full adder and a carry flip-flop
module serial_adder (
input clk,
input load, // load A and B, clear the carry
input [3:0] a_in,
input [3:0] b_in,
output reg [3:0] A, // the sum is shifted into A
output reg [3:0] B,
output reg Q // carry flip-flop
);
wire x = A[0], y = B[0];
wire S = x ^ y ^ Q; // full-adder sum
wire C = (x & y) | (x & Q) | (y & Q);
always @(posedge clk) begin
if (load) begin
A <= a_in;
B <= b_in;
Q <= 1'b0;
end else begin
A <= {S, A[3:1]}; // shift right, sum enters at the left
B <= {1'b0, B[3:1]};
Q <= C;
end
end
endmodule
module tb;
reg clk = 0, load = 1;
reg [3:0] a_in = 4'b0110, b_in = 4'b0111;
wire [3:0] A, B;
wire Q;
integer i;
serial_adder dut (.clk(clk), .load(load), .a_in(a_in), .b_in(b_in), .A(A), .B(B), .Q(Q));
task tick;
begin
#5 clk = 1;
#5 clk = 0;
end
endtask
initial begin
tick;
load = 0;
$display("step x y Q | S C | A after B after");
for (i = 1; i <= 4; i = i + 1) begin
$write(" %0d %b %b %b | %b %b | ", i, A[0], B[0], Q, dut.S, dut.C);
tick;
$display("%b %b", A, B);
end
$display("sum = %b with carry %b (6 + 7 = %0d)", A, Q, {Q, A});
end
endmoduleThe trace reproduces Example 1:
step x y Q | S C | A after B after
1 0 1 0 | 1 0 | 1011 0011
2 1 1 0 | 0 1 | 0101 0001
3 1 1 1 | 1 1 | 1010 0000
4 0 0 1 | 1 0 | 1101 0000
sum = 1101 with carry 0 (6 + 7 = 13)The JK design of Example 3, written with its input equations and the JK characteristic equation, checked by walking an input sequence through the state table:
// Checking the JK design of Example 3 against its state table
module jk_design (
input clk,
input rst_n,
input x,
output reg A,
output reg B
);
wire JA = B & ~x, KA = B & x;
wire JB = x, KB = ~(A ^ x);
always @(posedge clk or negedge rst_n) begin
if (!rst_n) begin
A <= 1'b0;
B <= 1'b0;
end else begin
A <= (JA & ~A) | (~KA & A); // JK characteristic equation
B <= (JB & ~B) | (~KB & B);
end
end
endmodule
module tb;
reg clk = 0, rst_n = 0, x = 0;
wire A, B;
reg [7:0] seq = 8'b11010011;
integer i;
jk_design dut (.clk(clk), .rst_n(rst_n), .x(x), .A(A), .B(B));
initial begin
#1 rst_n = 1;
$write("states: %b%b", A, B);
for (i = 7; i >= 0; i = i - 1) begin
x = seq[i];
#5 clk = 1;
#5 clk = 0;
$write(" -%b-> %b%b", x, A, B);
end
$display("");
end
endmoduleEach transition printed (state, then input above the arrow, then next state) matches a row of the state table:
states: 00 -1-> 01 -1-> 01 -0-> 10 -1-> 11 -0-> 11 -0-> 11 -1-> 00 -1-> 01Key points to remember
- Serial adder: 1 full adder + carry flip-flop + shift registers; n clocks for n bits.
- Serial adder carry with JK: J = xy, K = x'y'; sum S = x oplus y oplus Q.
- JK design: half of every K-map is don't-cares, usually the cheapest logic.
- D: D = Q+. T: T = Q oplus Q+. JK: read the excitation table row by row.
- Always check the unused states: a design is self-starting if they all lead back to the valid cycle.
📝 IPU End-Term Exam Corner (5-10 Marks)
- Q1. Explain the working of a serial adder with a block diagram. Show the addition of 0110 and 0111 step by step. (10 Marks)
- Write: shift registers A and B, full adder, carry D flip-flop, the 4-row trace, the result 1101.
- Q2. Draw the state diagram of a serial adder and implement it with a JK flip-flop. (5 Marks)
- Q3. Design a sequential circuit for a given state table using JK flip-flops. (10 Marks)
- Write: the excitation table with JA KA JB KB columns, four K-maps, the circuit.
- Q4. Compare the use of D, JK and T flip-flops in sequential circuit design. (5 Marks)
- Q5. What is a self-starting circuit? How are unused states handled? (2.5 Marks)