Skip to content

Commit 38e24a9

Browse files
committed
simpe vunit testing example
1 parent 578b249 commit 38e24a9

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,7 @@ Testbench will run, print results and then stop automatically.
3333
* Example components?
3434
* Three main different ways to implement state machines.
3535
* Use VUnit to implement basic testing examples.
36+
* Use VHDL 2008 env package (std.env.finish for instance).
37+
* Example to show that 'work' is not a library but a reference to same library
38+
where this element is defined (example:
39+
https://github.com/VUnit/vunit/issues/497).
Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,38 @@
1-
-- TODO: Write test bench to test bit multiplier using vunit.
1+
-- TODO: Finish this test bench with carry and p testings.
2+
library ieee;
23
library vunit_lib;
4+
5+
use ieee.std_logic_1164.all;
36
context vunit_lib.vunit_context;
47

8+
59
entity tb_example is
610
generic (runner_cfg : string);
711
end entity;
812

13+
914
architecture tb of tb_example is
15+
signal x_in, y_in, c_in, p_in : std_logic := '0';
16+
signal x_out, y_out, c_out, p_out : std_logic;
1017
begin
18+
dut : entity work.bit_multiplier port map (x_in, y_in, p_in, c_in, x_out, y_out, p_out, c_out);
19+
1120
main : process
1221
begin
1322
test_runner_setup(runner, runner_cfg);
14-
report "Hello world!";
23+
24+
while test_suite loop
25+
if run("test_without_carry") then
26+
x_in <= '1';
27+
y_in <= '0';
28+
wait for 1 ps;
29+
check(y_out = '0');
30+
check(x_out = '1');
31+
elsif run("second test") then
32+
report "second";
33+
end if;
34+
end loop;
35+
1536
test_runner_cleanup(runner); -- Simulation ends here
1637
end process;
1738
end architecture;

components-and-cores/arithmetic/array-multiplier/vimhdl.prj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ builder = msim
22
target_dir = .build
33

44
vhdl work bit_multiplier.vhd -2008
5+
vhdl work bit_multiplier_tb.vhd -2008

0 commit comments

Comments
 (0)