Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  nodelist  faq  

It is easier to change the specification to fit the program than vice versa.


programming / comp.lang.vhdl / How to manage multiple testcases in a testbench

SubjectAuthor
* How to manage multiple testcases in a testbenchBenjamin Couillard
+- Re: How to manage multiple testcases in a testbenchKKoorndyk
`- Re: How to manage multiple testcases in a testbenchKJ

1
Subject: How to manage multiple testcases in a testbench
From: Benjamin Couillard
Newsgroups: comp.lang.vhdl
Date: Mon, 19 Jul 2021 13:55 UTC
X-Received: by 2002:a0c:fbc3:: with SMTP id n3mr24910359qvp.3.1626702925374;
Mon, 19 Jul 2021 06:55:25 -0700 (PDT)
X-Received: by 2002:a25:b793:: with SMTP id n19mr31540924ybh.488.1626702925100;
Mon, 19 Jul 2021 06:55:25 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.snarked.org!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.vhdl
Date: Mon, 19 Jul 2021 06:55:24 -0700 (PDT)
Injection-Info: google-groups.googlegroups.com; posting-host=173.179.222.254; posting-account=d6rREgoAAAD9Yw3nMSUmtdHVlgasip1j
NNTP-Posting-Host: 173.179.222.254
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <a02c8714-16e7-4527-8f0f-fedb1c1335f2n@googlegroups.com>
Subject: How to manage multiple testcases in a testbench
From: benjamin...@gmail.com (Benjamin Couillard)
Injection-Date: Mon, 19 Jul 2021 13:55:25 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 18
View all headers
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


Subject: Re: How to manage multiple testcases in a testbench
From: KKoorndyk
Newsgroups: comp.lang.vhdl
Date: Tue, 20 Jul 2021 12:39 UTC
References: 1
X-Received: by 2002:a05:620a:1137:: with SMTP id p23mr30112149qkk.490.1626784743612;
Tue, 20 Jul 2021 05:39:03 -0700 (PDT)
X-Received: by 2002:a25:c60a:: with SMTP id k10mr39394055ybf.53.1626784743258;
Tue, 20 Jul 2021 05:39:03 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.vhdl
Date: Tue, 20 Jul 2021 05:39:03 -0700 (PDT)
In-Reply-To: <a02c8714-16e7-4527-8f0f-fedb1c1335f2n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=204.19.223.19; posting-account=w728HAoAAAAF2xrMb6mkfbhZUlYwqJjV
NNTP-Posting-Host: 204.19.223.19
References: <a02c8714-16e7-4527-8f0f-fedb1c1335f2n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <cf3f7d5f-0676-418a-bd01-ee6cdf449257n@googlegroups.com>
Subject: Re: How to manage multiple testcases in a testbench
From: kris.koo...@gmail.com (KKoorndyk)
Injection-Date: Tue, 20 Jul 2021 12:39:03 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
View all headers
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









Subject: Re: How to manage multiple testcases in a testbench
From: KJ
Newsgroups: comp.lang.vhdl
Date: Wed, 28 Jul 2021 15:03 UTC
References: 1
X-Received: by 2002:a05:622a:390:: with SMTP id j16mr25015845qtx.266.1627484628891;
Wed, 28 Jul 2021 08:03:48 -0700 (PDT)
X-Received: by 2002:a25:568b:: with SMTP id k133mr242657ybb.196.1627484628697;
Wed, 28 Jul 2021 08:03:48 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.vhdl
Date: Wed, 28 Jul 2021 08:03:48 -0700 (PDT)
In-Reply-To: <a02c8714-16e7-4527-8f0f-fedb1c1335f2n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=99.184.241.163; posting-account=TJOePQoAAADr-f6dDt_fMmacSJMCG-pd
NNTP-Posting-Host: 99.184.241.163
References: <a02c8714-16e7-4527-8f0f-fedb1c1335f2n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <c0717e46-8d93-481b-bc80-fd9dd5dbc7f1n@googlegroups.com>
Subject: Re: How to manage multiple testcases in a testbench
From: kkjenni...@sbcglobal.net (KJ)
Injection-Date: Wed, 28 Jul 2021 15:03:48 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
View all headers
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


1
rocksolid light 0.7.0
clearneti2ptor