How to define transaction class when I used parameterized interface?

In reply to aluowell:

Hi,
I’m writting a VIP used parameterized interface. The address width of interface is configurable.
I learned the chapter ParameterizedTests in UVM Cookbook and implemented the parameterized interface by using config_db API.
But the question is how to define transaction class ? Because the address width is configurable. It seems the driver couldn’t be reused.
like:
module top;

a_bus#(.addr_width(4)) bus0;
a_bus#(.addr_width(8)) bus1;// or 16,32,64 width

endmodule
class bus_driver extends uvm_driver#(bus_transaction);
virtual a_bus v_a_bus;

function void run_phase(phase);
bus_transaction bus_tr;

v_a_bus <= bus_tr.addr;

endfunction
endclass
class bus_transaction extend uvm_sequence_item;

logic[3:0] addr;//if I define like this,this VIP can’t reused by other address width
// or define like logic[7:0] addr;
// but it’s not flexible

endclass
So how to define the transaction class can be flexible ?

I would not define the interface and the transaction parameterized. Put your parameters in a package, like DATA_WIDTH0 = 8, DARA_WIDTH1=16, etc. In each place you need these parameters import the corresponding package. Than all things are fine.