Boundaries (Module, Endmodule) Inputs and Outputs (Ports) How It Works (Behavioral or RTL Code)
Boundaries (Module, Endmodule) Inputs and Outputs (Ports) How It Works (Behavioral or RTL Code)
Can be a single element or collection of lower level modules Module can describe a hierarchical design (a module of modules) A module should be contained within one le Module name should match the le name Module fadder resides in le named fadder.sv Multiple modules can reside within one le (not recommended) Correct partitioning a design into modules is critical
What kind of logic do you expect synthesis to produce? This is always a good question to ask.
assign
The assign statements may execute in any order We can consider that they are executed simultaneously This is how the logic would operate
Some Lexical Conventions - Comments Comments are signied the same as C One line comments begin with // Multi-line comments start: /*, end: */ Some Lexical Conventions - Identiers Identiers are names given to objects so that they may be referenced They start with alphabetic chars or underscore They cannot start with a number or dollar sign All identiers are case sensitive
Testbench Modules To test a chip at the top hierarchical level, we use a testbench Testbench encompasses the chip at the top level Testbench has no ports,...but probably some le i/o
Momentary digression on Verilog primitive gates.... A number of virtual gates are built-in to the language
and, or, nand, nor, xor, xnor, tristate, pullup and pulldown
Each gate has one output, the right most argument Gates have as many inputs as required These gates are models only, no physical part exists Good for experimentation in absence of a cell library
This method of declaring pins/wires is called named association. This is the preferred way of doing instantiation when pins/names dier. Comment each wire connection if its function is not obvious.
Its possible to connect wires to pins by position alone Called positional association... just say no!
shift_reg shift_reg_1(clk_50,reset_n,data_ena,serial_data,shift_reg_out);
How do you know its connected correctly? What if the module had 50 pins on it? What if you wanted to add wire in the middle of the list? Do not use Positional Association! It saves time once, and costs you dearly afterwords
This is the most powerful form of implicit association. Its best reserved for use at the top level testbench/top module. Otherwise, it could hide intent.
Unused ports may be left out of the port list...not recommended Make your intent clear!
In the module declaration, the keyword parameter is not required It does read more clearly however
Verilog modules provide a coarse-grain structuring mechanism Modules contain RTL logic or other modules Modules provide an abstraction mechanism via complexity hiding Modules provide a way to reuse designs How is a Verilog module dierent from a C function?