Hi,
I am trying to implement C-SV synchronization via DPI to perform vector matching against the RTL in simulation time.
The C Model generates a set of output vectors, which is intended to be matched against the RTL output vectors, and the matching is to be performed cycle by cycle in HDL simulation time.
The following is how I have constructed the artefact of my DPI communication:
SV Code:
import “DPI-C” context task c_main(input <>);
export “DPI” task c_to_sv;
struct data_t output_sv;
logic [31:0] o_A;
always@(posedge clock) begin
uvm_hdl_read(<HDL path>,o_A);
//Compare output_sv.A against o_A
end
task main;
c_main(); //Imported from C
endtask
task c_to_sv (input int sample, input data_t c_output);
uvm_info($psprintf("WORD: %0d",sample),"Called from C",UVM_LOW);
uvm_info(get_type_name(),$psprintf(“A: %0x”,output.A),UVM_LOW);
output_sv.A = output.A;
endtask
C code:
int c_main ()
{
for( word = 0 ; word < num_words ; word++ )
{
c_func( word,&(c_output[word]) ); //Core C function
c_to_sv(word,&(c_output[word])); //Imported from SV
}
}
My requirement is to halt the C execution after the return of every word/sample and compare the C-returned vector against the HDL output vector obtained on a particular clock edge, before advancing edge for the next vector comparison. However, I find that the C code invariably executes all the samples first before attending to the procedural block execution, due to which the purpose of my setup is lost.
The following is a paper I obtained on the topic being addressed, from another forum:
Can anyone shed some insight on how to make the C and HDL work together in synchronicity?
Thanks and Regards,
AP