On Monday, July 19, 2021 at 9:55:26 AM UTC-4,
[email protected] wrote:
Hi, I'm trying to implement a testbench for a relatively complex module and I need multiple test cases to cover all the functionnality. I'd like to find an elegant way to perform multiple testcases without using text files for the stimulus because I
find that text files are not really flexible. Here's my options so far
1 - Use one testbench file per test case. I don't really like this approach as I need to duplicate a lot of code amongst the testbench files even if I put procedure in a package.
2 - Use a generic to specify the testcase, then use a If generate clause to wrap the stimulus and validation process for each test case.
3 - Put all test cases in a the same process and simply reset the module between each test case.
I hesitate between option 2 and 3. Is there another option ?
Regards
I use a top level testbench that instantiates a test harness and a generic testcase like this:
--------------------------------------------------------------------------------------------------------------
architecture tb of testbench is
component harness is
end component harness;
component testcase is
end component testcase;
begin
th: component harness;
tc: component testcase;
end architecture tb; --------------------------------------------------------------------------------------------------------------
The testcase entity is defined in one file and each testcase containing the stimulus are defined in separate testcase architecture files. I use VHDL configurations in the testbench to select the appropriate testcase:
--------------------------------------------------------------------------------------------------------------
-- Test Configuration 1 (TCFG1) --------------------------------------------------------------------------------------------------------------
configuration tcfg1 of testbench is
for tb
for th : harness
use entity work.harness
generic map (
G_LOG_FILENAME => "tcfg1_log",
G_WIDTH => 34
);
end for;
for tc : testcase
use entity work.testcase(tc1)
generic map (
G_WIDTH => 34
);
end for;
end for;
end configuration tcfg1;
Then, simulating a specific testcase is done by targeting the corresponding configuration:
$ vsim ${VOPTS} work.tcfg1
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)