1

I have a register map which is generated with a script. The output of the module is one huge packed struct. This is normally not a problem, but when I lint my code I get warnings like this:

*W,UNCONO (./module_name.v,158):: 'reg[1415]' is not connected.

So I can see that one of my register bits isn't getting used, which is bad, but which one is it? How do I map the bit position in the packed struct back to the named struct member?

To clarify I am looking for a function of some sort that will take a bit position as input and returns the struct member name as an output.

nguthrie
  • 2,615
  • 6
  • 26
  • 43

1 Answers1

0

In a packed struct, the bits are numbered right to left, 0 to N-1. So, if you have

typedef struct packed {
logic sign;
logic [7:0] exponent;
logic [22:0] mantissa;
} Float32;

Float32 F;

then

assert (F.sign === F[31]);
assert (F.exponent === F[30:23]);
assert (F.mantissa === F[22:0]);
Matthew Taylor
  • 13,365
  • 3
  • 17
  • 44
  • 1
    Yes, I understand that, but in this case my structure has thousands of elements so I'm not sure of an easy way to map bit #1415 to a member of the struct without counting. – nguthrie Mar 26 '16 at 20:52