# Binding a module to another module's modport interface

**URL:** <https://verificationacademy.com/forums/t/binding-a-module-to-another-modules-modport-interface/49782>\
**Category:** SystemVerilog\
**Tags:** Assertion-Based-Verification, SVA-Assertion, SVA, Assertion-system-verilog, assertion-systemverilog, assertion\
**Created:** [March 6, 2025, 7:42pm UTC](https://verificationacademy.com/forums/t/binding-a-module-to-another-modules-modport-interface/49782 "2025-03-06T19:42:11Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![varunr86](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/v/c37758/32.png) [@varunr86](https://verificationacademy.com/forums/u/varunr86)\
**Post date:** [March 6, 2025, 7:42pm UTC](https://verificationacademy.com/forums/t/binding-a-module-to-another-modules-modport-interface/49782/1 "2025-03-06T19:42:11Z")

</div>

Given that a DUT uses a modport in its interface definition shown below -

```auto
module DUT 
(
      input clk,
      input resetn,
      dut_if.initiator if1
); 
endmodule

```

And interface itself looks like -

```auto
interface dut_if ;
      logic req;
      logic gnt;

      modport initiator {output req, input gnt};
      modport responder {input req, output gnt};
endinterface

```

If I have write a SVA module with some properties, conventional wisdom says - all ports of a DUT are inputs to a SVA module that’s supposed to be bound to the DUT.

How do I define the ports of SVA module (specifically the signals in modport) so that I can bind successfully?

`PS: I did checkout the various other questions in the forum. Most of the examples were using only 'input' ports in the interface/modport.. Didnt find one modport with both direction ports..`

---

<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:** [March 6, 2025, 8:09pm UTC](https://verificationacademy.com/forums/t/binding-a-module-to-another-modules-modport-interface/49782/2 "2025-03-06T20:09:45Z")

</div>

I do not understand why the dut\_if modport directions matter here. The SVA module that gets bound inside the DUT module would still be `input`s.

---

<div class="post-metadata">

**Author:** ![varunr86](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/v/c37758/32.png) [@varunr86](https://verificationacademy.com/forums/u/varunr86)\
**Post date:** [March 7, 2025, 6:38am UTC](https://verificationacademy.com/forums/t/binding-a-module-to-another-modules-modport-interface/49782/3 "2025-03-07T06:38:13Z")

</div>

Hi @dave_59 ,  
Here if the DUT interface were -

```auto
      input clk,
      input resetn,
      input req,
      output gnt

```

And the SVA module ports were are all inputs, then SVA bind works. That’s traditional formal bench.

there are 2 issues -

1… But with the DUT having a modport at the interface, SVA input ports (sepa\*\*rate req/gnt signals\*\*) can’t be bound to the modport, because they dont match the modport type.  
2… And SVA needs all signals as inputs, and there is **no such modport** to instantiate…  
3… Even if there was a modport with all inputs, to be used in SVA, can’t bind that modport to the DUT’s modport, because they are different…

Hope it makes it clear…

---

<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:** [March 7, 2025, 2:07pm UTC](https://verificationacademy.com/forums/t/binding-a-module-to-another-modules-modport-interface/49782/4 "2025-03-07T14:07:00Z")

</div>

Your issue has nothing to do with the `bind` construct. You can always instantiate a module without an interface with signals from members of an interface. Let’s say your SVA module looked like:

```auto
module sva ( 
      input clk,
      input resetn,
      input req,
      input gnt);
// ...
endmodule

```

Then inside your DUT module, you can instantiate this module as:

```auto
sva s1(clk,resetn,if1.req,if1.gnt);

```

---

<div class="post-metadata">

**Author:** ![varunr86](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/v/c37758/32.png) [@varunr86](https://verificationacademy.com/forums/u/varunr86)\
**Post date:** [March 7, 2025, 7:35pm UTC](https://verificationacademy.com/forums/t/binding-a-module-to-another-modules-modport-interface/49782/5 "2025-03-07T19:35:56Z")

</div>

Oh yes. That is what I ended up doing.  
But that’s not the ideal solution. RTL designers dont want to modify their file to include verification files.

That is where - bind - comes in handy. Your file is very much separated from RTL files. And won’t compile/bind, if the SVA file is specifically not passed for compilation.

And looks like the bind in this case doesn’t work. I was trying to see if I am missing something?  
I think we need support in SystemVerilog to be able to bind directly to a modport, for formal verification purposes.

---

<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:** [March 7, 2025, 10:49pm UTC](https://verificationacademy.com/forums/t/binding-a-module-to-another-modules-modport-interface/49782/6 "2025-03-07T22:49:08Z")

</div>

`bind` should have worked. Please show a complete example using

```
bind DUT sva s1(clk,resetn,if1.req,if1.gnt);

```

---

<div class="post-metadata">

**Author:** ![varunr86](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/v/c37758/32.png) [@varunr86](https://verificationacademy.com/forums/u/varunr86)\
**Post date:** [March 11, 2025, 4:00pm UTC](https://verificationacademy.com/forums/t/binding-a-module-to-another-modules-modport-interface/49782/7 "2025-03-11T16:00:50Z")

</div>

Hi Dave,  
Yes, for a single dimension, that might work.  
My design has multiple dimensions of the modport instance - as shown below…

```auto
module DUT 
(
      input clk,
      input resetn,
      dut_if.initiator if1[3:0]
); 
endmodule

```

And interface itself looks like - as shown before in the thread above…

```auto
interface dut_if ;
      logic req;
      logic gnt;

      modport initiator {output req, input gnt};
      modport responder {input req, output gnt};
endinterface

```

In this case, how would I write the binds…?

- the (.\*) won’t work
- Something like this - `sva s1(clk,resetn,if1.req,if1.gnt);` won’t work as well…?

because here you would have to make sure to bind to - if1[0].req, if1[0].gnt, if1[1].req, if1[1].gnt etc…

---

<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:** [March 11, 2025, 8:44pm UTC](https://verificationacademy.com/forums/t/binding-a-module-to-another-modules-modport-interface/49782/8 "2025-03-11T20:44:27Z")

</div>

It would really help to show a complete example. If you have

```auto
module sva (input wire clk,resetn,req,gnt);
//...
endmodule

```

Then you have multiple binds:

```auto
bind DUT sva s0(clk,resetn,if1[0].req,if1[0].gnt);
bind DUT sva s1(clk,resetn,if1[1].req,if1[1].gnt);

```

But if you have

```auto
module sva (input wire clk,resetn,req[4],gnt[4]);
//...
endmodule

```

The you can use an array assignment pattern

```auto
bind DUT sva s0(clk,resetn, 
     '{if1[0].req, if1[1].req, ...[2]...,...[3]...},
     '{if1[0].gnt, if1[1].gnt, ...[2]...,...[3]...}
);

```

There might be other ways to accomplish this if you gave a more complete example.

---

<div class="post-metadata">

**Author:** ![varunr86](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/v/c37758/32.png) [@varunr86](https://verificationacademy.com/forums/u/varunr86)\
**Post date:** [March 11, 2025, 8:58pm UTC](https://verificationacademy.com/forums/t/binding-a-module-to-another-modules-modport-interface/49782/9 "2025-03-11T20:58:08Z")

</div>

Thanks Dave.  
This solution isn’t scalable if we want to override different values to the bus width when based on parameters.

In my case, the dut.if1 is sized using a parameter with a default value of 64… and can be a bigger value in the places of instantiation.

Is there a more cleaner parameterized way of achieving this for scalability?

---

<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:** [March 12, 2025, 6:14am UTC](https://verificationacademy.com/forums/t/binding-a-module-to-another-modules-modport-interface/49782/10 "2025-03-12T06:14:44Z")

</div>

@varunr86, with every post, you add missing information.

If you want people to help you, please show us a [**minimal, complete example**](https://stackoverflow.com/help/minimal-reproducible-example) of the what the code looks like before the bind. And then show us some example of the SVA modules you want to add using bind with the port connections you would like to see.

---

<div class="post-metadata">

**Author:** ![varunr86](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/v/c37758/32.png) [@varunr86](https://verificationacademy.com/forums/u/varunr86)\
**Post date:** [March 17, 2025, 3:15pm UTC](https://verificationacademy.com/forums/t/binding-a-module-to-another-modules-modport-interface/49782/11 "2025-03-17T15:15:59Z")

</div>

Apologies on the delay to follow up @dave_59

DUT module is same as previous example, except parameterized.

Here are the SVA, interface, and DUT…

Interface - from before…

```auto
interface dut_if ;
      logic [NUM_REQS-1:0] req; //// Each bit pair of req/gnt is a handshake.. and there are NUM_REQs of them..  
      logic [NUM_REQS-1:0] gnt;

      modport initiator {output req, input gnt};
      modport responder {input req, output gnt};
endinterface

```

DUT - updated…

```auto
module DUT 
(
      input clk,
      input resetn,
      dut_if.initiator if1[NUM_PORTS-1:0]
); 
endmodule

```

SVA code (mainly port is what I am looking for…  
SVA - ??

```auto
module sva ( 
      input clk,
      input resetn,
// What's this line going to be??
      input logic [NUM_REQS-1:0] req [NUM_PORTS-1:0],  
/// What's this line going to be..?? 
      input logic [NUM_REQS-1:0] gnt [NUM_PORTS-1:0] ); 
// ...
endmodule

```

and how will the bind look…?

---

<div class="post-metadata">

**Author:** ![varunr86](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/v/c37758/32.png) [@varunr86](https://verificationacademy.com/forums/u/varunr86)\
**Post date:** [April 1, 2025, 3:53am UTC](https://verificationacademy.com/forums/t/binding-a-module-to-another-modules-modport-interface/49782/12 "2025-04-01T03:53:24Z")

</div>

Hi @dave_59 , any thoughts on the query shared above. Let me know if feel anything more is needed from my side. Would appreciate your inputs. Keen on knowing if this could be done in a scalable manner.

---

<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:** [April 1, 2025, 5:28pm UTC](https://verificationacademy.com/forums/t/binding-a-module-to-another-modules-modport-interface/49782/13 "2025-04-01T17:28:47Z")

</div>

As I Said before, If you want people to help you, please show us a [**minimal, complete example**](https://stackoverflow.com/help/minimal-reproducible-example) of the what the code looks like before the bind.  
Show all the interface connections. Why not have NUM\_PORTS a parameter of the interface creating arrays of `req/gnt`?

---

<div class="post-metadata">

**Author:** ![varunr86](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/v/c37758/32.png) [@varunr86](https://verificationacademy.com/forums/u/varunr86)\
**Post date:** [April 2, 2025, 9:47pm UTC](https://verificationacademy.com/forums/t/binding-a-module-to-another-modules-modport-interface/49782/14 "2025-04-02T21:47:54Z")

</div>

@dave_59 I am not sure, what you are not finding complete here. Can you elaborate, what else you think is missing?

- DUT and Interface - listed above

- SVA is what I am trying to figure out… What I have listed is what I can think of… But that’s not working… So looking for answers…

As for having NUM\_PORTS be a parameter of the interface, thats not how the RTL looks on my end. It looks exactly like how I pasted above…  
Your question is a design implementation question.

I am trying to see how I can write SVA for the RTL at-hand.
