I am returning a string from C function to SystemVerilog using DPI.
const char* print_input_dpi(int w, int h, int p, ......int mtail){
std::stringstream ss;
ss<<"w="<<std::hex<<w<<" ";
ss<<"h="<<std::hex<<h<<" ";
ss<<"p="<<std::hex<<p<<" ";
...
ss<<"mtail="<<std::hex<<mtail<<" ";
return (char*)ss.str().c_str();
}
On the SystemVerilog side:
string formatted_string;
always @* begin
if(en) begin
formatted_string = print_input_dpi(w,h,p,...mtail)l
end
...
always @(nededge sclk) begin
$fdisplayb(log_file, "", formatted_string)
end
Result: sometimes the result is like this:
w=1, h=3f, p=2f, ...mtail=0ã
sometimes i get this:
w=1, h=3f, p=2f, ...mtailº
I checked the waveforms on the verilog side and they is NO X propagation. Can you please help me understand why I get this error.