Placing values onto variables and nets are called assignments. There are three necessary forms:
Legal LHS values
An assignment has two parts, right-hand side (RHS) and left-hand side (LHS) with an equal symbol (=) or a less than-equal symbol (<=) in between.
The RHS can contain any expression that evaluates to a final value while the LHS indicates a variable or net to which RHS's value is being assigned.
Procedural assignments occur within procedures such as initial, always, task, and functions are used to place values onto variables. The variable will hold the value until the next assignment to the same variable.
The value will be placed onto the variable when the simulation executes this statement during simulation time. This can be modified and controlled the way we want by using control flow statements such as if-else-if, looping, and case statement mechanisms.
Variable Declaration Assignment
An initial value can be placed onto a variable at the time of its declaration. The assignment does not have the duration and holds the value until the next assignment to the same variable happens.
NOTE: The variable declaration assignments to an array are not allowed.
If the variable is initialized during declaration and at 0 times in an initial block as shown below, the order of evaluation is not guaranteed, and hence can have either 8'h05 or 8'hee.
This is used to assign values onto scalar and vector nets. And it happens whenever there is a change in the RHS.
It provides a way to model combinational logic without specifying an interconnection of gates and makes it easier to drive the net with logical expressions.
Whenever b or c changes its value, the whole expression in RHS will be evaluated and updated with the new value.
Net Declaration Assignment
This allows us to place a continuous assignment on the same statement that declares the net.
NOTE: Only one declaration assignment is possible because a net can be declared only once.
Procedural Continuous Assignment
These are procedural statements that allow expressions to be continuously assigned to variables or nets. And these are the two types.
1. Assign deassign: It will override all procedural assignments to a variable and deactivate it using the same signal with deassign.
The value of the variable will remain the same until the variable gets a new value through a procedural or procedural continuous assignment.
The LHS of an assign statement cannot be a part-select, bit-select, or an array reference, but it can be a variable or a combination of the variables.
2. Force release: These are similar to the assign deassignstatements but can also be applied to nets and variables.
The LHS can be a bit-select of a net, part-select of a net, variable, or a net but cannot be the reference to an array and bit or part select of a variable.
The force statement will override all other assignments made to the variable until it is released using the release keyword.