Search code examples
pythonghdlvunit

Run same testbench with different parameter files in VUnit


I have a project with the following structure:

tb_top
├── run.py
└── src
    ├── tb_top.vhd
    ├── test_a
    │   ├── top_parameter.vhd
    │   ├── input.csv
    │   └── output.csv
    ├── test_b
    │   ├── top_parameter.vhd
    │   ├── input.csv
    │   └── output.csv
    └── ...
src
├── bar.vhd
├── foo.vhd
└── top.vhd

top.vhd includes foo.vhd, bar.vhd as well as top_parameter.vhd of each test case. In run.py, first the files at src/ folder are compiled and then the top_parameter.vhd for each test case. All files are in the same library. When running run.py the following error is displayed:

tb_top/src/tb_top.vhd:44:20: entity "top" is obsoleted by package "top_parameter"
/usr/local/bin/ghdl: compilation error

Obviously, top.vhd should be recompiled everytime when top_parameter.vhd gets recompiled, but I can't figure out how to structure my run.py. Is there are way to compile the tests correctly, without:

  1. recompiling foo.vhd and bar.vhd for each test?
  2. duplicating identical files like tb_top.vhd and run.py for each test?

I'm using VUnit 4.2.0 and the current master of ghdl. If needed, I can prepare a MWE.


Solution

  • The compiled libraries can't change between test runs in VUnit. The preferred solution is to pass the parameter as top level generics instead of using a separate file.

    However, I didn't want to change the file structure. So in my case, top_parameter.vhd and all dependent files got compiled into a separate library for each test case. To chose the correct library, an extra generic got passed to the testbench.

    More details and other options can be found here.