Synthesizable Verilog Coding: For RTL Design
Synthesizable Verilog Coding: For RTL Design
Verilog code
+
reg [3:0] A, B, C;
video motion
DCT
frames estimation
entropy
Q
cod ing ESL design
(Electronic System Level)
RTL design
(Register Transfer Level)
gate-level design
circuit-level design
(transistor-level)
physical layout
The basic device to build a chip:
MOS transistor
ESL design
(Electronic System Level)
RTL design
(Register Transfer Level)
gate-level design
circuit-level design D
(transistor-level)
G
physical layout X X=0 X=1
S
Physical Layout
ESL design
(Electronic System Level)
RTL design
(Register Transfer Level)
gate-level design
circuit-level design
(transistor-level)
physical layout
Physical layout of a chip
The image you find
in fully-custom
design
Gate-level to Circuit-level
Transform
ESL design
(Electronic System Level)
RTL design
(Register Transfer Level)
gate-level design
circuit-level design
(transistor-level)
physical layout
RTL to Gate-level transform
reg A, B, C, D, E;
ESL design
(Electronic System Level) always @(*)
RTL design E = A&B | C&D;
(Register Transfer Level)
gate-level design
circuit-level design
(transistor-level)
physical layout
State-of-art chip design
RTL design
(Register Transfer Level)
gate-level design
module declaration
assign D = A&B;
assign E = C | D;
endmodule the same operators to C/C++
The “assign” statement
the “assign” a wire as driven by some combinational circuit
Example 1: the Boolean equation
Example 2: the arithmetic equation
Example 3: the multiplexer (MUX)
E
The “assign” statement
the “assign” a wire as driven by some combinational circuit
Example 1: the Boolean equation
Example 2: the arithmetic equation
Example 3: the multiplexer (MUX)
combinational D = f ( A, B, C ,...)
circuit
D
Lab Exercise
Design the circuit with “assign” statements
write the Boolean equations
Behavior description
General Semantics of Behavior
Description
specify the rules for event-driven simulation
Remark: Verilog is originally for hardware simulation, not
for hardware synthesis
reg E; E
always @(A or B or C) begin
E = (A&B)|C;
end
endmodule
Example: a combinational circuit
the synthesized circuit
declared
module demo_circuit (A,asB,a C,
register
E); but
input A, B, not
C; register synthesized
output E;
reg E; E
always @(A or B or C) begin
E = (A&B)|C;
end
endmodule
More Examples of inferring
combinational circuits
(1) design by specifying the Boolean
equations
(2) design by specifying the truth table
(3) inferring a data path with case
statement
(4) inferring a data path with if-then-else
Example 1 (a)
design by specifying Boolean equations
reg E;
E
always @(A or B or C) begin
E = (A&B)|C;
end
endmodule
Example 1 (b)
design by specifying Boolean equations
reg D;
reg E;
E
always @(*) begin
D = A&B;
end
reg D;
reg E;
E
always @(*) begin
E = D|C;
end
exchange yields the same result
always @(*) begin
D = A&B;
end
endmodule
More Examples of inferring
combinational circuits
(1) design by specifying the Boolean
equations
(2) design by specifying the truth table
(3) inferring a data path with case
statement
(4) inferring a data path with if-then-else
Example 2 module demo_circuit (A, B, C, E);
input A, B, C;
output E;
inferring combinational circuit
by specifying the truth table reg E;
specify a don’t-care
More Examples of inferring
combinational circuits
(1) design by specifying the Boolean
equations
(2) design by specifying the truth table
(3) inferring a data path with case
statement
(4) inferring a data path with if-then-else
Example: combinational circuit
A B C
always @(posedge clk) begin
hardware to be …
clk simulated // C code to compute D and E
…
end
D E
Inferring sequential circuit
coding style:
always @(posedge clk)
use non-blocking assignment “<=“
Example 1:
parallel D-FFs triggered by clock
time
acc_reg
1010 0110
rin acc_reg
clock
Example 1
parallel D-FFs triggered by clock
time
acc_reg
1010 0110
clock
Example 1
parallel D-FFs triggered by clock
time
acc_reg
1010 0110
clock
Example 2: sequential circuit
with combinational circuit for computation
Example 3: realizing finite-state
machine
realize the finite-state machine with
behavior description reg S;
always @(posedge clock) begin
case (S)
1’b0:
X=0 T=1 begin
if (X==0)
X=1
S <= 1’b0;
0 1 else
T=0 S <= 1’b1;
end
B C
B C
+
+
clk register
A
A
What’s the difference?
reg [3:0] A, B, C; reg [3:0] A, B, C;
clk clk
B 10 1 5 B 10 1 5
5 2 7 C 5 2 7
C
A 15 3 12 A 15 3 12
Caution on behavior description
Be aware of which part is combinational
circuit and which part is sequential circuit