FPGA Based System Design: Gate Level Modeling
FPGA Based System Design: Gate Level Modeling
VERILOG PROGRAMMING
w2
module full_adder(S,Co,A,B,Ci);
input A,B,Ci;
output S,Co; wire w1,w2,w3;
half_adder h1(w1,w2,A,B);//instantiate from half adder
half_adder h2(S,w3,w1,Ci);
or (Co,w2,w3);
endmodule
www.iiu.edu.pk 2 Wednesday, March 25, 2020
1
3/25/2020
Module Instantiation
A module provides a template from which you can create actual
objects.
When a module is invoked, Verilog creates a unique object from the
template.
Each object has its own name, variables, parameters, and I/O
interface.
The process of creating objects from a module template is called
instantiation, and the objects are called instances
In four_bit_adder module we used 4 instances of full_adder
template and each instance has been given a unique name.
Illegal Module Nesting
module full_adder(S,Co,A,B,Ci);
input A,B,Ci; output S,Co;
module half_adder(S,Co,A,B); // Illegal module nesting
endmodule // End of Illegal nesting
endmodule
2
3/25/2020
Design Hierarchy
1 Four Bit Full Adder
1-bit Full Adder 1-bit Full Adder 1-bit Full Adder 1-bit Full Adder
AND XOR
3
3/25/2020
4
3/25/2020
5
3/25/2020
6
3/25/2020
7
3/25/2020
8
3/25/2020
9
3/25/2020
10
3/25/2020
11