bench: Use VUnit

Well, not really. This just makes it compile and work with VUNIT,
but it's not a real VUnit test bench. Will do that at some other
point.
This commit is contained in:
Markus Koch 2022-01-16 17:46:01 +01:00
parent ef6b6378f8
commit 37714d5c2d
3 changed files with 48 additions and 2 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
vunit_out

View File

@ -18,7 +18,13 @@ use work.bench_pkg.all;
library trashernet;
use trashernet.trashernet_pkg.all;
library vunit_lib;
context vunit_lib.vunit_context;
entity bench_trashernet_mac is
generic(
runner_cfg : string
);
end entity bench_trashernet_mac;
architecture bench of bench_trashernet_mac is
@ -37,6 +43,8 @@ architecture bench of bench_trashernet_mac is
constant TEST_BENCH_LOOPBACK : boolean := true;
signal mac_tx_start : std_logic := '0';
begin
trashernet_phy_cdc_inst : entity trashernet.trashernet_phy_cdc
generic map(
@ -144,6 +152,8 @@ begin
mac_tx : process is
begin
wait on mac_tx_start;
mac_in.tx_mac_data <= x"11";
mac_in.tx_header.mac_destination <= (x"12", x"23", x"34", x"45", x"56", x"67");
mac_in.tx_header.mac_source <= (x"a2", x"a3", x"a4", x"a5", x"a6", x"a7");
@ -159,8 +169,27 @@ begin
wait until rising_edge(mac_out.tx_mac_data_ack);
wait until rising_edge(clk);
mac_in.tx_mac_data_en <= '0';
wait;
end process mac_tx;
test : process is
begin
wait for 1 ns;
test_runner_setup(runner, runner_cfg);
while test_suite loop
if run("mac_tx_rx_simple") then
mac_tx_start <= not mac_tx_start;
wait on mac_out.rx_mac_crc_ok, mac_out.rx_mac_crc_error for 1 ms;
assert mac_out.rx_mac_crc_ok = '1' report "Did not receive CRC OK" severity error;
end if;
end loop;
wait for 1 ns;
wait until rising_edge(clk);
test_runner_cleanup(runner);
end process test;
end architecture bench;

16
run.py Executable file
View File

@ -0,0 +1,16 @@
#!/usr/bin/env python
from vunit import VUnit
import os
library_names = ["trashernet", "bench"]
libs = {}
vu = VUnit.from_argv()
for library_name in library_names:
libs[library_name] = vu.add_library(library_name)
libs[library_name].add_source_files(os.path.join(library_name, "*.vhd"))
vu.main()