I'm trying to pass an interface to a module which is an array of interfaces.
interface front_port #(parameter DATA_WIDTH = 4);
logic [DATA_WIDTH - 1 : 0] data;
logic acknowledge;
modport f_interface(input data, output acknowledge);
endinterface
interface front_interface #(parameter NO_OF_IN_PORTS = 3);
front_port front_ports[NO_OF_IN_PORTS]();
endinterface
module A #(parameter NO_OF_IN_PORTS = 3)
(
interface front_port;
);
module testbench;
font_interface #(.NO_OF_IN_PORTS(3)) my_front_interface();
A #(.NO_OF_IN_PORTS(3)) (.front_port(my_front_interface));
endmodule
So, my question is, can the array elements of my_front_interface have different values of DATA_WIDTH. If so, how? In the code defined above all the array elements of my_front_interface have the default DATA_WIDTH of 4.
Thanks
Following from my comments, there seems many compilation errors in the given code. Yet, I have tried to resolve them as per my understanding.
In order to create varying
DATA_WIDTH
instances, the interfacefront_interface
must get information aboutDATA_WIDTH
in various instances. So, adding an array of parameters tofront_interface
entity. The size of that array is determined byNO_OF_IN_PORTS
parameter.Further, you must use
generate
block for creating multiple instances offront_port
. Each instance picks up an element from parameter array offront_interface
entity.I have created following code which overrides the default values of DATA_WIDTH and creates instances with unique data widths.
Output:
Refer this page for passing array of parameters in an entity. Also, SystemVerilog IEEE 1800-2012 Section 27 is helpful for
generate
blocks.Yes, it will create
data
as per DATA_WIDTH only, by default 4 bit.Check the below code, with it's output. (In the code, 2 Interface Arrays with different parameter values,
f & f5
are instantiated in thefront_interface
, to make things more clear.And Output of the Code :