Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > VHDL > Testing generic module

Reply
Thread Tools

Testing generic module

 
 
hssig
Guest
Posts: n/a
 
      01-06-2010
Hi,

I want to write a testbench to test a module with generic(s).


The unit under test:

component gen_mod
generic( gA : natural := 3)
port( ....);
end component;


Now in my testbench I define an array of constants, for example:

type type_ctable is array(natural range <>) of natural;

constant cGenTable : type_ctable(0 to 7) := (3,4,5,6,7,8,9.10);

The instantiation of the UUT:

UUT: gen_mod
generic map( gA => cGenTable(0))
port map( ...);

Now my question is how to perform a bundle of simulation runs to test
the complete array of constants without having to adjust the generic
map manually, then recompile and restart the simulation.

Thank you for your opinion.

Cheers,
hssig
 
Reply With Quote
 
 
 
 
Jonathan Bromley
Guest
Posts: n/a
 
      01-06-2010
On Wed, 6 Jan 2010 06:31:20 -0800 (PST), hssig wrote:

>I want to write a testbench to test a module with generic(s).
>
>Now in my testbench I define an array of constants, for example:
>
>type type_ctable is array(natural range <>) of natural;
>
>constant cGenTable : type_ctable(0 to 7) := (3,4,5,6,7,8,9.10);
>
>The instantiation of the UUT:
>
>UUT: gen_mod
>generic map( gA => cGenTable(0))
>port map( ...);
>
>Now my question is how to perform a bundle of simulation runs to test
>the complete array of constants without having to adjust the generic
>map manually, then recompile and restart the simulation.


Two options spring to mind:

(1)
If the scale of the problem is sufficiently small,
you could instantiate ALL your diffferent UUTs using a
generate loop:

gen_various_devices:
for config in cGenTable'range generate
UUT: gen_mod generic map (gA => cGenTable(config)) ...;
end generate;

and then a single sim will run all of them in parallel. You
would probably need to instantiate various other parts of your
testbench in the generate loop too, because presumably the
various UUT configurations won't all behave in the same way
and they may even need rather different stimulus.

(2)
Better (I think): Set the generic from the simulator command line.
Given your table-of-constants, you have a single number (an index
into that table) that controls your entire UUT and testbench
setup. If you give the top-level testbench a generic of its own,
to set that index:

entity tb_top is
generic (config: natural);
end;
architecture A of tb_top is
...
begin
UUT: gen_mod generic map (gA =>cGenTable(config)) ...;
...

you can then compile the whole mess just once, and simulate
with any chosen value of the top-level config. This for
ModelSim - other simulators can do similar things:

<file run_all_configs.tcl>
for {set config 0} {$config < 8} {incr config} {
# load sim with correct generic
vsim -c -gconfig=$config tb_top
# run sim
run -all
}

<at the simulator command prompt>
do run_all_configs.tcl

If your simulation is large, this approach makes it easy
to distribute the simulation runs across several machines
using GridEngine or whatever.

(3)
Like (2), but instead of using the simulator command line
to set the generic, write a VHDL configuration for each
different generic value you care about. Then you can,
once again, compile the whole lot; and simply choose which
VHDL configuration you wish to simulate. Many folk
find VHDL configurations somewhat indigestible, and I
strongly sympathize; maybe the simulator command line
thing is less hassle after all.
--
Jonathan Bromley

 
Reply With Quote
 
 
 
 
Andy
Guest
Posts: n/a
 
      01-06-2010
Most simulators will allow command line options that set the value(s)
of top level generic(s), in this case, the top level testbench entity.
Just pass the generic you want to use up to the top of your
testbench, and then a script can invoke simulations for each generic
value.

Andy
 
Reply With Quote
 
hssig
Guest
Posts: n/a
 
      01-12-2010
>you can then compile the whole mess just once, and simulate
>with any chosen value of the top-level config.


Your proposed approach works fine!

Thank you.
Cheers,
hssig
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Unit testing errors (testing the platform module) John Maclean Python 1 04-13-2010 02:11 PM
not just generic type programming,but also parallism generic syntaxprogramming?? minlearn C++ 2 03-13-2009 05:17 PM
generic interfaces with generic methods Murat Tasan Java 1 02-03-2009 12:17 PM
Generic class in a non generic class nramnath@gmail.com Java 2 07-04-2006 07:24 AM
Re: module docstring, documentation,anything? please note is the module type/object NOT some module Maric Michaud Python 0 06-24-2006 12:42 PM



Advertisments