hi all,
I have a C_DPI export in my top-level module and when C side test bench invokes this DPI I want to pump some traffic to my DUT through an agent which is sitting inside class based verification env. can anyone suggest a way to have this trigger mechanism possible? based on other answers in the forum we cant access C-DPI inside classes than how do we trigger our agent to pump traffic.
driver is a class based component you mean to say i can have C_DPI export in my class based verification env ?
to explain situation better i will take a example
basically i have a C side testbench which will call a READ function this function inturn will invoke a C_DPI which is being exported from sv side. so when this gets invoked i will have to ask my agent to issue a read and send the read data back to this C_DPI.
In reply to pawan:
You still provide too little information, as usual. We don’t understand the timing of your C based code in relation to your class based testbench. Are you using only functions to import/export to DPI or tasks?
You can certainly have class based methods get called from C by using wrappers (Same as you would between C and C++). You can export a non-class task/function that has a handle to the class method either stored statically, or looks it up. Then when called, it calls the class method using the handle as a reference.
In reply to pawan:
You still provide too little information, as usual. We don’t understand the timing of your C based code in relation to your class based testbench. Are you using only functions to import/export to DPI or tasks?
You can certainly have class based methods get called from C by using wrappers (Same as you would between C and C++). You can export a non-class task/function that has a handle to the class method either stored statically, or looks it up. Then when called, it calls the class method using the handle as a reference.
i am using tasks and hence the confusion.
basically, consider this scenario. i have a C-DPI export in my top level module and its a read task. in my RTL i have a apb protocol which is connected to a apb master vip and we issue read and write through apb agent. now how do i invoke read/write tasks of my agent from this module where C-DPI taks have been exported.
Still not enough information, but this forum may not be suitable for a detailed discussion. You may want to contact your tool vendor for better support.
Here is a sketch of what you could do
module hvl_top;
export "DPI-C" task exported_dpi_routine
task exported_dpi_routine(args);
static agent_class agent_h;
if (agent_h == null) begin
// get handle on first use - with uvm_config_db or uvm_root::find()
...
end
agent_h.agent_routine(args);
endtask