Initial and Always ProcessesΒΆ

Initial and always statements describe independent processes, meaning that the statements in one process execute autonomously. Both types of processes consist of procedural statements and both start immediately as the simulator is started. The difference between the two is that initial processes execute once, whereas always process execute repeatedly forever. As such, an always process must contain timing statements that will occasionally block execution and allow time to advance (time in initial and always process only advances when they are blocked). Thus, activity in these process progresses in a burst during which time does not advance, and then the activity blocks, which allows time to move forward.

The following initial process generates a pulse on the reset line that occurs once shortly after the start of the simulation:

reg reset = 0;

initial begin
   #1 reset = 1;
   #1 reset = 0;
end

This always process generates a periodic clock:

reg clk = 0;

always #5 clk = ~clk;

Finally, these always processes implement a 4-bit counter with reset:

reg [3:0] count=0;

always @(posedge clk) count = count + 1;
always @(posedge reset) assign count = 0;
always @(negedge reset) deassign count;

Initial and always process may contain any of the following statement types: