Assigning values to Struct of Vectors in Bluespec SV

216 views Asked by At
typedef struct {
    Vector#(4, INDEX)             index;
    Vector#(2, TAG1)     comp_tag1_table;
    Vector#(2, TAG2)     comp_tag2_table;
   } Prediction_Packet deriving(Bits, Eq, FShow);
Prediction_Packet pred_pkt <- mkReg(unpack(0)); 

In the above BSV code, I need to assign values to comp_tag1_table (having 2 entries of TAG1 data type) and comp_tag2_table (having 2 entries of TAG2 data type).

I have tried using...something like... pred_pkt.comp_tag1_table[ti] <= 8'b101 where ti can be 0 or 1 but that doesn't seem to solve the problem. It can't be an array I guess.

2

There are 2 answers

0
aswathy On

pred_pkt.comp_tag1_table[ti] = 8'b0101; can be used if its a variable. Ofcourse its a variable.

<= is used in the case of assigning values to registers.

0
Jamey Hicks On

BSV does not support updating a field or element of a register. If pred_pkt is a register, then you could do:

let new_pred_pkt = pred_pkt;
new_pred_pkt.comp_tag1_table[ti] = 8'b101;
pred_pkg <= new_pred_pkt;