Advanced Testing With VHDL
Advanced Testing With VHDL
Advanced Testing With VHDL
Module 9
Overview
SRAM Model Attributes Loop Statements Test Bench examples using
TEXTIO Conversion functions Reading file containing test vectors Writing test results to file
Picoblaze
55
VHDL Attributes
Signals can have attributes associated with them Example predefined signal attributes are
function value type range
Function Attributes
Predefined functions Returns information about the behavior of signals
sEVENT
returns true if an event occurred change in value
sACTIVE
returns true if signal s is active new value assigned to signal s (may be same value)
sLAST_EVENT
returns elapsed time since last event
sLAST_ACTIVE sLAST_VALUE
returns value of s before the last event
Assert statement checks that the input d has not had an event during the setup time. If time returned is less than setup time - assertion will fail
Jim Duckworth, WPI 10 Advanced Testing using VHDL
now function
NOW
predefined function that returns simulation time
IF dEVENT THEN lasteventonD := NOW; IF clkEVENT AND clk = 1 THEN ASSERT(now lasteventonD) >= setup_time REPORT setup violation SEVERITY error
11
RANGE attributes
Only for constrained array types Returns range of specified type Two range attributes
aRANGE aREVERSE RANGE
TYPE address_bus IS ARRAY (63 DOWNT0 0) OF std_logic; SIGNAL cpu_address : address_bus; -- declare array -- 63 DOWNTO 0 -- 0 TO 63
12
aRIGHT
returns right bound of type
aHIGH
returns upper bound of type
aLOW
returns lower bound of type
Also
aLENGTH
returns total length of the array
Jim Duckworth, WPI 13 Advanced Testing using VHDL
------
63 0 63 0 64
14
-----
15
LOOP Statements
Used to iterate through a set of sequential statements Three types
FOR identifier IN range LOOP END LOOP; WHILE boolean_expression LOOP END LOOP; LOOP EXIT WHEN condition_test END LOOP;
16
FOR LOOP
general syntax
FOR identifier IN range LOOP END LOOP;
example:
factorial := 1; FOR number IN 2 TO n LOOP factorial := factorial * number; END LOOP;
17
WHILE Loop
general syntax
WHILE boolean_expression END LOOP;
example:
j := 0; sum := 10; wh_loop: WHILE j < 20 LOOP sum := sum * 2 j := j + 3; END LOOP wh_loop;
LOOP
No iteration scheme
statements in body executed repeatedly until loop exits
General syntax
LOOP EXIT WHEN boolean_expression; -- optional EXIT statement END LOOP;
Example:
j := 0; sum := 1; l2: LOOP sum := sum * 10 j := j + 17; EXIT WHEN sum > 100; END LOOP l2;
LOOP contd
EXIT statement
only used inside a loop
General syntax
EXIT [loop_label] [WHEN condition] EXIT WHEN boolean_expression; -- optional EXIT statement END LOOP;
20
LOOP contd
NEXT statement
used to exit a loop for the current iteration of a loop continue to the next iteration
General syntax
NEXT [loop_label] [WHEN condition]
21
LOOP example
PROCESS BEGIN l1: LOOP -- statements -l2: LOOP -- statements -test_num := test_num + 1; EXIT l2 WHEN test_num = 25; IF solenoid_1 = 1 THEN drive_b := 0; NEXT l1; -- go to top of loop1 END IF; IF trigger = 0 THEN -- statements END LOOP l2; EXIT l1 WHEN sim_tests = 200; END LOOP l1; Jim Duckworth, WPI 22 Advanced Testing using VHDL
Assert Statements
During testing
Usually want to display information about signals and variables
25
26
27
test_vec.txt File
Format is
3 bits for SEL input 8 bits for expected output
29
30
31
32
33
34
35
36
37
38
39
results_file
40
41
42
43