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 make the transaction parameterized as this will add significant complexity to using the transactions. Instead, make the address the maximum width needed. Only the required number of bits will be driven on the interface.
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.
Yes , I think your method is feasible, but it still add complexity about scoreboard. How about parameterized class ? I would like to use this VIP for 2 or more places in my environment in which there are different address width.
Yes, I try this way before. But I would like to use this VIP for 2 or more places in my environment in which there are different address width. How to resolve this problem if I use your method ?
As I said, the address width should be the biggest width that is supported by the interface. For example, if you can support 8, 16, or 32 bit addresses, use 32 bits in the transaction. In the driver, only the required bits will be driven on the interface.
In reply to chr_sue:
Yes, I try this way before. But I would like to use this VIP for 2 or more places in my environment in which there are different address width. How to resolve this problem if I use your method ?
Because your parameters should be in package which is not local to your agent, but local to your project, you can put in there any parameter.
I’m still confused that how to reuse the VIP.In fact, my parameters package is local to my project. But my agent how to use different parameters ? Can you write an example ?
For example:
In your example you really need parameterized interface. In the Class-based environment you have to make sure you are using exactly the sam specification for the Virtual interface as you are using in the toplevel module. There is no typedef vor a SV interface possible. Looks like a weakness in SV.