1 |
2 |
sckoarn |
-------------------------------------------------------------------------------
|
2 |
19 |
sckoarn |
-- Copyright 2011 Ken Campbell
|
3 |
2 |
sckoarn |
-------------------------------------------------------------------------------
|
4 |
|
|
-- $Author: sckoarn $
|
5 |
|
|
--
|
6 |
19 |
sckoarn |
-- $Date: $
|
7 |
2 |
sckoarn |
--
|
8 |
19 |
sckoarn |
-- $Id: $
|
9 |
2 |
sckoarn |
--
|
10 |
19 |
sckoarn |
-- $Source: $
|
11 |
2 |
sckoarn |
--
|
12 |
|
|
-- Description : The the testbench package template behave file.
|
13 |
19 |
sckoarn |
-- GNU release 2 Beta.
|
14 |
2 |
sckoarn |
--
|
15 |
|
|
------------------------------------------------------------------------------
|
16 |
|
|
--This file is part of The VHDL Test Bench.
|
17 |
|
|
--
|
18 |
|
|
-- The VHDL Test Bench is free software; you can redistribute it and/or modify
|
19 |
|
|
-- it under the terms of the GNU General Public License as published by
|
20 |
|
|
-- the Free Software Foundation; either version 2 of the License, or
|
21 |
|
|
-- (at your option) any later version.
|
22 |
|
|
--
|
23 |
10 |
sckoarn |
-- The VHDL Test Bench is distributed in the hope that it will be useful,
|
24 |
2 |
sckoarn |
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
25 |
|
|
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
26 |
|
|
-- GNU General Public License for more details.
|
27 |
|
|
--
|
28 |
|
|
-- You should have received a copy of the GNU General Public License
|
29 |
|
|
-- along with The VHDL Test Bench; if not, write to the Free Software
|
30 |
|
|
-- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
31 |
|
|
-------------------------------------------------------------------------------
|
32 |
|
|
|
33 |
|
|
architecture bhv of tb_Top is
|
34 |
|
|
|
35 |
|
|
|
36 |
|
|
signal tb_clk : std_logic;
|
37 |
|
|
|
38 |
|
|
-------------------------------------------------------------------------
|
39 |
|
|
-- Component defintion
|
40 |
|
|
|
41 |
|
|
-------------------------------------------------------------------------------
|
42 |
|
|
-- USER Component instantiations
|
43 |
|
|
--for all: Arbitor use entity tb_objects.arbitor(bhv);
|
44 |
|
|
|
45 |
|
|
|
46 |
|
|
begin
|
47 |
|
|
|
48 |
|
|
-------------------------------------------------------------------------------
|
49 |
|
|
-- clock driver process
|
50 |
|
|
-- the main clock generator
|
51 |
|
|
clock_driver:
|
52 |
|
|
process
|
53 |
|
|
begin
|
54 |
|
|
tb_clk <= '0';
|
55 |
|
|
wait for 5 ns;
|
56 |
|
|
tb_clk <= '1';
|
57 |
|
|
wait for 5 ns;
|
58 |
|
|
end process clock_driver;
|
59 |
|
|
|
60 |
|
|
--------------------------------------------------------------------------
|
61 |
|
|
-- Read_file Process:
|
62 |
|
|
--
|
63 |
|
|
-- This process is the main process of the testbench. This process reads
|
64 |
|
|
-- the stumulus file, parses it, creates lists of records, then uses these
|
65 |
|
|
-- lists to exicute user instructions. There are two passes through the
|
66 |
|
|
-- script. Pass one reads in the stimulus text file, checks it, creates
|
67 |
|
|
-- lists of valid instructions, valid list of variables and finialy a list
|
68 |
|
|
-- of user instructions(the sequence). The second pass through the file,
|
69 |
|
|
-- records are drawn from the user instruction list, variables are converted
|
70 |
|
|
-- to integers and put through the elsif structure for exicution.
|
71 |
|
|
--------------------------------------------------------------------------
|
72 |
|
|
Read_file: process
|
73 |
|
|
variable current_line : text_line; -- The current input line
|
74 |
|
|
variable inst_list : inst_def_ptr; -- the instruction list
|
75 |
|
|
variable defined_vars : var_field_ptr; -- defined variables
|
76 |
|
|
variable inst_sequ : stim_line_ptr; -- the instruction sequence
|
77 |
10 |
sckoarn |
variable file_list : file_def_ptr; -- pointer to the list of file names
|
78 |
13 |
sckoarn |
variable last_sequ_num: integer;
|
79 |
|
|
variable last_sequ_ptr: stim_line_ptr;
|
80 |
2 |
sckoarn |
|
81 |
|
|
variable instruction : text_field; -- instruction field
|
82 |
|
|
variable par1 : integer; -- paramiter 1
|
83 |
|
|
variable par2 : integer; -- paramiter 2
|
84 |
|
|
variable par3 : integer; -- paramiter 3
|
85 |
|
|
variable par4 : integer; -- paramiter 4
|
86 |
|
|
variable par5 : integer; -- paramiter 5
|
87 |
|
|
variable par6 : integer; -- paramiter 6
|
88 |
|
|
variable txt : stm_text_ptr;
|
89 |
|
|
variable nbase : base; -- the number base to use
|
90 |
|
|
variable len : integer; -- length of the instruction field
|
91 |
|
|
variable file_line : integer; -- Line number in the stimulus file
|
92 |
|
|
variable file_name : text_line; -- the file name the line came from
|
93 |
|
|
variable v_line : integer := 0; -- sequence number
|
94 |
|
|
variable stack : stack_register; -- Call stack
|
95 |
|
|
variable stack_ptr : integer := 0; -- call stack pointer
|
96 |
|
|
variable wh_stack : stack_register; -- while stack
|
97 |
|
|
variable wh_dpth : integer := 0; -- while depth
|
98 |
|
|
variable wh_ptr : integer := 0; -- while pointer
|
99 |
|
|
variable loop_num : integer := 0;
|
100 |
|
|
variable curr_loop_count : int_array := (others => 0);
|
101 |
|
|
variable term_loop_count : int_array := (others => 0);
|
102 |
|
|
variable loop_line : int_array := (others => 0);
|
103 |
|
|
|
104 |
|
|
variable messages : boolean := TRUE;
|
105 |
|
|
variable if_state : boolean := FALSE;
|
106 |
|
|
variable wh_state : boolean := FALSE;
|
107 |
|
|
variable wh_end : boolean := FALSE;
|
108 |
|
|
variable rand : std_logic_vector(31 downto 0);
|
109 |
|
|
variable rand_back : std_logic_vector(31 downto 0);
|
110 |
10 |
sckoarn |
variable valid : integer;
|
111 |
2 |
sckoarn |
|
112 |
10 |
sckoarn |
-- scratchpad variables
|
113 |
2 |
sckoarn |
variable temp_int : integer;
|
114 |
|
|
variable temp_index : integer;
|
115 |
|
|
variable temp_str : text_field;
|
116 |
|
|
variable v_temp_vec1 : std_logic_vector(31 downto 0);
|
117 |
|
|
variable v_temp_vec2 : std_logic_vector(31 downto 0);
|
118 |
|
|
|
119 |
|
|
--------------------------------------------------------------------------
|
120 |
|
|
-- Area for Procedures which may be usefull to more than one instruction.
|
121 |
|
|
-- By coding here commonly used code sections ...
|
122 |
|
|
-- you know the benifits.
|
123 |
|
|
---------------------------------------------------------------------
|
124 |
|
|
-----------------------------------------------------------------
|
125 |
|
|
-- This procedure writes to the arbitor model access port
|
126 |
|
|
-- procedure arb_write(add: in integer; .....
|
127 |
|
|
-- end arb_write;
|
128 |
|
|
|
129 |
|
|
|
130 |
|
|
begin -- process Read_file
|
131 |
|
|
-- parse_tb1 start input initialization
|
132 |
|
|
-----------------------------------------------------------------------
|
133 |
|
|
-- Stimulus file instruction definition
|
134 |
|
|
-- This is where the instructions used in the stimulus file are defined.
|
135 |
|
|
-- Syntax is
|
136 |
|
|
-- define_instruction(inst_def_ptr, instruction, paramiters)
|
137 |
|
|
-- inst_def_ptr: is a record pointer defined in tb_pkg_header
|
138 |
19 |
sckoarn |
-- instruction: the text instruction name ie. "ADD_VAR"
|
139 |
2 |
sckoarn |
-- paramiters: the number of fields or paramiters passed
|
140 |
|
|
--
|
141 |
|
|
-- Some basic instruction are created here, the user should create new
|
142 |
|
|
-- instructions below the standard ones.
|
143 |
|
|
------------------------------------------------------------------------
|
144 |
|
|
define_instruction(inst_list, "DEFINE_VAR", 2); -- Define a Variable
|
145 |
|
|
define_instruction(inst_list, "EQU_VAR", 2);
|
146 |
|
|
define_instruction(inst_list, "ADD_VAR", 2);
|
147 |
|
|
define_instruction(inst_list, "SUB_VAR", 2);
|
148 |
|
|
define_instruction(inst_list, "CALL", 1);
|
149 |
|
|
define_instruction(inst_list, "RETURN_CALL", 0);
|
150 |
|
|
define_instruction(inst_list, "JUMP", 1);
|
151 |
|
|
define_instruction(inst_list, "LOOP", 1);
|
152 |
|
|
define_instruction(inst_list, "END_LOOP", 0);
|
153 |
|
|
define_instruction(inst_list, "IF", 3);
|
154 |
10 |
sckoarn |
define_instruction(inst_list, "ELSEIF", 3);
|
155 |
2 |
sckoarn |
define_instruction(inst_list, "ELSE", 0);
|
156 |
|
|
define_instruction(inst_list, "END_IF", 0);
|
157 |
|
|
define_instruction(inst_list, "WHILE", 3);
|
158 |
|
|
define_instruction(inst_list, "END_WHILE", 0);
|
159 |
|
|
define_instruction(inst_list, "MESSAGES_OFF", 0);
|
160 |
|
|
define_instruction(inst_list, "MESSAGES_ON", 0);
|
161 |
|
|
define_instruction(inst_list, "ABORT", 0); -- Error exit from sim
|
162 |
|
|
define_instruction(inst_list, "FINISH", 0); -- Normal exit from sim
|
163 |
19 |
sckoarn |
define_instruction(inst_list, "INCLUDE", 1); -- Include a script file
|
164 |
|
|
-- Start User defined instructions
|
165 |
2 |
sckoarn |
|
166 |
19 |
sckoarn |
-- End User defined instructions
|
167 |
2 |
sckoarn |
------------------------------------------------------------------------
|
168 |
|
|
-- Read, test, and load the stimulus file
|
169 |
10 |
sckoarn |
read_instruction_file(stimulus_file, inst_list, defined_vars, inst_sequ,
|
170 |
|
|
file_list);
|
171 |
2 |
sckoarn |
|
172 |
13 |
sckoarn |
-- initialize last info
|
173 |
|
|
last_sequ_num := 0;
|
174 |
|
|
last_sequ_ptr := inst_sequ;
|
175 |
2 |
sckoarn |
------------------------------------------------------------------------
|
176 |
|
|
-- Using the Instruction record list, get the instruction and implement
|
177 |
|
|
-- it as per the statements in the elsif tree.
|
178 |
|
|
while(v_line < inst_sequ.num_of_lines) loop
|
179 |
|
|
v_line := v_line + 1;
|
180 |
10 |
sckoarn |
access_inst_sequ(inst_sequ, defined_vars, file_list, v_line, instruction,
|
181 |
13 |
sckoarn |
par1, par2, par3, par4, par5, par6, txt, len, file_name, file_line,
|
182 |
|
|
last_sequ_num, last_sequ_ptr);
|
183 |
2 |
sckoarn |
|
184 |
|
|
--------------------------------------------------------------------------
|
185 |
10 |
sckoarn |
--if(instruction(1 to len) = "DEFINE_VAR") then
|
186 |
|
|
-- null; -- This instruction was implemented while reading the file
|
187 |
2 |
sckoarn |
|
188 |
|
|
--------------------------------------------------------------------------
|
189 |
10 |
sckoarn |
if(instruction(1 to len) = "INCLUDE") then
|
190 |
2 |
sckoarn |
null; -- This instruction was implemented while reading the file
|
191 |
|
|
|
192 |
|
|
--------------------------------------------------------------------------
|
193 |
|
|
elsif(instruction(1 to len) = "ABORT") then
|
194 |
|
|
assert (false)
|
195 |
|
|
report "The test has aborted due to an error!!"
|
196 |
|
|
severity failure;
|
197 |
|
|
|
198 |
|
|
--------------------------------------------------------------------------
|
199 |
|
|
elsif(instruction(1 to len) = "FINISH") then
|
200 |
|
|
assert (false)
|
201 |
|
|
report "Test Finished with NO errors!!"
|
202 |
|
|
severity failure;
|
203 |
|
|
|
204 |
|
|
--------------------------------------------------------------------------
|
205 |
|
|
elsif(instruction(1 to len) = "EQU_VAR") then
|
206 |
|
|
update_variable(defined_vars, par1, par2, valid);
|
207 |
|
|
|
208 |
|
|
--------------------------------------------------------------------------
|
209 |
|
|
elsif(instruction(1 to len) = "ADD_VAR") then
|
210 |
|
|
index_variable(defined_vars, par1, temp_int, valid);
|
211 |
|
|
if(valid /= 0) then
|
212 |
|
|
temp_int := temp_int + par2;
|
213 |
|
|
update_variable(defined_vars, par1, temp_int, valid);
|
214 |
|
|
else
|
215 |
|
|
assert (false)
|
216 |
|
|
report "ADD_VAR Error: Not a valid Variable??"
|
217 |
|
|
severity failure;
|
218 |
|
|
end if;
|
219 |
|
|
|
220 |
|
|
--------------------------------------------------------------------------
|
221 |
|
|
elsif(instruction(1 to len) = "SUB_VAR") then
|
222 |
|
|
index_variable(defined_vars, par1, temp_int, valid);
|
223 |
|
|
if(valid /= 0) then
|
224 |
|
|
temp_int := temp_int - par2;
|
225 |
|
|
update_variable(defined_vars, par1, temp_int, valid);
|
226 |
|
|
else
|
227 |
|
|
assert (false)
|
228 |
|
|
report "SUB_VAR Error: Not a valid Variable??"
|
229 |
|
|
severity failure;
|
230 |
|
|
end if;
|
231 |
|
|
|
232 |
|
|
--------------------------------------------------------------------------
|
233 |
|
|
elsif(instruction(1 to len) = "CALL") then
|
234 |
|
|
if(stack_ptr >= 7) then
|
235 |
|
|
assert (false)
|
236 |
|
|
report "Call Error: Stack over run, calls to deeply nested!!"
|
237 |
|
|
severity failure;
|
238 |
|
|
end if;
|
239 |
|
|
stack(stack_ptr) := v_line;
|
240 |
|
|
stack_ptr := stack_ptr + 1;
|
241 |
|
|
v_line := par1 - 1;
|
242 |
|
|
|
243 |
|
|
--------------------------------------------------------------------------
|
244 |
|
|
elsif(instruction(1 to len) = "RETURN_CALL") then
|
245 |
|
|
if(stack_ptr <= 0) then
|
246 |
|
|
assert (false)
|
247 |
|
|
report "Call Error: Stack under run??"
|
248 |
|
|
severity failure;
|
249 |
|
|
end if;
|
250 |
|
|
stack_ptr := stack_ptr - 1;
|
251 |
|
|
v_line := stack(stack_ptr);
|
252 |
|
|
|
253 |
|
|
--------------------------------------------------------------------------
|
254 |
|
|
elsif(instruction(1 to len) = "JUMP") then
|
255 |
|
|
v_line := par1 - 1;
|
256 |
|
|
wh_state := false;
|
257 |
|
|
wh_stack := (others => 0);
|
258 |
|
|
wh_dpth := 0;
|
259 |
|
|
wh_ptr := 0;
|
260 |
|
|
stack := (others => 0);
|
261 |
|
|
stack_ptr := 0;
|
262 |
|
|
|
263 |
|
|
--------------------------------------------------------------------------------
|
264 |
|
|
elsif (instruction(1 to len) = "LOOP") then
|
265 |
13 |
sckoarn |
loop_num := loop_num + 1;
|
266 |
2 |
sckoarn |
loop_line(loop_num) := v_line;
|
267 |
|
|
curr_loop_count(loop_num) := 0;
|
268 |
|
|
term_loop_count(loop_num) := par1;
|
269 |
13 |
sckoarn |
assert (messages)
|
270 |
2 |
sckoarn |
report LF & "Executing LOOP Command" &
|
271 |
|
|
LF & " Nested Loop:" & HT & integer'image(loop_num) &
|
272 |
|
|
LF & " Loop Length:" & HT & integer'image(par1)
|
273 |
|
|
severity note;
|
274 |
|
|
|
275 |
|
|
--------------------------------------------------------------------------------
|
276 |
|
|
elsif (instruction(1 to len) = "END_LOOP") then
|
277 |
|
|
curr_loop_count(loop_num) := curr_loop_count(loop_num) + 1;
|
278 |
|
|
if (curr_loop_count(loop_num) = term_loop_count(loop_num)) then
|
279 |
|
|
loop_num := loop_num - 1;
|
280 |
|
|
else
|
281 |
|
|
v_line := loop_line(loop_num);
|
282 |
|
|
end if;
|
283 |
|
|
|
284 |
|
|
--------------------------------------------------------------------------------
|
285 |
|
|
elsif (instruction(1 to len) = "IF") then
|
286 |
|
|
if_state := false;
|
287 |
|
|
case par2 is
|
288 |
|
|
when 0 => if(par1 = par3) then if_state := true; end if;
|
289 |
|
|
when 1 => if(par1 > par3) then if_state := true; end if;
|
290 |
|
|
when 2 => if(par1 < par3) then if_state := true; end if;
|
291 |
|
|
when 3 => if(par1 /= par3) then if_state := true; end if;
|
292 |
|
|
when 4 => if(par1 >= par3) then if_state := true; end if;
|
293 |
|
|
when 5 => if(par1 <= par3) then if_state := true; end if;
|
294 |
|
|
when others =>
|
295 |
|
|
assert (false)
|
296 |
|
|
report LF & "ERROR: IF instruction got an unexpected value" &
|
297 |
|
|
LF & " in parameter 2!" & LF &
|
298 |
|
|
"Found on line " & (ew_to_str(file_line,dec)) & " in file " & file_name
|
299 |
|
|
severity failure;
|
300 |
|
|
end case;
|
301 |
|
|
|
302 |
|
|
if(if_state = false) then
|
303 |
|
|
v_line := v_line + 1;
|
304 |
10 |
sckoarn |
access_inst_sequ(inst_sequ, defined_vars, file_list, v_line, instruction,
|
305 |
13 |
sckoarn |
par1, par2, par3, par4, par5, par6, txt, len, file_name, file_line,
|
306 |
|
|
last_sequ_num, last_sequ_ptr);
|
307 |
2 |
sckoarn |
while(instruction(1 to len) /= "ELSE" and
|
308 |
|
|
instruction(1 to len) /= "ELSEIF" and
|
309 |
|
|
instruction(1 to len) /= "END_IF") loop
|
310 |
|
|
if(v_line < inst_sequ.num_of_lines) then
|
311 |
|
|
v_line := v_line + 1;
|
312 |
10 |
sckoarn |
access_inst_sequ(inst_sequ, defined_vars, file_list, v_line, instruction,
|
313 |
13 |
sckoarn |
par1, par2, par3, par4, par5, par6, txt, len, file_name, file_line,
|
314 |
|
|
last_sequ_num, last_sequ_ptr);
|
315 |
2 |
sckoarn |
else
|
316 |
|
|
assert (false)
|
317 |
|
|
report LF & "ERROR: IF instruction unable to find terminating" &
|
318 |
|
|
LF & " ELSE, ELSEIF or END_IF statement."
|
319 |
|
|
severity failure;
|
320 |
|
|
end if;
|
321 |
|
|
end loop;
|
322 |
|
|
v_line := v_line - 1; -- re-align so it will be operated on.
|
323 |
|
|
end if;
|
324 |
|
|
|
325 |
|
|
--------------------------------------------------------------------------------
|
326 |
|
|
elsif (instruction(1 to len) = "ELSEIF") then
|
327 |
|
|
if(if_state = true) then -- if the if_state is true then skip to the end
|
328 |
|
|
v_line := v_line + 1;
|
329 |
10 |
sckoarn |
access_inst_sequ(inst_sequ, defined_vars, file_list, v_line, instruction,
|
330 |
13 |
sckoarn |
par1, par2, par3, par4, par5, par6, txt, len, file_name, file_line,
|
331 |
|
|
last_sequ_num, last_sequ_ptr);
|
332 |
2 |
sckoarn |
while(instruction(1 to len) /= "END_IF") loop
|
333 |
|
|
if(v_line < inst_sequ.num_of_lines) then
|
334 |
|
|
v_line := v_line + 1;
|
335 |
10 |
sckoarn |
access_inst_sequ(inst_sequ, defined_vars, file_list, v_line, instruction,
|
336 |
13 |
sckoarn |
par1, par2, par3, par4, par5, par6, txt, len, file_name, file_line,
|
337 |
|
|
last_sequ_num, last_sequ_ptr);
|
338 |
2 |
sckoarn |
else
|
339 |
|
|
assert (false)
|
340 |
|
|
report LF & "ERROR: IF instruction unable to find terminating" &
|
341 |
|
|
LF & " ELSE, ELSEIF or END_IF statement."
|
342 |
|
|
severity failure;
|
343 |
|
|
end if;
|
344 |
|
|
end loop;
|
345 |
|
|
v_line := v_line - 1; -- re-align so it will be operated on.
|
346 |
|
|
|
347 |
|
|
else
|
348 |
|
|
case par2 is
|
349 |
|
|
when 0 => if(par1 = par3) then if_state := true; end if;
|
350 |
|
|
when 1 => if(par1 > par3) then if_state := true; end if;
|
351 |
|
|
when 2 => if(par1 < par3) then if_state := true; end if;
|
352 |
|
|
when 3 => if(par1 /= par3) then if_state := true; end if;
|
353 |
|
|
when 4 => if(par1 >= par3) then if_state := true; end if;
|
354 |
|
|
when 5 => if(par1 <= par3) then if_state := true; end if;
|
355 |
|
|
when others =>
|
356 |
|
|
assert (false)
|
357 |
|
|
report LF & "ERROR: ELSEIF instruction got an unexpected value" &
|
358 |
|
|
LF & " in parameter 2!" & LF &
|
359 |
|
|
"Found on line " & (ew_to_str(file_line,dec)) & " in file " & file_name
|
360 |
|
|
severity failure;
|
361 |
|
|
end case;
|
362 |
|
|
|
363 |
|
|
if(if_state = false) then
|
364 |
|
|
v_line := v_line + 1;
|
365 |
10 |
sckoarn |
access_inst_sequ(inst_sequ, defined_vars, file_list, v_line, instruction,
|
366 |
13 |
sckoarn |
par1, par2, par3, par4, par5, par6, txt, len, file_name, file_line,
|
367 |
|
|
last_sequ_num, last_sequ_ptr);
|
368 |
2 |
sckoarn |
while(instruction(1 to len) /= "ELSE" and
|
369 |
|
|
instruction(1 to len) /= "ELSEIF" and
|
370 |
|
|
instruction(1 to len) /= "END_IF") loop
|
371 |
|
|
if(v_line < inst_sequ.num_of_lines) then
|
372 |
|
|
v_line := v_line + 1;
|
373 |
10 |
sckoarn |
access_inst_sequ(inst_sequ, defined_vars, file_list, v_line, instruction,
|
374 |
13 |
sckoarn |
par1, par2, par3, par4, par5, par6, txt, len, file_name, file_line,
|
375 |
|
|
last_sequ_num, last_sequ_ptr);
|
376 |
2 |
sckoarn |
else
|
377 |
|
|
assert (false)
|
378 |
|
|
report LF & "ERROR: ELSEIF instruction unable to find terminating" &
|
379 |
|
|
LF & " ELSE, ELSEIF or END_IF statement."
|
380 |
|
|
severity failure;
|
381 |
|
|
end if;
|
382 |
|
|
end loop;
|
383 |
|
|
v_line := v_line - 1; -- re-align so it will be operated on.
|
384 |
|
|
end if;
|
385 |
|
|
end if;
|
386 |
|
|
|
387 |
|
|
--------------------------------------------------------------------------------
|
388 |
|
|
elsif (instruction(1 to len) = "ELSE") then
|
389 |
|
|
if(if_state = true) then -- if the if_state is true then skip the else
|
390 |
|
|
v_line := v_line + 1;
|
391 |
10 |
sckoarn |
access_inst_sequ(inst_sequ, defined_vars, file_list, v_line, instruction,
|
392 |
13 |
sckoarn |
par1, par2, par3, par4, par5, par6, txt, len, file_name, file_line,
|
393 |
|
|
last_sequ_num, last_sequ_ptr);
|
394 |
2 |
sckoarn |
while(instruction(1 to len) /= "END_IF") loop
|
395 |
|
|
if(v_line < inst_sequ.num_of_lines) then
|
396 |
|
|
v_line := v_line + 1;
|
397 |
10 |
sckoarn |
access_inst_sequ(inst_sequ, defined_vars, file_list, v_line, instruction,
|
398 |
13 |
sckoarn |
par1, par2, par3, par4, par5, par6, txt, len, file_name, file_line,
|
399 |
|
|
last_sequ_num, last_sequ_ptr);
|
400 |
2 |
sckoarn |
else
|
401 |
|
|
assert (false)
|
402 |
|
|
report LF & "ERROR: IF instruction unable to find terminating" &
|
403 |
|
|
LF & " ELSE, ELSEIF or END_IF statement."
|
404 |
|
|
severity failure;
|
405 |
|
|
end if;
|
406 |
|
|
end loop;
|
407 |
|
|
v_line := v_line - 1; -- re-align so it will be operated on.
|
408 |
|
|
end if;
|
409 |
|
|
|
410 |
|
|
--------------------------------------------------------------------------------
|
411 |
|
|
elsif (instruction(1 to len) = "END_IF") then
|
412 |
|
|
null; -- instruction is a place holder for finding the end of IF.
|
413 |
|
|
|
414 |
|
|
--------------------------------------------------------------------------------
|
415 |
|
|
elsif (instruction(1 to len) = "WHILE") then
|
416 |
|
|
wh_state := false;
|
417 |
|
|
case par2 is
|
418 |
11 |
sckoarn |
when 0 => if(par1 = par3) then wh_state := true; end if;
|
419 |
|
|
when 1 => if(par1 > par3) then wh_state := true; end if;
|
420 |
|
|
when 2 => if(par1 < par3) then wh_state := true; end if;
|
421 |
|
|
when 3 => if(par1 /= par3) then wh_state := true; end if;
|
422 |
|
|
when 4 => if(par1 >= par3) then wh_state := true; end if;
|
423 |
|
|
when 5 => if(par1 <= par3) then wh_state := true; end if;
|
424 |
2 |
sckoarn |
when others =>
|
425 |
|
|
assert (false)
|
426 |
|
|
report LF & "ERROR: WHILE instruction got an unexpected value" &
|
427 |
|
|
LF & " in parameter 2!" & LF &
|
428 |
|
|
"Found on line " & (ew_to_str(file_line,dec)) & " in file " & file_name
|
429 |
|
|
severity failure;
|
430 |
|
|
end case;
|
431 |
|
|
|
432 |
|
|
if(wh_state = true) then
|
433 |
|
|
wh_stack(wh_ptr) := v_line;
|
434 |
|
|
wh_ptr := wh_ptr + 1;
|
435 |
|
|
else
|
436 |
|
|
wh_end := false;
|
437 |
|
|
while(wh_end /= true) loop
|
438 |
|
|
if(v_line < inst_sequ.num_of_lines) then
|
439 |
|
|
v_line := v_line + 1;
|
440 |
10 |
sckoarn |
access_inst_sequ(inst_sequ, defined_vars, file_list, v_line, instruction,
|
441 |
13 |
sckoarn |
par1, par2, par3, par4, par5, par6, txt, len, file_name, file_line,
|
442 |
|
|
last_sequ_num, last_sequ_ptr);
|
443 |
2 |
sckoarn |
else
|
444 |
|
|
assert (false)
|
445 |
|
|
report LF & "ERROR: WHILE instruction unable to find terminating" &
|
446 |
|
|
LF & " END_WHILE statement."
|
447 |
|
|
severity failure;
|
448 |
|
|
end if;
|
449 |
|
|
|
450 |
|
|
-- if is a while need to escape it
|
451 |
|
|
if(instruction(1 to len) = "WHILE") then
|
452 |
|
|
wh_dpth := wh_dpth + 1;
|
453 |
|
|
-- if is the end_while we are looking for
|
454 |
|
|
elsif(instruction(1 to len) = "END_WHILE") then
|
455 |
|
|
if(wh_dpth = 0) then
|
456 |
|
|
wh_end := true;
|
457 |
|
|
else
|
458 |
|
|
wh_dpth := wh_dpth - 1;
|
459 |
|
|
end if;
|
460 |
|
|
end if;
|
461 |
|
|
end loop;
|
462 |
|
|
end if;
|
463 |
|
|
|
464 |
|
|
--------------------------------------------------------------------------------
|
465 |
|
|
elsif (instruction(1 to len) = "END_WHILE") then
|
466 |
|
|
if(wh_ptr > 0) then
|
467 |
|
|
v_line := wh_stack(wh_ptr - 1) - 1;
|
468 |
|
|
wh_ptr := wh_ptr - 1;
|
469 |
|
|
end if;
|
470 |
|
|
|
471 |
|
|
--------------------------------------------------------------------------------
|
472 |
|
|
elsif (instruction(1 to len) = "MESSAGES_OFF") then
|
473 |
|
|
messages := TRUE;
|
474 |
|
|
--------------------------------------------------------------------------------
|
475 |
|
|
elsif (instruction(1 to len) = "MESSAGES_ON") then
|
476 |
|
|
messages := FALSE;
|
477 |
|
|
|
478 |
|
|
|
479 |
|
|
--------------------------------------------------------------------------------
|
480 |
|
|
--------------------------------------------------------------------------------
|
481 |
|
|
-- USER Istruction area. Add all user instructions below this
|
482 |
|
|
--------------------------------------------------------------------------------
|
483 |
|
|
--------------------------------------------------------------------------------
|
484 |
|
|
-- elsif (instruction(1 to len) = "RESET_SYS") then
|
485 |
|
|
|
486 |
|
|
|
487 |
|
|
--------------------------------------------------------------------------------
|
488 |
|
|
-- USER Istruction area. Add all user instructions above this
|
489 |
|
|
--------------------------------------------------------------------------------
|
490 |
|
|
--------------------------------------------------------------------------
|
491 |
|
|
-- catch those little mistakes
|
492 |
|
|
else
|
493 |
10 |
sckoarn |
assert (false)
|
494 |
|
|
report LF & "ERROR: Seems the command " & instruction(1 to len) & " was defined but" & LF &
|
495 |
|
|
"was not found in the elsif chain, please check spelling."
|
496 |
2 |
sckoarn |
severity failure;
|
497 |
|
|
end if; -- else if structure end
|
498 |
10 |
sckoarn |
-- after the instruction is finished print out any txt and sub vars
|
499 |
|
|
txt_print_wvar(defined_vars, txt, hex);
|
500 |
2 |
sckoarn |
end loop; -- Main Loop end
|
501 |
|
|
|
502 |
|
|
assert (false)
|
503 |
|
|
report LF & "The end of the simulation! It was not terminated as expected." & LF
|
504 |
|
|
severity failure;
|
505 |
|
|
|
506 |
|
|
end process Read_file;
|
507 |
|
|
|
508 |
|
|
|
509 |
|
|
end bhv;
|
510 |
19 |
sckoarn |
-------------------------------------------------------------------------------
|
511 |
|
|
-- Revision History:
|
512 |
|
|
-- version 1.4
|
513 |
|
|
-- $Log: not supported by cvs2svn $
|
514 |
|
|
-- Revision 1.3 2007/11/14 02:35:56 sckoarn
|
515 |
|
|
-- Fix to WHILE instruction: Change if_state typo to wh_state
|
516 |
|
|
--
|
517 |
|
|
-- Revision 1.2 2007/09/02 04:04:04 sckoarn
|
518 |
|
|
-- Update of version 1.2 tb_pkg
|
519 |
|
|
-- See documentation for details
|
520 |
|
|
--
|
521 |
|
|
-- Revision 1.1.1.1 2007/04/06 04:06:48 sckoarn
|
522 |
|
|
-- Import of the vhld_tb
|
523 |
|
|
--
|
524 |
|
|
--
|
525 |
|
|
-------------------------------------------------------------------------------
|