• There are two types of blocks
– Simple
– Guarded
Simple block
• The BLOCK statement, in its simple form, represents only a way of locally partitioning the code.
• It allows a set of concurrent statements to be clustered into a BLOCK, with the purpose of turning the overall code more readable and more manageable (which might be helpful when dealing with long codes).
• Block can be nested inside another block
Guarded block
• A guarded BLOCK is a special kind of BLOCK, which includes an additional expression, called guard expression.
• A guarded statement in a guarded BLOCK is executed only when the guard expression is TRUE.
Syntax
label: BLOCK (
guard expression)
[declarative part]
BEGIN
(concurrent guarded and unguarded statements)
END BLOCK label;
• Even though only concurrent statements can be written within a BLOCK, with a guarded BLOCK even sequential circuits can be constructed.
Latch
LIBRARY ieee;
USE ieee.std_logic_1164.all;
ENTITY latch IS
PORT (d, clk: IN STD_LOGIC;
q: OUT STD_LOGIC);
END latch;
ARCHITECTURE latch OF latch IS
BEGIN
b1: BLOCK (clk='1')
BEGIN
q <= GUARDED d;
END BLOCK b1;
END latch;
DFF
LIBRARY ieee;
USE ieee.std_logic_1164.all;
ENTITY DFF IS
PORT (d, clk, rst: IN STD_LOGIC;
q: OUT STD_LOGIC);
END DFF;
ARCHITECTURE DFF OF DFF IS
BEGIN
b1: BLOCK (clk’EVENT AND clk='1')
BEGIN
q <= GUARDED ‘0’ WHEN rst=‘1’ ELSE d;
END BLOCK b1;
END DFF;
information shared by www.irvs.info
No comments:
Post a Comment