SlideShare a Scribd company logo
1 of 6
Download to read offline
1|Page

Notes: Verilog Part 2
4 CHAPTER 4:
4.1 MODULES:



Modules are the basic building blocks of any Verilog code.
A Module in Verilog consists of different parts.
Module Name,
Port List, Port Declarations,
Parameters (Optional),
Declaration of Variables
Instantiation of lower level modules

Data Flow Statements
always and initial blocks.

Tasks and Functions.
endmodule statement.










A Module definition always begins with the keyword module. It should
be duly noted that there must not be any changes in the sequence of
parts mentioned above.
Port List and Port Declarations are present only if the module has any
ports to interact with.
All components except the module, module name and endmodule are
optional.
The five components within the module viz. Declaration of Varibales,
Data Flow Statements, Instantiation of lower level modules, always and
initial blocks and Tasks and Functions can appear in any order.
Verilog allows multiple modules to be defined in any order in a file.
However, nesting of modules (defining one module in another) is
prohibited.

4.2 EXAMPLE: SR LATCH


The SR Latch has S and R as the input ports and Q and Qbar as the
output ports.
The stimulus and the design can be modelled as shown in SR_Latch



Ports provide the interface by which a module can communicate with its
environment. The environment can interact with the module only with
the port.
They are also referred to as terminals.

4.3 PORTS



Notes: Verilog Part-2

Prepared By: Jay Baxi
2|Page

4.4 LIST OF PORTS:






A module definition can optionally have a list of ports. If module does
not need to exchange any signals with the environment, there are no
ports in the list.
In case of a top level module TOP, which has a full adder module
4fulladd. The module 4fulladd takes input a, b, c_in as inputs and
produces sum and c_out as outputs.
The top level module does not need to pass or receive signals. Thus it
does not have a list of ports.

4.5 PORT DECLARATION







All ports in the list of ports must be declared in the module.
They can be input (input port), output (output port) or inout port
(bidirectional port).
By default these ports are declared as wire.
However, if output holds their value, they must be declared as reg.
For example, in D_FF, when q was supposed to retain its value after a
clock edge.
Ports of input and inout cannot be declared as reg because reg variables
are supposed to store values and input ports should not store values but
simply reflect the changes in the external signals they are connected to.
(ERROR)

Internal
External
Inputs
net
reg/net
Outputs
reg/net
reg
Inouts
net
net
 Width Matching: It is legal to connect internal and external items of
different sizes when making inter-module port connections. A warning is
usually displayed that widths do not match.
 Unconnected ports: Verilog allows the ports to remain unconnected. For
ports that are used only for debugging, it can be remained unconnected.
The module, in this case can be instantiated by
4fulladd(SUM, , A, B, C_in) // port C_out is unconnected

4.6 CONNECTING PORTS TO EXTERNAL SIGNALS


Notes: Verilog Part-2

There are two methods to connect ports to external signals
1.) Connecting Ports by ordered lists:
The signals to be connected must appear in the module instantiation in the
same order as the ports in the port list in the module definition
2.) Connecting Ports by name:
For large modules, it is not feasible to remember the order of each port.
Hence, in those cases, Verilog provides connecting external signals to ports
by the port names.

Prepared By: Jay Baxi
3|Page

5 CHAPTER 5:
5.1 TRUTH TABLES OF LOGIC GATES
5.1.1

5.1.2

5.1.3

5.1.4

5.1.5

AND Gate
AND
0
1
X
Z

0
0
0
0
0

1
0
1
X
X

X
0
X
X
X

Z
0
X
X
X

OR Gate
OR
0
1
X
Z

0
0
1
X
X

1
1
1
1
1

X
X
1
X
X

Z
X
1
X
X

NAND Gate
NAND
0
1
X
Z

0
1
1
1
1

1
1
0
X
X

X
1
X
X
X

Z
1
X
X
X

NOR Gate
NOR
0
1
X
Z

0
1
0
X
X

1
0
0
0
0

X
X
0
X
X

Z
X
0
X
X

XOR Gate
XOR
0
1
X
Z

0
0
1
X
X

1
1
0
X
X

X
X
X
X
X

Z
X
X
X
X

Notes: Verilog Part-2

Prepared By: Jay Baxi
4|Page
5.1.6

5.1.7

XNOR Gate
XNOR
0
1
X
Z

0
1
0
X
X

1
0
1
X
X

Z
X
X
X
X

BUF Gate and NOT Gate
In
0
1
X
Z

5.1.8

X
X
X
X
X

BUF
0
1
X
X

NOT
1
0
X
X

BUFif and NOTif



The BUFif and NOTif are the gates that propagate only if their control
signal is asserted. They propagate Z if the signal is deasserted.
These signals are used when a signal is driven only when the control
signal is asserted, this is a case when multiple drivers drive the signal
//Instantiation of gates
bufif1 b1 (out, in, ctrl);
bufif0 b0 (out, in, ctrl);
notif1 n1(out, in, ctrl);
notif0 n0(out, in, ctrl);



The Truth Tables of these gates are given as follows

Bufif1
0
1
X
Z

0
Z
Z
Z
Z

1
0
1
X
X

X
L
H
X
X

Z
L
H
X
X

Bufif0
0
1
X
Z

0
0
1
X
Z

1
Z
Z
Z
Z

X
L
H
X
X

Z
L
H
X
X

Notif1
0
1
X
Z

0
Z
Z
Z
Z

1
1
0
X
X

X
H
L
X
X

Z
H
L
X
X

Notes: Verilog Part-2

Prepared By: Jay Baxi
5|Page
Notif0
0
1
X
Z
5.1.9

0
1
0
X
X

Array of Instances


1
Z
Z
Z
Z

X
H
L
X
X

Z
H
L
X
X

For situations when there are more than one instances required, Verilog
allows us to create array of instances where each instance differs from
other just by the index.

5.1.10 Examples:
5.1.10.1 Gate Level Multiplexer
 We will design a 4-to-1 Mux with 2 select signals. Using the basic logic gates the logic
diagram of a 4-to-1 Mux is given as follows

 The Verilog modules for the same are given in Multiplexer
5.1.10.2 4-bit Ripple Carry Adder
 A 4-bit full adder can be created from four 1-bit FA. The Verilog modules for the same is
given in Full Adder.

5.2 GATE DELAYS




Rise delay is when a delay is experienced while transition from 0, X or Z to 1.
Fall delay is when a delay is experienced while transition from 1, X or Z to 0.
Turn off delay is associated with a gate output transition to high impedance
(Z) value from another value.

Notes: Verilog Part-2

Prepared By: Jay Baxi
6|Page




Notes: Verilog Part-2

Min value: The minimum value of delay, the designer expects to have.
Max value: The maximum value of delay, the designer expects to have.
Typ value: The typical value of delay, the designer expects to have.

Prepared By: Jay Baxi

More Related Content

What's hot

04 control structures 1
04 control structures 104 control structures 1
04 control structures 1
Jomel Penalba
 

What's hot (20)

Notes part5
Notes part5Notes part5
Notes part5
 
C programming session7
C programming  session7C programming  session7
C programming session7
 
PM1
PM1PM1
PM1
 
C programming session8
C programming  session8C programming  session8
C programming session8
 
C programming session3
C programming  session3C programming  session3
C programming session3
 
C programming session6
C programming  session6C programming  session6
C programming session6
 
Hd6
Hd6Hd6
Hd6
 
Microcontroller lec 3
Microcontroller  lec 3Microcontroller  lec 3
Microcontroller lec 3
 
FPGA training session generic package and funtions of VHDL by Digitronix Nepal
FPGA training session generic package and funtions of VHDL by Digitronix NepalFPGA training session generic package and funtions of VHDL by Digitronix Nepal
FPGA training session generic package and funtions of VHDL by Digitronix Nepal
 
Basic structure of c programming
Basic structure of c programmingBasic structure of c programming
Basic structure of c programming
 
C programming session10
C programming  session10C programming  session10
C programming session10
 
04 control structures 1
04 control structures 104 control structures 1
04 control structures 1
 
Operators used in vb.net
Operators used in vb.netOperators used in vb.net
Operators used in vb.net
 
Control structures ii
Control structures ii Control structures ii
Control structures ii
 
Quiz 9
Quiz 9Quiz 9
Quiz 9
 
Embedded c
Embedded cEmbedded c
Embedded c
 
Symbolic Execution (introduction and hands-on)
Symbolic Execution (introduction and hands-on)Symbolic Execution (introduction and hands-on)
Symbolic Execution (introduction and hands-on)
 
Ch10 Program Organization
Ch10 Program OrganizationCh10 Program Organization
Ch10 Program Organization
 
Recursive Function
Recursive FunctionRecursive Function
Recursive Function
 
Ch4 Expressions
Ch4 ExpressionsCh4 Expressions
Ch4 Expressions
 

Viewers also liked

Seminar: Fabrication and Characteristics of CMOS
Seminar: Fabrication and Characteristics of CMOSSeminar: Fabrication and Characteristics of CMOS
Seminar: Fabrication and Characteristics of CMOS
Jay Baxi
 
Operating system concepts (notes)
Operating system concepts (notes)Operating system concepts (notes)
Operating system concepts (notes)
Sohaib Danish
 

Viewers also liked (15)

Radiation Hardening by Design
Radiation Hardening by DesignRadiation Hardening by Design
Radiation Hardening by Design
 
Functions and tasks in verilog
Functions and tasks in verilogFunctions and tasks in verilog
Functions and tasks in verilog
 
Seminar: Fabrication and Characteristics of CMOS
Seminar: Fabrication and Characteristics of CMOSSeminar: Fabrication and Characteristics of CMOS
Seminar: Fabrication and Characteristics of CMOS
 
Designing of fifo and serial peripheral interface protocol using Verilog HDL
Designing of fifo and serial peripheral interface protocol using Verilog HDLDesigning of fifo and serial peripheral interface protocol using Verilog HDL
Designing of fifo and serial peripheral interface protocol using Verilog HDL
 
First Year Basic Electronics Notes VTU Syllabus 2014 Scheme
First Year Basic Electronics Notes VTU Syllabus 2014 SchemeFirst Year Basic Electronics Notes VTU Syllabus 2014 Scheme
First Year Basic Electronics Notes VTU Syllabus 2014 Scheme
 
Web design and development cs506 handouts
Web design and development   cs506 handoutsWeb design and development   cs506 handouts
Web design and development cs506 handouts
 
4Sem VTU-HDL Programming Notes-Unit1-Introduction
4Sem VTU-HDL Programming Notes-Unit1-Introduction4Sem VTU-HDL Programming Notes-Unit1-Introduction
4Sem VTU-HDL Programming Notes-Unit1-Introduction
 
Fundamentals of HDL (first 4 chapters only) - Godse
Fundamentals of HDL (first 4 chapters only) - GodseFundamentals of HDL (first 4 chapters only) - Godse
Fundamentals of HDL (first 4 chapters only) - Godse
 
MOSFETs (10EC63) Notes for Electronics & Communication Engineering Students o...
MOSFETs (10EC63) Notes for Electronics & Communication Engineering Students o...MOSFETs (10EC63) Notes for Electronics & Communication Engineering Students o...
MOSFETs (10EC63) Notes for Electronics & Communication Engineering Students o...
 
Verilog codes and testbench codes for basic digital electronic circuits.
Verilog codes and testbench codes for basic digital electronic circuits. Verilog codes and testbench codes for basic digital electronic circuits.
Verilog codes and testbench codes for basic digital electronic circuits.
 
Microelectronic Circuits Notes (10EC63) by Dr. M. C. Hanumantharaju of BMS In...
Microelectronic Circuits Notes (10EC63) by Dr. M. C. Hanumantharaju of BMS In...Microelectronic Circuits Notes (10EC63) by Dr. M. C. Hanumantharaju of BMS In...
Microelectronic Circuits Notes (10EC63) by Dr. M. C. Hanumantharaju of BMS In...
 
Microelectronic Circuits (10EC63) Notes for Visvesvaraya Technological Univer...
Microelectronic Circuits (10EC63) Notes for Visvesvaraya Technological Univer...Microelectronic Circuits (10EC63) Notes for Visvesvaraya Technological Univer...
Microelectronic Circuits (10EC63) Notes for Visvesvaraya Technological Univer...
 
Embedded System Design Notes written by Arun Kumar G, Associate Professor, De...
Embedded System Design Notes written by Arun Kumar G, Associate Professor, De...Embedded System Design Notes written by Arun Kumar G, Associate Professor, De...
Embedded System Design Notes written by Arun Kumar G, Associate Professor, De...
 
Operating system concepts (notes)
Operating system concepts (notes)Operating system concepts (notes)
Operating system concepts (notes)
 
Embedded systems class notes
Embedded systems  class notes Embedded systems  class notes
Embedded systems class notes
 

Similar to Notes: Verilog Part 2 - Modules and Ports - Structural Modeling (Gate-Level Modeling)

1.5 Legal Labels in Verilog areSystem Verilog extends it and al.pdf
1.5 Legal Labels in Verilog areSystem Verilog extends it and al.pdf1.5 Legal Labels in Verilog areSystem Verilog extends it and al.pdf
1.5 Legal Labels in Verilog areSystem Verilog extends it and al.pdf
ankit482504
 
vlsi introduction to hdl and its typesunit-1.pptx
vlsi introduction to hdl and its typesunit-1.pptxvlsi introduction to hdl and its typesunit-1.pptx
vlsi introduction to hdl and its typesunit-1.pptx
iconicyt2
 
Fpga 07-port-rules-gate-delay-data-flow-carry-look-ahead-adder
Fpga 07-port-rules-gate-delay-data-flow-carry-look-ahead-adderFpga 07-port-rules-gate-delay-data-flow-carry-look-ahead-adder
Fpga 07-port-rules-gate-delay-data-flow-carry-look-ahead-adder
Malik Tauqir Hasan
 
CSCI 2121- Computer Organization and Assembly Language Labor.docx
CSCI 2121- Computer Organization and Assembly Language Labor.docxCSCI 2121- Computer Organization and Assembly Language Labor.docx
CSCI 2121- Computer Organization and Assembly Language Labor.docx
annettsparrow
 

Similar to Notes: Verilog Part 2 - Modules and Ports - Structural Modeling (Gate-Level Modeling) (20)

Modules and ports in Verilog HDL
Modules and ports in Verilog HDLModules and ports in Verilog HDL
Modules and ports in Verilog HDL
 
VHDL- gate level modelling
VHDL- gate level modellingVHDL- gate level modelling
VHDL- gate level modelling
 
1.5 Legal Labels in Verilog areSystem Verilog extends it and al.pdf
1.5 Legal Labels in Verilog areSystem Verilog extends it and al.pdf1.5 Legal Labels in Verilog areSystem Verilog extends it and al.pdf
1.5 Legal Labels in Verilog areSystem Verilog extends it and al.pdf
 
vlsi introduction to hdl and its typesunit-1.pptx
vlsi introduction to hdl and its typesunit-1.pptxvlsi introduction to hdl and its typesunit-1.pptx
vlsi introduction to hdl and its typesunit-1.pptx
 
Verilog
VerilogVerilog
Verilog
 
Verilog_ppt.pdf
Verilog_ppt.pdfVerilog_ppt.pdf
Verilog_ppt.pdf
 
Fpga 04-verilog-programming
Fpga 04-verilog-programmingFpga 04-verilog-programming
Fpga 04-verilog-programming
 
Fpga 07-port-rules-gate-delay-data-flow-carry-look-ahead-adder
Fpga 07-port-rules-gate-delay-data-flow-carry-look-ahead-adderFpga 07-port-rules-gate-delay-data-flow-carry-look-ahead-adder
Fpga 07-port-rules-gate-delay-data-flow-carry-look-ahead-adder
 
Basics of digital verilog design(alok singh kanpur)
Basics of digital verilog design(alok singh kanpur)Basics of digital verilog design(alok singh kanpur)
Basics of digital verilog design(alok singh kanpur)
 
VLSI & E-CAD Lab Manual
VLSI & E-CAD Lab ManualVLSI & E-CAD Lab Manual
VLSI & E-CAD Lab Manual
 
e CAD lab manual
e CAD lab manuale CAD lab manual
e CAD lab manual
 
Gate level design -For beginners
Gate level design -For beginnersGate level design -For beginners
Gate level design -For beginners
 
Introduction to VHDL
Introduction to VHDLIntroduction to VHDL
Introduction to VHDL
 
Ccnp labs
Ccnp labsCcnp labs
Ccnp labs
 
verilog
verilogverilog
verilog
 
Ccnp3 lab 3_5_en (hacer)
Ccnp3 lab 3_5_en (hacer)Ccnp3 lab 3_5_en (hacer)
Ccnp3 lab 3_5_en (hacer)
 
Practical file
Practical filePractical file
Practical file
 
CSCI 2121- Computer Organization and Assembly Language Labor.docx
CSCI 2121- Computer Organization and Assembly Language Labor.docxCSCI 2121- Computer Organization and Assembly Language Labor.docx
CSCI 2121- Computer Organization and Assembly Language Labor.docx
 
Kroening et al, v2c a verilog to c translator
Kroening et al, v2c   a verilog to c translatorKroening et al, v2c   a verilog to c translator
Kroening et al, v2c a verilog to c translator
 
Assic 6th Lecture
Assic 6th LectureAssic 6th Lecture
Assic 6th Lecture
 

Recently uploaded

Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
ZurliaSoop
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 

Recently uploaded (20)

REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptx
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 

Notes: Verilog Part 2 - Modules and Ports - Structural Modeling (Gate-Level Modeling)

  • 1. 1|Page Notes: Verilog Part 2 4 CHAPTER 4: 4.1 MODULES:   Modules are the basic building blocks of any Verilog code. A Module in Verilog consists of different parts. Module Name, Port List, Port Declarations, Parameters (Optional), Declaration of Variables Instantiation of lower level modules Data Flow Statements always and initial blocks. Tasks and Functions. endmodule statement.       A Module definition always begins with the keyword module. It should be duly noted that there must not be any changes in the sequence of parts mentioned above. Port List and Port Declarations are present only if the module has any ports to interact with. All components except the module, module name and endmodule are optional. The five components within the module viz. Declaration of Varibales, Data Flow Statements, Instantiation of lower level modules, always and initial blocks and Tasks and Functions can appear in any order. Verilog allows multiple modules to be defined in any order in a file. However, nesting of modules (defining one module in another) is prohibited. 4.2 EXAMPLE: SR LATCH  The SR Latch has S and R as the input ports and Q and Qbar as the output ports. The stimulus and the design can be modelled as shown in SR_Latch  Ports provide the interface by which a module can communicate with its environment. The environment can interact with the module only with the port. They are also referred to as terminals. 4.3 PORTS  Notes: Verilog Part-2 Prepared By: Jay Baxi
  • 2. 2|Page 4.4 LIST OF PORTS:    A module definition can optionally have a list of ports. If module does not need to exchange any signals with the environment, there are no ports in the list. In case of a top level module TOP, which has a full adder module 4fulladd. The module 4fulladd takes input a, b, c_in as inputs and produces sum and c_out as outputs. The top level module does not need to pass or receive signals. Thus it does not have a list of ports. 4.5 PORT DECLARATION       All ports in the list of ports must be declared in the module. They can be input (input port), output (output port) or inout port (bidirectional port). By default these ports are declared as wire. However, if output holds their value, they must be declared as reg. For example, in D_FF, when q was supposed to retain its value after a clock edge. Ports of input and inout cannot be declared as reg because reg variables are supposed to store values and input ports should not store values but simply reflect the changes in the external signals they are connected to. (ERROR) Internal External Inputs net reg/net Outputs reg/net reg Inouts net net  Width Matching: It is legal to connect internal and external items of different sizes when making inter-module port connections. A warning is usually displayed that widths do not match.  Unconnected ports: Verilog allows the ports to remain unconnected. For ports that are used only for debugging, it can be remained unconnected. The module, in this case can be instantiated by 4fulladd(SUM, , A, B, C_in) // port C_out is unconnected 4.6 CONNECTING PORTS TO EXTERNAL SIGNALS  Notes: Verilog Part-2 There are two methods to connect ports to external signals 1.) Connecting Ports by ordered lists: The signals to be connected must appear in the module instantiation in the same order as the ports in the port list in the module definition 2.) Connecting Ports by name: For large modules, it is not feasible to remember the order of each port. Hence, in those cases, Verilog provides connecting external signals to ports by the port names. Prepared By: Jay Baxi
  • 3. 3|Page 5 CHAPTER 5: 5.1 TRUTH TABLES OF LOGIC GATES 5.1.1 5.1.2 5.1.3 5.1.4 5.1.5 AND Gate AND 0 1 X Z 0 0 0 0 0 1 0 1 X X X 0 X X X Z 0 X X X OR Gate OR 0 1 X Z 0 0 1 X X 1 1 1 1 1 X X 1 X X Z X 1 X X NAND Gate NAND 0 1 X Z 0 1 1 1 1 1 1 0 X X X 1 X X X Z 1 X X X NOR Gate NOR 0 1 X Z 0 1 0 X X 1 0 0 0 0 X X 0 X X Z X 0 X X XOR Gate XOR 0 1 X Z 0 0 1 X X 1 1 0 X X X X X X X Z X X X X Notes: Verilog Part-2 Prepared By: Jay Baxi
  • 4. 4|Page 5.1.6 5.1.7 XNOR Gate XNOR 0 1 X Z 0 1 0 X X 1 0 1 X X Z X X X X BUF Gate and NOT Gate In 0 1 X Z 5.1.8 X X X X X BUF 0 1 X X NOT 1 0 X X BUFif and NOTif   The BUFif and NOTif are the gates that propagate only if their control signal is asserted. They propagate Z if the signal is deasserted. These signals are used when a signal is driven only when the control signal is asserted, this is a case when multiple drivers drive the signal //Instantiation of gates bufif1 b1 (out, in, ctrl); bufif0 b0 (out, in, ctrl); notif1 n1(out, in, ctrl); notif0 n0(out, in, ctrl);  The Truth Tables of these gates are given as follows Bufif1 0 1 X Z 0 Z Z Z Z 1 0 1 X X X L H X X Z L H X X Bufif0 0 1 X Z 0 0 1 X Z 1 Z Z Z Z X L H X X Z L H X X Notif1 0 1 X Z 0 Z Z Z Z 1 1 0 X X X H L X X Z H L X X Notes: Verilog Part-2 Prepared By: Jay Baxi
  • 5. 5|Page Notif0 0 1 X Z 5.1.9 0 1 0 X X Array of Instances  1 Z Z Z Z X H L X X Z H L X X For situations when there are more than one instances required, Verilog allows us to create array of instances where each instance differs from other just by the index. 5.1.10 Examples: 5.1.10.1 Gate Level Multiplexer  We will design a 4-to-1 Mux with 2 select signals. Using the basic logic gates the logic diagram of a 4-to-1 Mux is given as follows  The Verilog modules for the same are given in Multiplexer 5.1.10.2 4-bit Ripple Carry Adder  A 4-bit full adder can be created from four 1-bit FA. The Verilog modules for the same is given in Full Adder. 5.2 GATE DELAYS    Rise delay is when a delay is experienced while transition from 0, X or Z to 1. Fall delay is when a delay is experienced while transition from 1, X or Z to 0. Turn off delay is associated with a gate output transition to high impedance (Z) value from another value. Notes: Verilog Part-2 Prepared By: Jay Baxi
  • 6. 6|Page    Notes: Verilog Part-2 Min value: The minimum value of delay, the designer expects to have. Max value: The maximum value of delay, the designer expects to have. Typ value: The typical value of delay, the designer expects to have. Prepared By: Jay Baxi