• How to manage multiple testcases in a testbench

    From Benjamin Couillard@21:1/5 to All on Mon Jul 19 06:55:24 2021
    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

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From KKoorndyk@21:1/5 to benjamin....@gmail.com on Tue Jul 20 05:39:03 2021
    On Monday, July 19, 2021 at 9:55:26 AM UTC-4, benjamin....@gmail.com 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)
  • From KJ@21:1/5 to benjamin....@gmail.com on Wed Jul 28 08:03:48 2021
    On Monday, July 19, 2021 at 9:55:26 AM UTC-4, benjamin....@gmail.com 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 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

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)