Verilog Procedural assignments

The primary discussion of procedural assignments is in Procedural assignments<add link>. However, a description of the basic ideas in this clause highlights the differences between continuous assignments and procedural assignments.

As stated in Continuous assignments<add link>, continuous assignments drive nets in a manner similar to the way gates drive nets. The
expression on the right-hand side can be thought of as a combinatorial circuit that drives the net
continuously. In contrast, procedural assignments put values in variables. The assignment does not have
duration; instead, the variable holds the value of the assignment until the next procedural assignment to that variable.

Procedural assignments occur within procedures such as always, initial (see Structured procedures <add link>), task, and function(see Tasks and functions <add link>) and can be thought of as “triggered” assignments. The trigger occurs when the flow of execution in the simulation reaches an assignment within a procedure. Reaching the assignment can be controlled by conditional statements. Event controls, delay controls, if statements, case statements, and looping statements can all be used to control whether assignments are evaluated. topic Behavioral modeling <add link> gives details and examples.

Variable declaration assignment:
The variable declaration assignment is a special case of procedural assignment as it assigns a value to a
variable. It allows an initial value to be placed in a variable in the same statement that declares the variable.
The assignment shall be to a constant expression. The assignment does not have duration; instead, the
variable holds the value until the next assignment to that variable. Variable declaration assignments to an
array are not allowed. Variable declaration assignments are only allowed at the module level. If the same
variable is assigned different values both in an initial block and in a variable declaration assignment, the
order of the evaluation is undefined.

 Example 1—Declare two real variables, assigned to the values 2.5 and 300,000.
 real r1 = 2.5, n300k = 3E6;

 Example 2—Declare a time variable and realtime variable with initial values.
 time t1 = 25;
 realtime rt1 = 2.5;

<< Previous | Next >>

Comments are closed.