Hi everyone, thanks in advance for your help.
I’m working with a 3rd party IP and am trying to randomize a transaction class. I get a runtime error as follows:
** Fatal: Illegal unpacked assignment to type ‘bit’ from packed type ‘bit[31:0]$’.
If I rename my local variable to match the name of the class variables, I no longer get this error. Why?
My code looks basically like this.
class sequence …
bit [AXI4_WDATA_WIDTH-1:0] data_words;
…
task body();
…
if(!write_item.randomize() with {
addr == local::address; // must use local here.
foreach(local::data_words[j])
data_words[j] == local::data_words[j];
}) `uvm_error(“MYERR”, “This is a randomize error”);
finish_item( write_item );
The above code works without error.
If I rename things to be the following, I get the error:
class sequence …
bit [AXI4_WDATA_WIDTH-1:0] write_data_words;
…
task body();
…
if(!write_item.randomize() with {
addr == local::address; // must use local here.
foreach(local::write_data_words[j])
data_words[j] == local::write_data_words[j];
}) `uvm_error(“MYERR”, “This is a randomize error”);
finish_item( write_item );
…
The write_item class has what I believe to be the correct matching type:
rand bit [((AXI4_WDATA_WIDTH) - 1):0] data_words ;
Question
Why can’t I use a different name than the name inside the item being randomized? I thought my ‘local’ scope allow me to specify any local name. The error suggests that the LHS is being interpreted as a bit in the failing case and I assume not a bit, but the proper array size in the passing case.
When used with matching names, my write transaction appears to work correctly.
Thanks for sharing your insight and knowledge, I appreciate it.
Brian