Lesson 19 +40 XP

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 adderSerial adder
Full adders for n bitsn1
Clock cycles for n bits1 (combinational)n
Storageregisters with parallel loadshift registers + 1 carry flip-flop
Usefast arithmetic unitslow-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 diagramSerial adder block diagram

SolvedExample 1 · Adding 0110 + 0111 serially

Trace a 4-bit serial adder with A = 0110, B = 0111 and carry cleared.

Clockx = A₀y = B₀Carry in QSum SCarry outA after the shift
1010101011
2110010101
3111111010
4001101101
  1. Each sum bit enters at the left of A while A shifts right, so after four clocks the four sum bits are in order.
  2. Check: 6 + 7 = 13 = 11012, with final carry 0.
AnswerA = 1101, 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 adderState diagram of the serial adder

Present Qx yNext QS
00000
00101
01001
01110
10001
10110
11010
11111
SolvedExample 2 · Serial adder with a JK flip-flop (Mano)

Implement the carry of the serial adder with a JK flip-flop instead of a D flip-flop.

  1. From the JK excitation table: when Q = 0, J = Q+ and K = X; when Q = 1, K = (Q+)' and J = X.
  2. JQ: rows with Q = 0 have Q+ = 1 only for xy = 11. So JQ = xy (the Q = 1 rows are don't-cares).
  3. KQ: rows with Q = 1 have Q+ = 0 only for xy = 00. So KQ = x'y'.
  4. The sum output is still S = x oplus y oplus Q.
AnswerJQ = xy, KQ = x'y' = (x + y)', 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

SolvedExample 3 · Designing from a state table with JK flip-flops (Mano)

Design the circuit with two JK flip-flops A, B and input x for the state table:

Present ABNext AB, x = 0Next AB, x = 1
000001
011001
101011
111100
  1. Excitation table (one row per present state and input):
A B xA⁺ B⁺JA KAJB KB
0 0 00 00 X0 X
0 0 10 10 X1 X
0 1 01 01 XX 1
0 1 10 10 XX 0
1 0 01 0X 00 X
1 0 11 1X 01 X
1 1 01 1X 0X 0
1 1 10 0X 1X 1
  1. JA = ∑ m(2) + d(4, 5, 6, 7) = Bx'.
  2. KA = ∑ m(7) + d(0, 1, 2, 3) = Bx.
  3. JB = ∑ m(1, 5) + d(2, 3, 6, 7) = x.
  4. KB = ∑ m(2, 7) + d(0, 1, 4, 5) = A'x' + Ax = (A oplus x)'.
AnswerJA = Bx', KA = Bx, JB = x, KB = (A oplus x)'

K-maps for the four JK inputsK-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

SolvedExample 4 · Cost comparison: D, JK and T

Implement the state table of Example 3 with D flip-flops and with T flip-flops, and compare the literal counts.

  1. D: DA = A+ = ∑ m(2, 4, 5, 6) = Bx' + AB'; DB = B+ = ∑ m(1, 3, 5, 6) = A'x + B'x + ABx'.
  2. T: T = Q oplus Q+. TA = ∑ m(2, 7) = A'Bx' + ABx; TB = ∑ m(1, 2, 5, 7) = B'x + Ax + A'Bx'.
  3. JK: Bx', Bx, x, (A oplus x)'.
Flip-flopInput equationsLiterals
DBx' + AB'; A'x + B'x + ABx'11
TA'Bx' + ABx; B'x + Ax + A'Bx'13
JKBx'; Bx; x; A'x' + Ax9
AnswerJK gives the simplest logic here; T suits counters (Lesson 21); D is simplest to design and is preferred in VLSI

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.

VERILOG
// 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
endmodule

The trace reproduces Example 1:

OUTPUT
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:

VERILOG
// 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
endmodule

Each transition printed (state, then input above the arrow, then next state) matches a row of the state table:

OUTPUT
states: 00 -1-> 01 -1-> 01 -0-> 10 -1-> 11 -0-> 11 -0-> 11 -1-> 00 -1-> 01
💡 Tip

Key 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.
🎯 END-TERM EXAM PREP

📝 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)