Title: Full Adder
1Full Adder (1-bit)
A
Sum
B
Cout
Cin
2Anatomy of a Verilog Module
3Anatomy of a Verilog Module
moduleÂ
Declare a module
4Anatomy of a Verilog Module
moduleÂ
Define a module name
FullAdderÂ
5Anatomy of a Verilog Module
moduleÂ
FullAdderÂ
(A, B, Cin, Sum, Cout)
Declare the input and output ports
6Anatomy of a Verilog Module
moduleÂ
FullAdderÂ
(A, B, Cin, Sum, Cout)
input AÂ
Define the input and output ports
input BÂ
input CinÂ
output SumÂ
output CoutÂ
7Anatomy of a Verilog Module
moduleÂ
FullAdderÂ
(A, B, Cin, Sum, Cout)
input AÂ
input BÂ
input CinÂ
output SumÂ
output CoutÂ
Declare local internal signals
wire AandB, AandCin, xxxx, yyyy, zzzzÂ
8Anatomy of a Verilog Module
moduleÂ
FullAdderÂ
(A, B, Cin, Sum, Cout)
input AÂ
input BÂ
input CinÂ
output SumÂ
output CoutÂ
wire AandB, AandCin, xxxx, yyyy, zzzzÂ
and(AandB, A, B)Â
Define circuit using built-in logic
and(AandCin, A, Cin)Â
9Anatomy of a Verilog Module
moduleÂ
FullAdderÂ
(A, B, Cin, Sum, Cout)
input AÂ
input BÂ
input CinÂ
output SumÂ
output CoutÂ
wire AandB, AandCin, xxxx, yyyy, zzzzÂ
and(AandB, A, B)Â
and(AandCin, A, Cin)Â
endmoduleÂ
Define the end of the module
101-Bit ALU
Ctrl(0)
Ctrl
Ctrl(1)
A
Full Adder
Carry Control
Cout
A
Cout
B
B
Sum
Cin
Cin
Other logic
A
Result
41 Mux
A
AandB
B
Anot
11(No Transcript)
124-Bit ALU
134-Bit ALU
144-Bit ALU
154-Bit ALU
16 module ALU1Bit ( A, B, Cin, Ctrl, R,
Cout)
172-bit vector
module ALU1Bit ( A, B, Cin, Ctrl, R,
Cout)
18 module ALU1Bit ( A, B, Cin, Ctrl, R,
Cout)
ALU1Bit ALUBIT0 ( A0, B0, Cin, Ctrl, R0,
Cy0)
19 module ALU1Bit ( A, B, Cin, Ctrl, R,
Cout)
ALU1Bit ALUBIT0 ( A0, B0, Cin, Ctrl, R0,
Cy0)
ALU1Bit ALUBIT1 (A1, B1, Cy0, Ctrl, R1,
Cy1)
20 module ALU1Bit ( A, B, Cin, Ctrl, R,
Cout)
ALU1Bit ALUBIT0 ( A0, B0, Cin, Ctrl, R0,
Cy0)
ALU1Bit ALUBIT1 (A1, B1, Cy0, Ctrl, R1,
Cy1)
ALU1Bit ALUBIT2 (A2, B2, Cy1, Ctrl, R2,
Cy2)
21 module ALU1Bit ( A, B, Cin, Ctrl, R,
Cout)
ALU1Bit ALUBIT0 ( A0, B0, Cin, Ctrl, R0,
Cy0)
ALU1Bit ALUBIT1 (A1, B1, Cy0, Ctrl, R1,
Cy1)
ALU1Bit ALUBIT2 (A2, B2, Cy1, Ctrl, R2,
Cy2)
ALU1Bit ALUBIT3 (A3, B3, Cy2, Ctrl, R3,
Cout)
22 module ALU1Bit ( A, B, Cin, Ctrl, R,
Cout)
ALU1Bit ALUBIT0 ( A0, B0, Cin, Ctrl, R0,
Cy0)
ALU1Bit ALUBIT1 (A1, B1, Cy0, Ctrl, R1,
Cy1)
ALU1Bit ALUBIT2 (A2, B2, Cy1, Ctrl, R2,
Cy2)
ALU1Bit ALUBIT3 (A3, B3, Cy2, Ctrl, R3,
Cout)
23 module ALU1Bit ( A, B, Cin, Ctrl, R,
Cout)
ALU1Bit ALUBIT0 ( A0, B0, Cin, Ctrl, R0,
Cy0)
ALU1Bit ALUBIT1 (A1, B1, Cy0, Ctrl, R1,
Cy1)
ALU1Bit ALUBIT2 (A2, B2, Cy1, Ctrl, R2,
Cy2)
ALU1Bit ALUBIT3 (A3, B3, Cy2, Ctrl, R3,
Cout)
24 module ALU1Bit ( A, B, Cin, Ctrl, R,
Cout)
ALU1Bit ALUBIT0 ( A0, B0, Cin, Ctrl, R0,
Cy0)
ALU1Bit ALUBIT1 (A1, B1, Cy0, Ctrl, R1,
Cy1)
ALU1Bit ALUBIT2 (A2, B2, Cy1, Ctrl, R2,
Cy2)
ALU1Bit ALUBIT3 (A3, B3, Cy2, Ctrl, R3,
Cout)
25 module ALU1Bit ( A, B, Cin, Ctrl, R,
Cout)
ALU1Bit ALUBIT0 ( A0, B0, Cin, Ctrl, R0,
Cy0)
ALU1Bit ALUBIT1 (A1, B1, Cy0, Ctrl, R1,
Cy1)
ALU1Bit ALUBIT2 (A2, B2, Cy1, Ctrl, R2,
Cy2)
ALU1Bit ALUBIT3 (A3, B3, Cy2, Ctrl, R3,
Cout)
26 module ALU1Bit ( A, B, Cin, Ctrl, R,
Cout)
ALU1Bit ALUBIT0 ( A0, B0, Cin, Ctrl, R0,
Cy0)
ALU1Bit ALUBIT1 (A1, B1, Cy0, Ctrl, R1,
Cy1)
ALU1Bit ALUBIT2 (A2, B2, Cy1, Ctrl, R2,
Cy2)
ALU1Bit ALUBIT3 (A3, B3, Cy2, Ctrl, R3,
Cout)
27 module ALU1Bit ( A, B, Cin, Ctrl, R,
Cout)
ALU1Bit ALUBIT0 ( A0, B0, Cin, Ctrl, R0,
Cy0)
ALU1Bit ALUBIT1 (A1, B1, Cy0, Ctrl, R1,
Cy1)
ALU1Bit ALUBIT2 (A2, B2, Cy1, Ctrl, R2,
Cy2)
ALU1Bit ALUBIT3 (A3, B3, Cy2, Ctrl, R3,
Cout)
28 module ALU1Bit ( A, B, Cin, Ctrl, R,
Cout)
ALU1Bit ALUBIT0 ( A0, B0, Cin, Ctrl, R0,
Cy0)
ALU1Bit ALUBIT1 (A1, B1, Cy0, Ctrl, R1,
Cy1)
ALU1Bit ALUBIT2 (A2, B2, Cy1, Ctrl, R2,
Cy2)
ALU1Bit ALUBIT3 (A3, B3, Cy2, Ctrl, R3,
Cout)
29 module ALU1Bit ( A, B, Cin, Ctrl, R,
Cout)
ALU1Bit ALUBIT0 ( A0, B0, Cin, Ctrl, R0,
Cy0)
ALU1Bit ALUBIT1 (A1, B1, Cy0, Ctrl, R1,
Cy1)
ALU1Bit ALUBIT2 (A2, B2, Cy1, Ctrl, R2,
Cy2)
ALU1Bit ALUBIT3 (A3, B3, Cy2, Ctrl, R3,
Cout)
30 module ALU1Bit ( A, B, Cin, Ctrl, R,
Cout)
2-bits
ALU1Bit ALUBIT0 ( A0, B0, Cin, Ctrl, R0,
Cy0)
ALU1Bit ALUBIT1 (A1, B1, Cy0, Ctrl, R1,
Cy1)
ALU1Bit ALUBIT2 (A2, B2, Cy1, Ctrl, R2,
Cy2)
ALU1Bit ALUBIT3 (A3, B3, Cy2, Ctrl, R3,
Cout)
31 module ALU1Bit ( A, B, Cin, Ctrl, R,
Cout)
ALU1Bit ALUBIT0 ( A0, B0, Cin, Ctrl, R0,
Cy0)
ALU1Bit ALUBIT1 (A1, B1, Cy0, Ctrl, R1,
Cy1)
ALU1Bit ALUBIT2 (A2, B2, Cy1, Ctrl, R2,
Cy2)
ALU1Bit ALUBIT3 (A3, B3, Cy2, Ctrl, R3,
Cout)
32Vectors in a DO File
33Vectors in a DO File
Force the entire vector at the same time
34Vectors in a DO File
Force the entire vector at the same time
force A 1111 force B 0001
35Vectors in a DO File
Force the entire vector at the same time
force A 1111 force B 0001
Force the vector one bit at a time
36Vectors in a DO File
Force the entire vector at the same time
force A 1111 force B 0001
Force the vector one bit at a time
force Ctrl(0) 0, 1 10ns -r 20ns force
Ctrl(1) 0, 1 20ns -r 40ns
37Vectors in a UCF File
38Vectors in a UCF File
Each bit of a vector must be mapped individually
39Vectors in a UCF File
Each bit of a vector must be mapped individually
NET Ctrllt1gt LOC K13 SW7NET Ctrllt0gt
LOC K14 SW6
40Review of Vector Notation
In a Verilog file Ctrl0 In a DO file
Ctrl(0) In a UCF file Ctrllt0gt