From my previous question (Groups inside structs), after creating typedef structs, I tried to form an interface from 5 different channel signal declarations (the structs).
The struct's form is:
typedef struct {
struct {
logic [1:0] a;
logic [2:0] b;
} in;
struct {
logic [4:0] d;
} out;
} axi_X_ch;
Then I tried the following code:
interface axi_interface ();
//as = axi slave
axi_X_ch as_X;
axi_Y_ch as_Y; //similar to struct axi_X_ch
modport slave ( input as_X.in, as_Y.in,
output as_X.out, as_Y.out);
endinterface
But I get the error
message (ignore the coordinates):
modport slave ( input as_X.in, as_Y.in, output as_X.out, as_Y.out);
|
ncvlog: *E,ILLHIN (demo.sv,177|30): illegal location for a hierarchical name (as_X).
modport slave ( input as_X.in, as_Y.in, output as_X.out, as_Y.out);
|
ncvlog: *E,ILLHIN (demo.sv,177|30): illegal location for a hierarchical name (as_Y).
... (same for the next two output declarations) ...
What am I doing wrong?
Modport items should be variables inside the interface not just part of them. Moreover, you are referencing your modport items as types, not variables:
modport slave ( input axi_X_ch.in, axi_Y_ch.in, output axi_X_ch.out, axi_Y_ch.out);
axi_X_ch
is a type, not a variable.
What you want to achieve can be done by something called "modport expressions" (not sure if all synthesis tools support it).
So, using modport expressions, you can create new port names called X_IN, Y_IN, X_OUT, Y_OUT
:
modport slave ( input .X_IN(as_X.in), .Y_IN(as_Y.in),
output X_OUT(as_X.out), output .Y_OUT(as_Y.out));
EDIT:
If modport expressions are not supported, the closest thing I can think of is:
typedef struct {
logic [1:0] a;
logic [2:0] b;
} t_in;
typedef struct {
logic [4:0] d;
} t_out;
interface axi_interface ();
t_in as_X_in;
t_out as_X_out;
t_in as_Y_in;
t_out as_Y_out;
modport slave ( input as_X_in, as_Y_in,
output as_X_out, as_Y_out);
endinfterface
This loses part of the grouping that you are trying to achieve.