|
11 | 11 | --library vunit_lib; |
12 | 12 | --context vunit_lib.vunit_context; |
13 | 13 |
|
| 14 | +library ieee; |
| 15 | +use ieee.std_logic_1164.all; |
| 16 | +use ieee.numeric_std.all; |
| 17 | + |
14 | 18 | library vunit_lib; |
15 | 19 | use vunit_lib.run_pkg.all; |
16 | 20 | use vunit_lib.logger_pkg.all; |
17 | 21 | use vunit_lib.types_pkg.all; |
18 | 22 | use vunit_lib.byte_vector_ptr_pkg.all; |
| 23 | +use vunit_lib.integer_vector_ptr_pkg.all; |
| 24 | +use vunit_lib.clk_pkg.all; |
19 | 25 |
|
20 | 26 | entity tb_external_byte_vector is |
21 | 27 | generic ( runner_cfg : string ); |
22 | 28 | end entity; |
23 | 29 |
|
24 | 30 | architecture tb of tb_external_byte_vector is |
25 | 31 |
|
26 | | - constant block_len : natural := 5; |
| 32 | + constant params: integer_vector_ptr_t := new_integer_vector_ptr(6, extacc, 0); |
| 33 | + |
| 34 | + constant clk_step : natural := get(params, 2); |
| 35 | + constant block_len : integer := get(params, 4); |
27 | 36 |
|
28 | | - constant ebuf: byte_vector_ptr_t := new_byte_vector_ptr( 3*block_len, extfnc, 0); -- external through VHPIDIRECT functions 'read_char' and 'write_char' |
29 | | - constant abuf: byte_vector_ptr_t := new_byte_vector_ptr( 3*block_len, extacc, 0); -- external through access (requires VHPIDIRECT function 'get_string_ptr') |
| 37 | + constant ebuf: byte_vector_ptr_t := new_byte_vector_ptr( 3*block_len, extfnc, 1); -- external through VHPIDIRECT functions 'read_char' and 'write_char' |
| 38 | + constant abuf: byte_vector_ptr_t := new_byte_vector_ptr( 3*block_len, extacc, 1); -- external through access (requires VHPIDIRECT function 'get_string_ptr') |
| 39 | + |
| 40 | + signal clk, rst, rstn : std_logic := '0'; |
| 41 | + signal done, tg, start : boolean := false; |
30 | 42 |
|
31 | 43 | begin |
32 | 44 |
|
33 | | - main: process |
| 45 | + rstn <= not rst; |
| 46 | + |
| 47 | + clk_gen: entity vunit_lib.clk_handler generic map ( params ) port map ( rst, clk, tg ); |
| 48 | + |
| 49 | + run: process(tg) begin if rising_edge(tg) then |
| 50 | + info("UPDATE READY"); |
| 51 | + set(params, 3, 1); |
| 52 | + end if; end process; |
| 53 | + |
| 54 | + main: process begin |
| 55 | + test_runner_setup(runner, runner_cfg); |
| 56 | + rst <= '1'; |
| 57 | + info("Init test: " & to_string(block_len)); |
| 58 | + wait for 100 ns; |
| 59 | + rst <= '0'; |
| 60 | + info("wait_load"); |
| 61 | + wait_load(params); |
| 62 | + info("start"); |
| 63 | + start <= true; |
| 64 | + info("wait_sync"); |
| 65 | + wait_sync(params, done, tg); |
| 66 | + info("Test done"); |
| 67 | + test_runner_cleanup(runner); |
| 68 | + wait; |
| 69 | + end process; |
| 70 | + |
| 71 | + stimuli: process |
34 | 72 | variable val, ind: integer; |
35 | 73 | begin |
36 | | - test_runner_setup(runner, runner_cfg); |
37 | | - info("Init test"); |
| 74 | + wait until start; |
| 75 | + wait_for(clk, 1); |
38 | 76 | for x in 0 to block_len-1 loop |
39 | 77 | val := get(ebuf, x) + 1; |
40 | 78 | ind := block_len+x; |
41 | 79 | set(ebuf, ind, val); |
42 | 80 | info("SET " & to_string(ind) & ": " & to_string(val)); |
| 81 | + wait_for(clk, 1); |
43 | 82 | end loop; |
44 | 83 | for x in block_len to 2*block_len-1 loop |
45 | 84 | val := get(abuf, x) + 2; |
46 | 85 | ind := block_len+x; |
47 | 86 | set(abuf, ind, val); |
48 | 87 | info("SET " & to_string(ind) & ": " & to_string(val)); |
| 88 | + wait_for(clk, 1); |
49 | 89 | end loop; |
50 | | - info("End test"); |
51 | | - test_runner_cleanup(runner); |
| 90 | + info("done"); |
| 91 | + done <= true; |
52 | 92 | wait; |
53 | 93 | end process; |
54 | 94 |
|
|
0 commit comments