3.5.6HDL & Digital Design Flow

RTL (register transfer level) design

2,066 words9 min readdifficulty · medium

WHY does RTL exist?


WHAT is RTL, precisely?


Figure — RTL (register transfer level) design

HOW does data actually flow? (Derive the timing)


Worked Example 1 — A simple accumulator

Design: acc <= acc + data_in; on each clock.

module accum(input clk, input rst, input [7:0] data_in,
             output reg [7:0] acc);
  always @(posedge clk) begin
    if (rst) acc <= 8'd0;      // synchronous reset
    else     acc <= acc + data_in;
  end
endmodule

Step: use <= (non-blocking). Why this step? Non-blocking assignment schedules the update at the end of the timestep, modeling "all registers latch simultaneously on the edge." Real flip-flops all fire together — <= matches that. Using = here would create a false ordering dependency.

Step: reset inside @(posedge clk). Why? This is a synchronous reset — it only takes effect on an edge, exactly like real logic feeding the D input.

Timing: critical path = adder. If tcq=0.2t_{cq}=0.2ns, adder tcomb=1.5t_{comb}=1.5ns, tsetup=0.3t_{setup}=0.3ns, then T2.0T\ge 2.0ns, so fmax=500f_{max}=500 MHz.


Worked Example 2 — Combinational vs sequential split

Compute y = (a + b) * c, registered output.

reg [15:0] y;
wire [15:0] prod = (a + b) * c;   // combinational (assign-style)
always @(posedge clk) y <= prod;  // sequential: latch it

Step: keep the arithmetic combinational, latch only at the end. Why? Separating "compute" (a pure function, no clock) from "store" (the register) is the essence of RTL. The tool synthesizes an adder + multiplier as gates, then one register bank.

Forecast-then-Verify: Predict — how many registers? Only the 16-bit y → 16 flip-flops. The adder/multiplier are gates, not registers. ✅ (Beginners often think every wire is stored — it isn't.)


Worked Example 3 — Blocking mistake in sequential logic

// BUGGY intent: swap a and b every clock
always @(posedge clk) begin
  a = b;   // blocking
  b = a;   // now b gets the NEW a, not old a!
end

a=b executes, then b=a sees the already-updated a. Both become old b. Fix:

always @(posedge clk) begin
  a <= b;
  b <= a;   // both use OLD values → true swap
end

Why the fix works: non-blocking reads all right-hand sides using pre-edge values, then updates simultaneously — a faithful register model.



Recall Feynman: explain to a 12-year-old

Imagine a relay race. Registers are runners standing at fixed spots holding a baton (a number). The clock is a whistle. On every whistle, each runner hands the baton to the next runner. But between whistles, the baton passes through a little machine (the logic) that changes it — maybe adds 1. The whole trick: the machine must finish changing the baton before the next whistle blows, or the next runner grabs a half-cooked number. Blow the whistle too fast → chaos. RTL is just writing down: "at each whistle, this runner gets this changed baton."


Flashcards

What does RTL stand for and describe?
Register Transfer Level — describes hardware as registers (state) plus combinational logic transferring data between them on each clock edge.
The two fundamental building blocks in RTL?
Combinational logic (no memory, pure function of inputs) and sequential logic (registers updated on the clock edge).
Write the max-clock-period (setup) constraint.
Ttcq+tcomb,max+tsetupT \ge t_{cq} + t_{comb,max} + t_{setup}
Why does the critical path determine max frequency?
It's the slowest combinational path between registers; the clock period must exceed its delay (plus tcq+tsetupt_{cq}+t_{setup}), so it caps fmaxf_{max}.
Why use non-blocking (<=) in @(posedge clk) blocks?
It models all flip-flops latching simultaneously using pre-edge values, matching real parallel register updates; blocking = imposes false ordering.
Write the hold-time constraint and note what's special.
tcq+tcomb,mintholdt_{cq} + t_{comb,min} \ge t_{hold} — it has no TT, so slowing the clock cannot fix hold violations.
Which signals become registers in synthesis?
Only those assigned under a clock edge (or needing to remember state across clocks); combinational assigns become gates/wires.
How do you make a design run at a higher clock frequency?
Shorten the critical path (e.g., pipeline it), reducing tcomb,maxt_{comb,max}; then raise ff.
Difference between synchronous and asynchronous reset (RTL)?
Sync reset is inside @(posedge clk) and acts only on an edge; async reset is in the sensitivity list and acts immediately.

Connections

Concept Map

sits between

sits between

describes

uses

stores in

synced by

computes

latched into

updates only at

fed to

maps to

delay t_comb sets

edge must wait for

RTL abstraction level

Gate-level too low

Behavioral too high

Data transfer per clock tick

Combinational logic

Registers / state

Clock edge

Next-state function delta

Synthesis tool

Clock-period constraint

Hinglish (regional understanding)

Intuition Hinglish mein samjho

Dekho, RTL ka matlab hai apne circuit ko is tarah describe karna: "har clock edge pe, kaunsa register kaunsi value store karega." Do hi cheezein hoti hain — registers (jo numbers yaad rakhte hain) aur combinational logic (jo bina yaad rakhe seedha compute karti hai, jaise adder). Data ek register se nikalta hai, beech ki logic se hoke guzarta hai (add, multiply, jo bhi), aur agli clock edge pe doosre register mein "latch" ho jaata hai. Bas yahi hai poora khel.

Sabse important baat timing hai. Register se signal nikalne mein tcqt_{cq} lagta hai, logic ko compute karne mein tcombt_{comb}, aur next register ko capture ke liye pehle tsetupt_{setup} chahiye. In sabka total clock period TT se kam hona chahiye: Ttcq+tcomb+tsetupT \ge t_{cq}+t_{comb}+t_{setup}. Jo path sabse slow hai wo critical path hai — wahi tumhari maximum speed decide karta hai. Agar clock bahut fast kar doge, logic settle nahi hogi aur galat value latch ho jaayegi.

Verilog mein ek golden rule yaad rakho: sequential block (always @(posedge clk)) mein hamesha <= (non-blocking) use karo, aur combinational (always @(*)) mein = (blocking). Kyun? Kyunki real flip-flops sab ek saath, ek hi edge pe update hote hain — <= yahi parallel behaviour model karta hai. Agar = use karoge sequential mein, to swap type bugs aa jaayenge. RTL master karne ke liye bas yeh soch: "kya is signal ko clock ke aar-paar yaad rakhna hai?" Haan → register. Nahi → sirf logic.

Go deeper — visual, from zero

Test yourself — HDL & Digital Design Flow

Connections