Composite Statements

Sequential

A begin/end statement bundles multiple statements together so that they appear to be a single statement to the compiler. Each of the statements are executed in order. Here is a simple example:

always @(posedge clk) begin
   a <= b;
   b <= a;
end

Adding a name to the begin/end allows local variables to be declared within the block. The scope of these variable is just the block itself:

always @(posedge clk) begin : lcldecls
   integer A, B;
   A = b + c;
   B = d + e;
   a <= A*B;
end

Adding a name also allows for the use of disable. In this case it is used to build an oscillator that can be reset/synchronized using an edge of a sync pulse:

reg out = 0;

always #50 begin : osc
   out = ~out;
end
always @(posedge sync) disable osc;

Concurrent

A fork/join statement bundles multiple statements together so that they appear to be a single statement to the compiler. Each of the statements are executed simultaneously.

Simple example:

always @(posedge clk) fork
   a <= b;
   b <= a;
join

Adding a name to the fork/join allows local variables to be declared within the block. It also allows for the use of disable. In the following example it is used to create a timeout mechanism:

fork : measure_lock_time
   #250 begin
      locked = 0;
      disable measure_lock_time;
   end
   @(posedge lock) begin
      locked = 1;
      disable measure_lock_time;
   end
join