# Parameterizing the Bit Widths of fields in a packed struct so that modules can infer bit width if used in port map - virtual interface - interface - compile time configured struct bit width

**URL:** <https://verificationacademy.com/forums/t/parameterizing-the-bit-widths-of-fields-in-a-packed-struct-so-that-modules-can-infer-bit-width-if-used-in-port-map-virtual-interface-interface-compile-time-configured-struct-bit-width/38548>\
**Category:** SystemVerilog\
**Tags:** SystemVerilog, systemverilog-interface\
**Created:** [January 6, 2021, 12:14pm UTC](https://verificationacademy.com/forums/t/parameterizing-the-bit-widths-of-fields-in-a-packed-struct-so-that-modules-can-infer-bit-width-if-used-in-port-map-virtual-interface-interface-compile-time-configured-struct-bit-width/38548 "2021-01-06T12:14:58Z")\
**Posts on this page:** 1\
**Showing post:** 2

<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 7, 2021, 5:21am UTC](https://verificationacademy.com/forums/t/parameterizing-the-bit-widths-of-fields-in-a-packed-struct-so-that-modules-can-infer-bit-width-if-used-in-port-map-virtual-interface-interface-compile-time-configured-struct-bit-width/38548/2 "2021-01-07T05:21:30Z")

</div>

_In reply to [Ian.L.Kennedy](https://verificationacademy.com/forums/t/parameterizing-the-bit-widths-of-fields-in-a-packed-struct-so-that-modules-can-infer-bit-width-if-used-in-port-map-virtual-interface-interface-compile-time-configured-struct-bit-width/38548):_

The current SystemVerilog BNF does not allow any dotted “.” names in a parameter initialization. But you can get around this by using a typedef instead

```verilog
interface MyInterface #(int DATA_W=0, ADDR_W=0) () ;
  typedef logic [DATA_W-1:0] data_t;
  ...
endinterface

module InnerTest 
  ( input wire Clock
  , input wire Reset
  , MyInterface.SNK Sink
  ) ;
 
  typedef Sink.data_t data_t;
  localparam BIT_WIDTH_SINK_DATA = $bits( data_t );
  ...
endmodule

```

---

_[View the full topic](https://verificationacademy.com/forums/t/parameterizing-the-bit-widths-of-fields-in-a-packed-struct-so-that-modules-can-infer-bit-width-if-used-in-port-map-virtual-interface-interface-compile-time-configured-struct-bit-width/38548)._
