Featured post

Top 5 books to refer for a VHDL beginner

VHDL (VHSIC-HDL, Very High-Speed Integrated Circuit Hardware Description Language) is a hardware description language used in electronic des...

Sunday, 9 September 2012

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

· The disable statement cannot be used to disable functions.

· If a task or a named block contains other tasks or named blocks then disabling that task or a named block terminates all tasks and blocks within.

· The disable statement can appear only within the procedural blocks.

No comments:

Post a Comment

Please provide valuable comments and suggestions for our motivation. Feel free to write down any query if you have regarding this post.