2.1 Verilog UDP Basics
Category Advanced Verilog Tutorial
The built-in gate primitives introduced in gate-level modeling, such as and, or, nor, etc., are all part of the standard primitives provided by Verilog, commonly referred to as built-in primitives.
Additionally, Verilog allows users to write their own primitives, known as User Defined Primitives (UDP).
In UDP, no other modules or primitives can be called, and the calling method is identical to that of gate-level primitives.
There are mainly two types of UDPs, which will be introduced one by one later.
Combinational Logic UDP: The output is solely determined by the combination of input signals.
Sequential Logic UDP: The next output value depends not only on the current input values but also on the current internal state.
UDP Definition
The definition of UDP does not rely on module definitions, so it can appear outside of module definitions or be defined separately in a file.
The format for defining UDP is as follows:
Example
primitive UDP_name (
output_name,
list_of_input);
output_declaration;
list_of_input_declaration;
[reg_declaration];
[initial_statement];
table
list_of_table_entries;
endtable
endprimitive
UDP Explanation
Port Declaration:
- The port declaration part is similar to that of a module. You can list the port signals in the port list and then specify their types within the primitive entity, or directly specify their types in the port list.
- Input ports can only be scalars (i.e., 1 bit), and multiple input ports are allowed.
- There is only one output port allowed, which must be a scalar (i.e., 1 bit), and the output port must appear in the first position of the port list. Multiple output ports are absolutely not allowed.
- The output port is declared with the output keyword, and for sequential logic UDPs that need to save state, the output port must also be declared as reg type.
- UDP does not support inout port types.
Initialization
The initial statement can be used to initialize the output port (reg type) of a sequential logic UDP, which is optional.
State Table
- The UDP state table is the most important part of the UDP, declared with the table keyword. It defines how the output value is obtained based on the input state and the current state, similar to a logic truth table.
- The entries in the state table can be 0, 1, or x. UDP cannot handle z values, so z values passed to the UDP are treated as x.
-1.2 Verilog Switch-Level Modeling
- 2.1 Verilog UDP Basics
-2.2 Verilog Combinational Logic UDP
-2.3 Verilog Sequential Logic UDP
-3.2 Verilog specify Block Statements
-3.3 Verilog Setup and Hold Times
-3.5 Verilog Delay Backannotation
-4.1 Verilog Synchronous and Asynchronous
-4.2 Verilog Clock Domain Crossing: Slow to Fast
-4.3 Verilog Clock Domain Crossing: Fast to Slow
-5.1 Verilog Reset Introduction
-5.2 Verilog Clock Introduction
-6.1 Verilog Low Power Introduction
-6.2 Verilog System-Level Low Power Design
-6.3 Verilog RTL-Level Low Power Design (Part 1)
-6.4 Verilog RTL-Level Low Power Design (Part 2)
-7.3 Verilog Random Numbers and Probability Distributions
-7.4 Verilog Real to Integer Conversion
-7.5 Verilog Other System Tasks
-8.3 Verilog TF Subroutine List
-8.5 Verilog ACC Subroutine List
-9.2 Verilog Synthesizable Design
WeChat Subscription
English: