VHDL Programming

(C. Jardin) #1

98 Chapter Four


Fifo Element

fifo_ptr

temp_ptr

Figure 4-3
Multiple Access Type
References.


Incomplete Types


When implementing recursive structures such as linked lists, you need
another VHDL language feature to complete the declarations. This feature
is called the incomplete type. The incomplete type allows the declaration
of a type to be defined later.
Following is an example that demonstrates why this would be useful:

PACKAGE stack_types IS
TYPE data_type IS ARRAY(0 TO 7) OF std_logic; --line 1

TYPE element_rec; --incomplete type line 2

TYPE element_ptr IS ACCESS element_rec; --line 3
TYPE element_rec IS --line 4
RECORD --line 5
data : data_type; --line 6
nxt : element_ptr; --line 7
END RECORD; --line 8

END stack_types;

USE WORK.stack_types.ALL;
ENTITY stack IS
PORT(din : IN data_type;
clk : IN std_logic;
dout : OUT data_type;
r_wb : IN std_logic);
END stack;

ARCHITECTURE stack OF stack IS
BEGIN
PROCESS(clk)

VARIABLE list_head : element_ptr := NULL; --line 9
VARIABLE temp_elem : element_ptr := NULL; --line 10
VARIABLE last_clk : std_logic := U; --line 11
BEGIN
IF (clk = ‘ 1 ’) AND (last_clk = ‘ 0 ’) THEN --line 12
IF (r_wb = ‘ 0 ’) THEN --line 13
temp_elem := NEW element_rec; --line 14
temp_elem.data := din; --line 15
Free download pdf