L06 - Verilog - Combinational-Cct Building Blocks - Adder
L06 - Verilog - Combinational-Cct Building Blocks - Adder
Structural Behavioral
Modeling Modeling ❑ Using Expressions
❑ Concurrent Statements
❑ assign net_assignment • Using Behavioral constructs (if-else etc)
aka Procedural Statements
• Required to be enclosed inside an
always block
always @(sensitivity_list)
[begin]
[procedural assignment statements]
[if-else statements]
[case statements]
[while, repeat, and for loops]
[task and function calls]
[end]
2
Design of Arithmetic Circuits –
Full Adder
3
Review: Half-Adder
4
Review: Full-Adder
5
Review: Full-Adder using Half-Adders
ci s si
s HA c
xi
HA c ci + 1
yi
ci
si
xi
yi
ci + 1
6
Full-Adder using Gate-Level Primitives
endmodule
7
Full-Adder using Continuous Assignment
assign s = x ^ y ^ Cin;
assign Cout = (x & y) | (x & Cin) | (y & Cin);
endmodule
8
Full-Adder at Behavioral
endmodule
9
Design of Arithmetic Circuits –
Multi-bit Adder
10
Four-bit Adder –
Using Hierarchical Design Approach
module adder4 (carryin, x3, x2, x1, x0, y3, y2, y1, y0, s3, s2, s1, s0, carryout);
input carryin, x3, x2, x1, x0, y3, y2, y1, y0;
output s3, s2, s1, s0, carryout;
endmodule
assign s = x ^ y ^ Cin,
assign Cout = (x & y) | (x & Cin) | (y & Cin);
endmodule
11
Code Improvement using Vectors
endmodule
12
Code Improvement using Parametrization
endmodule
13
Alternate Style using CASE
module fulladd (Cin, x, p_state, s, Cout);
input Cin, x, p_state;
output reg s, Cout;
endmodule
14
Code Improvement using Generate
15
Recommended Reading
• Digital System Design with Verilog HDL, 3/e, b Stephen
Brown and Zvonko Vranesic. [S&Z]
– S&Z,
▪ Chapter-3 for review
▪ 3.5 for Verilog
16
THANK YOU