![]() |
![]() |
A block statement (which is concurrent) contains a set of concurrent statements. The order of the concurrent statements does not matter, because all statements are always executing.
Note: Foundation Express does not create a new level of design hierarchy from a block statement.
The syntax of a block statement follows.
label: block[ (expression) ]
{ block_declarative_item }
begin
{ concurrent_statement }
end block [ label ];
Objects declared in a block are visible to that block and to all blocks nested within. When a child block (inside a parent block) declares an object with the same name as an object in the parent block, the child block's declaration overrides that of the parent.
The description in the following example uses nested blocks. The resulting circuit schematic is shown in the figure following the example.
B1: block
signal S: BIT; -- Declaration of "S" in block B1
begin
S <= A and B; -- "S" from B1
B2: block
signal S: BIT; -- Declaration of "S" in block B2
begin
S <= C and D; -- "S" from B2
B3: block
begin
Z <= S; -- "S" from B2
end block B3;
end block B2;
Y <= S; -- "S" from B1
end block B1;
The description in the following example uses guarded blocks. In the example, z has the same value as a.
entity EG1 is
port (a: in BIT; z: out BIT);
end;
architecture RTL of EG1 is
begin
guarded_block: block (a = '1')
begin
z <= '1' when guard else '0';
end block;
end RTL;
A concurrent assignment within a block statement can use the guarded keyword. In such a case, the guard expression conditions the signal assignment. The description in the following example produces a level-sensitive latch.
entity EG2 is
port (d, g: in BIT; q: out BIT);
end;
architecture RTL of EG2 is
begin
guarded_block: block (g = '1')
begin
q <= guarded d;
end block;
end RTL;
Note: Do not use the 'event or 'stable attributes with the guard expression if you want to produce an edge-triggered latch using a guarded block. The presence of either attribute prevents it.