I defined a package like below.
package my_reg_struct_pkg;
typedef struct packed {
logic [3:0] reserved;
logic [3:0] enable;
logic [7:0] x_index;
logic [7:0] y_index;
logic [7:0] z_index;
} my_reg_s;
typedef union packed {
logic [31:0] val;
my_reg_s f;
} my_reg_u;
my_reg_u reg0;
reg0.val = 0; // every reg default is 0
...
...
endpackage :my_reg_struct_pkg
and then in my test I import this package and try to use the variable inside it. But doesn’t work. The failure information is “Cross-module reference resolution error”
Below is the tests_pkg file content.
package tests_pkg;
import uvm_pkg::*;
import my_reg_struct_pkg::*;
...
...
`include "my_test.svh"
endpackage : tests_pkg
below is my_test.svh file content
class my_test extends uvm_test;
...
...
reg0.f.enable = 4'h1;
...
...
...
endclass
However if I moved the ‘reg0.val = 0’ from package to my_test.svh, then it works… But I have no idea about it.