例如,我有一个很长的声明:
$display("input_data: %x,
output_data: %x,
result: %x",
input_data,
output_data,
result);
如何在 Verilog 中将其变为单个语句和多行?
例如,我有一个很长的声明:
$display("input_data: %x,
output_data: %x,
result: %x",
input_data,
output_data,
result);
如何在 Verilog 中将其变为单个语句和多行?
您需要分解带引号的字符串。这是一种方法:
module tb;
initial begin
integer input_data = 1;
integer output_data = 0;
integer result = 55;
$display("input_data: %x " , input_data,
"output_data: %x " , output_data,
"result: %x " , result);
end
endmodule
输出:
input_data: 00000001 output_data: 00000000 result: 00000037
更一般地,您还可以使用字符串连接运算符:
{“字符串 1”、“字符串 2”、“字符串 3”}
来自http://www.asic-world.com/systemverilog/literal_values4.html
string a;
a = "This is multi line comment \
and this is second line";
/*
Outputs:
a = This is multi line comment^M
and this is second line
*/
//您将拥有 ^M 这是换行符的 dos 字符。如果你想避免这种情况,那么应该使用下一个解决方案
string tmg ={" \n" ,
"//periodic signal intf.KEYCONTROL_CLK \n" ,
"fork\n" ,
" begin\n" ,
" the_clock = 0;\n" ,
" forever begin\n" ,
" if(the_clock == 0)\n" ,
" #(5000000/2 * 1ps);\n" ,
" else\n" ,
" #((5000000-5000000/2) * 1ps);\n" ,
" the_clock=~the_clock;\n" ,
" end\n" ,
" end\n" ,
"join_none\n"};
`uvm_info("record_key_control_map_and_record", $sformatf("Start recording of interface if_record_key_control"), UVM_DEBUG);
$fdisplay ( mcd0,tmg);