Syntax and Basic Elements
Modules are the fundamental building blocks in Verilog.
module module_name (port_list);
input input_port;
output output_port;
// Internal signals
wire internal_signal;
// Logic implementation
assign output_port = input_port & internal_signal;
endmodule
|
Instantiation:
module_name instance_name (
.input_port (signal_a),
.output_port (signal_b)
);
|
|
Represents a physical wire, cannot store values.
|
|
Represents a variable that stores a value. Used in always blocks.
|
|
General-purpose variable, typically 32 bits.
|
|
|
|
Unsigned 64-bit integer for simulation time.
|
|
Four-state data type: 0, 1, X (unknown), Z (high impedance). SystemVerilog only.
|
<size>'<base><value>
<size> : Size in bits.
<base> : b (binary), o (octal), d (decimal), h (hexadecimal).
<value> : The number.
Examples:
4'b1010 - 4-bit binary number 1010.
8'hFF - 8-bit hexadecimal number FF (255 in decimal).
16'd255 - 16-bit decimal number 255.
|