我使用 DPI 从 C 函数返回一个字符串到 SystemVerilog。
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();
}
在 SystemVerilog 方面:
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
结果:有时结果是这样的:
w=1, h=3f, p=2f, ...mtail=0ã
有时我得到这个:
w=1, h=3f, p=2f, ...mtailº
我检查了 verilog 端的波形,它们是 NO X 传播。你能帮我理解为什么我得到这个错误。