The module is the basic unit of hierarchy in Verilog. Modules contain declarations and functional decriptions and represent hardware components.
Syntax ( Key to Notation )
{either}
module ModuleName [(Port,...)];
ModuleItem...
endmodule
macromodule ModuleName [(Port,...)];
ModuleItem...
endmodule
ModuleItem = {either}
Declaration
Defparam
Continuous Assignment
Instance
Specify
Initial
Always
Modules are declared outside any other modules or primitives.
The same keyword, endmodule, is used at the end of both modules and macromodules.
Have only one module declaration per file. This eases source code maintenance for a large design.
macromodule nand2 (f, a, b);
output f;
input a, b;
nand (f, a, b);
endmodule
module PYTHAGORAS (X, Y, Z);
input [63:0] X, Y;
output [63:0] Z;
parameter Epsilon = 1.0E-6;
real RX, RY, X2Y2, A, B;
always @(X or Y)
begin
RX = $bitstoreal(X);
RY = $bitstoreal(Y);
X2Y2 = (RX * RX) + (RY * RY);
B = X2Y2;
A = 0.0;
while ((A - B) > Epsilon || (A - B) < -Epsilon)
begin
A = B;
B = (A + X2Y2 / A) / 2.0;
end
end
assign Z = $realtobits(A);
endmodule
Primitive, Instantiation
Verilog Quick Reference
Doulos Training
Courses
Back to the Verilog Golden Reference Guide
Copyright 1995-1997 Doulos
This page was last updated 16th July 1996
We welcome your e-mail
comments. Please contact us at: webmaster@doulos.co.uk