# Example code for multiple agents

**URL:** <https://verificationacademy.com/forums/t/example-code-for-multiple-agents/36177>\
**Category:** UVM\
**Tags:** UVM, multiple-agents, sample-code-for-array-agent\
**Created:** [June 13, 2019, 10:27am UTC](https://verificationacademy.com/forums/t/example-code-for-multiple-agents/36177 "2019-06-13T10:27:07Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![Rufhana](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/r/6bbea6/32.png) [@Rufhana](https://verificationacademy.com/forums/u/Rufhana)\
**Post date:** [June 14, 2019, 5:58am UTC](https://verificationacademy.com/forums/t/example-code-for-multiple-agents/36177/3 "2019-06-14T05:58:31Z")

</div>

_In reply to [chr\_sue](https://verificationacademy.com/forums/t/example-code-for-multiple-agents/36177/2):_

My DUT is basically a switch which is connected to 8 device having same functionality. May be I was wrong which I mentioned as 8 diff interfaces.

```verilog
 interconnect DUT (.clk(clk),
                   .reset_(reset_),
                   .input0_packet(dut_if1.input_packet[0]),
                   .input0_packet_v(dut_if1.input_packet_v[0]),
                   .input0_credit(dut_if1.input0_credit),

                   .output0_packet(dut_if1.output_packet[0]),
                   .output0_packet_v(dut_if1.output_packet_v[0]),
                   .output0_credit(dut_if1.output_credit[0]),
       				
                    .input1_packet (dut_if1.input_packet[1]),
                    .input1_packet_v(dut_if1.input_packet_v[1]),
                    .input1_credit (dut_if1.input1_credit),

                    .output1_packet (dut_if1.output_packet[1]),
                    .output1_packet_v(dut_if1.output_packet_v[1]),
                    .output1_credit (dut_if1.output_credit[1]),

```

The above piece of code I have shown is the top level connection of dut to interface. But instaed of making this as array(output\_packet[1]) connection, i am trying to create instance of agents lets say my\_agent[8]. i need to know what is the minimal ways to implement this funtionality.

Thanks!

---

_[View the full topic](https://verificationacademy.com/forums/t/example-code-for-multiple-agents/36177)._
