diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3f7ae5b --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +vunit_out diff --git a/bench/bench_trashernet_mac.vhd b/bench/bench_trashernet_mac.vhd index 3bc6563..9b2bd42 100644 --- a/bench/bench_trashernet_mac.vhd +++ b/bench/bench_trashernet_mac.vhd @@ -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; diff --git a/run.py b/run.py new file mode 100755 index 0000000..95cb34b --- /dev/null +++ b/run.py @@ -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()