Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to manage multiple testcases in a testbench

64 views
Skip to first unread message

Benjamin Couillard

unread,
Jul 19, 2021, 9:55:26 AM7/19/21
to
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

KKoorndyk

unread,
Jul 20, 2021, 8:39:05 AM7/20/21
to
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







KJ

unread,
Jul 28, 2021, 11:03:50 AM7/28/21
to
On Monday, July 19, 2021 at 9:55:26 AM UTC-4, benjamin....@gmail.com wrote:
I use a variation on #2. However, instead of a generic I use a boolean array to specify which tests to run. The main test code then simply loops through the array and calls the test case code if the boolean is true. I define an enumeration list of the tests mainly to give a readable named list of all of the tests. The boolean array is an array of that enumeration list. This is also easy to adjust while in debug mode where I might want to only run either a single test or some subset.

Example:
type t_TESTS is (TestThis, TestThat, TestSomethingElse);
type t_LIST_OF_TESTS is array(t_TESTS) of boolean;
constant TestsToRun: t_LIST_OF_TESTS :=
(
TestThis => TRUE,
TestThat => TRUE,
TestSomethingElse => TRUE
);

Kevin Jennings
0 new messages