Prev Page Next Page

Disable Statement

Formal Definition

The disable statement provides means of terminating active procedures.

Simplified Syntax

disable task_identifier;

disable block_identifier;

Description

The disable statement can be used to terminate tasks (Example 1), named blocks (Example 2) and loop statements (Example 3) or for skipping statements in loop iteration statements (Example 4). Using the disable keyword followed by a task or block identifier will only disable tasks and named blocks. It cannot disable functions. If the task that is being disabled enables other tasks, all enabled tasks will be terminated.

If a task is enabled more than once, then disabling that task terminates all its instances.

Examples

Example 1

task t;
output o;
integer o;
#100 o = 15;
endtask
disable t; // Disabling task t.

Example 2

begin : named_block
a = 1; // #1
disable named_block;
a = 2; // #2
end

Statement #2 will never be executed, therefore after execution of this block, variable 'a' will have 1 as its value.

Example 3

begin : break_block
i = 0;
forever begin
  if (i==a)
  disable break_block;
  #1 i = i + 1;
  end
end

The forever statement will be executed until 'i' is not equal to 'a'.

Example 4

begin
i = 0;
forever begin : continue_block
  if (i==a)
  disable continue_block;
  #1 i = i + 1;
  end
end

If 'i' is equal to 'a' then statement (#1 i = i + 1) that appears after the disable statement will not be executed.

Important Notes

 
Prev Page Next Page
Powered by IXwebhosting