Sub topic 3
Clock period, setup time, hold time and propagation delay
This chapter assumes you know D flip-flops, binary numbers and basic gates (AND, OR, NOT).
Timing limits
Setup time (tsetup) is how long the D input must be stable before the clock edge. Hold time (thold) is how long D must stay stable after the edge. Clock-to-Q delay (tcq) is the flip-flop's own delay after the edge. Propagation delay (tpd) is the time a signal takes to pass through logic.
The minimum clock period is:
Tmin = tcq + tpd(logic, max) + tsetup
The maximum clock frequency is fmax = 1 / Tmin.
Registers and shift registers
A register is a group of flip-flops that share a clock. A shift register moves each bit one stage per clock edge. A ring counter feeds the last output back to the first input. A 4-bit ring counter starting at 0001 has 4 states. A Johnson counter feeds the inverted last output back to the input. A 4-bit Johnson counter has 8 states: 0000, 0001, 0011, 0111, 1111, 1110, 1100, 1000.
Ripple and synchronous counters
A ripple (asynchronous) counter clocks each flip-flop from the previous output, so delays add up. A synchronous counter drives all flip-flops from one clock. A modulus-N counter needs at least ceil(log2 N) flip-flops. This modulo-6 counter resets when it reaches 5:
module mod6_counter(input clk, input rst, output reg [2:0] q);
always @(posedge clk) begin
if (rst || q == 3'd5)
q <= 3'd0;
else
q <= q + 3'd1;
end
endmoduleMealy and Moore machines
A Moore machine's output depends only on its state. A Mealy machine's output depends on its state and its input. Mealy machines often need fewer states, but their outputs can change within a clock cycle.
Sequence detectors and state minimization
This Moore machine detects the overlapping sequence 101. Its output z is 1 in state S3.
To minimize states, merge two states when they give the same output and the same next state for every input.
Exercise
A flip-flop has tcq = 2 ns, the longest logic path is 5 ns, and tsetup = 1 ns. What is the minimum clock period and maximum frequency?
Show answer
Tmin = 2 + 5 + 1 = 8 ns. fmax = 1 / 8 ns = 125 MHz.