Miscellaneous Statements

Disable

The disable statement terminates a named block, meaning that if that block is currently executing control immediately jumps to any subsequent statement. If the named block is not executing the disable statement has no effect. For example, disable can be 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

It can also be used to create a synchronization mechanism for an oscillator:

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

It can also be used to implement break and continue mechanisms for loops:

always @(posedge start) begin : break
   for (i=0; i<64; i=i+1) begin: continue
      attenuation = i;
      #1u;
      if (clipped(V(pout), V(nout))) begin
         $display('ERROR: attenuation = %d: output is clipped', i);
         disable break
      end
      expected = pow(10, -attenuation/20.0);
      measured = V(pout,nout) / V(pin,nin);
      passes = (0.9*expected < measured) && (measured < 1.1*expected);
      $display('%s: attenuation = %d', i, passes ? 'Pass' : 'FAIL');
      if (passes) disable continue;
      $display('      measured attenuation = %f', measured);
      $display('      expected attenuation = %f', expected);
   end
end

Trigger

The trigger statement (->) is used to trigger named events. For example:

event update_result;

always @update_result
   result = find_result(x, y, z);

initial
   -> update_result;

This example shows enough to see that result is computed initially as the simulator starts, but it could be updated at any time simply by triggering the update_result event.