Hi,
I have a packet header that have different types of encoding allowed (around 65 in actual).
Let’s for simplicity take a case of two types of encoding as shown below:-
Ex:-
bit [64] header; //Actual header width
//valid header type_1
header [63:20] field_1_type_1;
header [19:10] field_2_type_1;
header [9:0] field_3_type_1;
//valid header type_2
header [63:20] field_1_type_2;
header [19:13] field_2_type_2;
header [12:9] field_3_type_2;
header [8:0] field_4_type_2;
My current class organisation is as follows:-
//Base Class
class base_tx extends uvm_sequence_item;
rand bit [64] header;
…
//No Constraints are present in this class
…
endclass
//Derived class type_1
class my_tx_1 extends base_tx;
rand bit [44] field_1_type_1;
rand bit [10] field_2_type_1;
rand bit [10] field_3_type_1;
//Some constraints on each of the above fields
…
//Pack functions to assign the field values to header
header[63:20] = field_1_type_1;
header[19:10] = field_2_type_1;
…
endclass
//Derived class type_2
class my_tx_2 extends base_tx;
rand bit [44] field_1_type_2;
rand bit [7] field_2_type_2;
rand bit [4] field_3_type_2;
rand bit [9] field_4_type_2;
//Some constraints on each of the above fields
…
//Pack functions to assign the field values to header
header[63:20] = field_1_type_2;
header[19:13] = field_2_type_2;
…
endclass
I would like to create random sequences consisting of my_tx_1 and my_tx_2.
The problem here is that if I am calling base_tx.randomize(), it is generating invalid stimulus in some cases.
I am able to create random sequences with my_tx_1 and my_tx_2, which are working.
Do I need to change the base class hierarchy to achieve this?
What would be better hierarchical organisation for my application with UVM?
Thanks in advance.
–Bravo