3

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?

Community
  • 1
  • 1
user2692669
  • 461
  • 8
  • 23

1 Answers1

1

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.

Ari
  • 7,251
  • 11
  • 40
  • 70
  • sorry there was a typo in my example (I used `as_X` not `axi_X_ch` ). I tried the solution and I got `ncvlog: *E,MODPXE (test.sv,177|30): Unsupported modport expression for port identifier 'X_IN'.`. If I can't solve this with these structs, is there another way to reconstruct my AXI channels so I put together a nice and neat Interface? – user2692669 Oct 10 '14 at 18:54
  • Wow, with axi that means 10 groups... Overkill? – user2692669 Oct 10 '14 at 19:08
  • You can put them in an array – Ari Oct 10 '14 at 19:13
  • Sorry, I don't follow: put what in an array? (each channel has different signals). – user2692669 Oct 10 '14 at 19:18
  • I was thinking of an array of `t_in` and `t_out`. For example: `t_m [4:0] INS` and `t_m [4:0] OUTS` – Ari Oct 10 '14 at 19:27
  • I think this would get even more complicated. I've decided to just split the signals just to inputs and outputs and seperate them with newlines and placing comment titles between them. – user2692669 Oct 10 '14 at 19:33