Chap. 4 Modules and Ports
Dec 13, 2015
3
Modules
Basic component in Verilog for describing/defining a hardware
module <module_name> (<module_terminal_list>);<I/O declaration><parameter declaration>…<module internals>……endmodule
4
Components of Modules - I
Variables Declaration Dataflow Statement Module Instantiation Behavior Statement Tasks and Functions
7
Module Description of SR Gate
No “variable declaration”, “dataflow statement” and “behavioral statement” are included in this module
10
Ports
I/O Interface used to communicate with external module
“No” port declaration if do not need to communicate with other module, such as Top module
11
Module fulladd4 has five ports while top has no port.a, b, and c_in are input ports and sum and c_out are output ports.
List of Ports - I
17
Input Port Internal view - viewed as “a wire/net” External view - can be connected to a reg or wire
Output Port Internal view - declared as a reg or wire External view - only be connected to a wire
Inout Port viewed as a wire/net regardless of internal or extern
al module
Port Connection Rules - I
19
Mismatch of internal and external port connections Simulation should issue a warning for this conditio
n Floating of port connection
Fulladd4 fa0(sum, , a, b, c_in); // c_out floating
Illegal connection of internal and external ports
Port Connection Rules - II
21
Connecting Ports to External Signals Connecting ports by module declaration
sequence Connecting ports by name
23
Connecting Ports by Name Fulladd4 fa_byname(.c_out(c_out), .sum(sum),
.b(b), .c_in(c_in), .a(a));
Fulladd4 fa_byname(.sum(sum), .b(b),
.c_in(c_in), .a(a));
25
Hierarchical Names
Named each instance, variables and signals in hierarchical design
Root module Never be referenced by other modules, such as
stimulus Hierarchical instances are separated by dot
sign “.” $display (“%m”)
display hierarchical level of that module
28
Summary
A module contains module, endmodule keyword Port list, port declaration, variable declaration, dataflow statement,
behavioral block, module instantiation, task and function Ports provide an interface communicated with external environm
ent Input, output, inout
Connecting ports to external signals By port declaration sequence By port name
Hierarchical name Root module Separated by “.” between instances