# Dynamic DUT instantiation

**URL:** <https://verificationacademy.com/forums/t/dynamic-dut-instantiation/30264>\
**Category:** UVM\
**Tags:** config\_db-DUT, UVM\
**Created:** [January 5, 2015, 11:30am UTC](https://verificationacademy.com/forums/t/dynamic-dut-instantiation/30264 "2015-01-05T11:30:19Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![shristozkov](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/s/3d9bf3/32.png) [@shristozkov](https://verificationacademy.com/forums/u/shristozkov)\
**Post date:** [January 5, 2015, 11:30am UTC](https://verificationacademy.com/forums/t/dynamic-dut-instantiation/30264/1 "2015-01-05T11:30:19Z")

</div>

Hi,

Firstly, I am quite new at both UVM and verification in general but I’ve been putting a lot of effort into it and the resources I’ve found here have been extremely useful so thank you for your efforts.

I am currently verifying a chip that works in one of 3 modes - as a master, a slave or an “individual”. This is decided via a ChipId, which is to be hardwired. In short, the chip is part of a sensing system so we have a control mechanism and a readout mechanism.

The system I’m verifying is essentially working in one of two scenarios:

1. Up to 6 slaves share a line to communicate with a single master (via a token exchange mechanism), which in exchange passes its own and the slaves’ data to the outside world using a specified high speed link.
2. Up to 9 “individuals” share a control line but each has an instance of the aforementioned high speed link to get data out.

What I would like to do is have a DUT module that gets information from the test configuration and decides how many chips of each type to instantiate.  
Here are a couple of examples:

1. Run a test with a single master and 6 slaves or a master and 4 slaves (say 2 have experienced a glitch and stopped working, which is likely). Ideally, I’d be randomising the number of faulty slaves and their position along the string of slaves.
2. Run a test with a variable number of “individual” chips.  
Example 1) above is really critical for me, as we have observed bugs as a result of a single slave breaking down (to do with the token exchange mechanism). Anyway this needs to be verified.

Naturally, I can just cover the basic cases and create a number of DUT instances and TOP modules to correspond. However, this is not really in line with basic principles taught here, hard to maintain and makes regression testing difficult. I can’t really get a configuration object from the DB before instantiating the DUT in the TOP level.  
Another option I see is instantiating enough devices to be able to cover every scenario and selectively wiring some of them to GND. However, I don’t think this is ideal as it clutters and slows down the environment.

I hope I’ve managed to properly explain my issue. Please, feel free to contribute any ideas since I am not at all happy with the options I’ve come up with.

Regards,

Svet

---

<div class="post-metadata">

**Author:** ![dave\_59](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/dave_59/32/4499_2.png) [@dave\_59](https://verificationacademy.com/forums/u/dave_59)\
**Post date:** [January 5, 2015, 10:53pm UTC](https://verificationacademy.com/forums/t/dynamic-dut-instantiation/30264/2 "2015-01-05T22:53:42Z")

</div>

You can’t dynamically instantiate a module. If you instantiate all devices and selectively tie their inputs to GND you will not pay any run-time penalty, just some elaboration setup time.

What I have recommended in the past is to have a two-step flow where you use the randomization features to write a SystemVerilog package that is used in the second step to configure the DUT for running the test.

Dave

---

<div class="post-metadata">

**Author:** ![shristozkov](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/s/3d9bf3/32.png) [@shristozkov](https://verificationacademy.com/forums/u/shristozkov)\
**Post date:** [January 6, 2015, 8:38am UTC](https://verificationacademy.com/forums/t/dynamic-dut-instantiation/30264/3 "2015-01-06T08:38:45Z")

</div>

_In reply to [dave\_59](https://verificationacademy.com/forums/t/dynamic-dut-instantiation/30264/2):_

Thanks for your reply!

I shall proceed with that option then - I was just hoping there might be a trick I’m missing to make the whole thing a little more elegant.

Svet

---

<div class="post-metadata">

**Author:** ![M\_Somasekhar](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/m/bbe5ce/32.png) [@M\_Somasekhar](https://verificationacademy.com/forums/u/M_Somasekhar)\
**Post date:** [May 5, 2016, 6:27am UTC](https://verificationacademy.com/forums/t/dynamic-dut-instantiation/30264/4 "2016-05-05T06:27:40Z")

</div>

Hi Dave,

If possible could you please point me to your past recommended post?  
I would like to understand what is the ideal way to tieoff the DUT signals during the run time.

Should I look for command line args in the tb\_top and tie off the redundant DUT signals or is there any better approach to achieve this run time DUT configuration?

Thanks,  
Somasekhar M

_In reply to [dave\_59](https://verificationacademy.com/forums/t/dynamic-dut-instantiation/30264/3):_

> You can’t dynamically instantiate a module. If you instantiate all devices and selectively tie their inputs to GND you will not pay any run-time penalty, just some elaboration setup time.  
> What I have recommended in the past is to have a two-step flow where you use the randomization features to write a SystemVerilog package that is used in the second step to configure the DUT for running the test.  
> Dave

---

<div class="post-metadata">

**Author:** ![dave\_59](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/dave_59/32/4499_2.png) [@dave\_59](https://verificationacademy.com/forums/u/dave_59)\
**Post date:** [May 5, 2016, 6:50am UTC](https://verificationacademy.com/forums/t/dynamic-dut-instantiation/30264/5 "2016-05-05T06:50:42Z")

</div>

_In reply to [M Somasekhar](https://verificationacademy.com/forums/t/dynamic-dut-instantiation/30264/4):_  
[https://verificationacademy.com/forums/ovm/randomizing-module-parameters](https://verificationacademy.com/forums/ovm/randomizing-module-parameters)

```verilog
module1 inst1(..., .input_portN(input_to_module1), ...);
module2 inst2(..., .output_portM(output_from_module2), ...);

assign input_to_module1 = mode ? output_from_module2 : constant_to_tieoff;

```
