Reputation: 545
I have a lower level module that implements an array of interfaces. At a higher level I would like to break out that interface array and assign it to individual ports (the code is just an example . . . no special functionality intended).
// -------- INTERFACE --------
interface my_if;
logic d;
endinterface
// -------- INTERMEDIATE MODULE --------
module intermediate(
my_if i1,
my_if i2
);
sub mySub(
.a ('{i1,i2}),
.w1 (1'b1)
);
endmodule
// -------- SUB MODULE --------
module sub(
my_if a[2],
input wire w1
);
assign a[0].d = w1;
assign a[1].d = ~w1;
endmodule
The above code gives me an error:
The interface port 'a' of module 'sub' whose type is interface 'my_if' is illegally connected.
Two questions:
Upvotes: 1
Views: 1549
Reputation: 42616
This is not allowed in SystemVerilog. There is a real problem with interfaces in that you cannot compose one interface from a collection of other interfaces.
The only workaround is using assign
statements that would connect the signals in an individual interface ports to the signals in the array of interface signals.
You would be better of not using interface and perhaps use a struct instead.
Upvotes: 1