4. Verilog II¶
Review¶
Design metrics: 1. Functionality and robustness 2. Cost 3. Performance 4. Power and Energy
Verilog: 1. Hardware Description language 2. Logic synthesis: Verilog -> Gate-level netlists 3. Used in both ASIC and FPGA
Verilog Introduction¶
A module definition describes a component in a circuit. There are two ways to describe module contents 1. Structural Verilog
-
List of sub-components and how they are connected
-
Just like schematics, but using text
-
Tedious to write, hard to decode
-
You get precise control over circuit details
-
May be necessary to map to special resources of the FPGA/ASIC
-
Behavioral Verilog
-
Describe what a component does, not how it does it
-
Synthesized into a circuit that has this behavior
-
Result is only as good as the tools
The idea is to build up a hierarchy of modules. Top-level module is your entire design (or the environment to test your design)
Verilog Modules and Instantiation¶
Modules define circuit components. Instantiation defines hierarchy of design:

A module is not a functio in the C sense. Ther eis no call and return mechanism. Think of it more like a hierarchical data structure.
Here is an example: XOR

Note that the instantiated gates are not executed. They are active always. The xorgate already exists as a built-in (so really no need to define it). Undeclared variables assumed to be wires. Don't let this happen to you!
Simple Behavioral Model¶

The assign statement has a bitwise "and" gate. The assignment continuously happens, therefore any change on the RHS is reflected in out immediately (except for small delay associated with the implemnetaion of the practical &.)
It is not like an assignment in C that takes place when the program counter gets to that place in the program.
Instantiation, Signal Array, Named Ports¶

Example: Ripple Adder¶

Verilog Operators¶



Continuous Assignment Examples¶
Assign values whenever there is a change in the RHS. Model combinational logic without specifying an interconnection of gates:

Non-Continuous Assignmnets¶
This is a bit unusual from a hardware specification point of view. However it shows that Verilog is a simulation language

Always Blocks¶
Always blocks give us some constructs that are impossible or awkward in continuous assignments


Simplified Verilog Guidelines¶
For combinational logic:
- Continuous assignment: assign a = b & c
- Always block with
@(*):
always @(*) begin
a = b & c; // blocking statement
end