例如,我有一个长语句:
$display("input_data: %x,
output_data: %x,
result: %x",
input_data,
output_data,
result);
如何在Verilog中将它变成单个语句和多行?
答案 0 :(得分:9)
你需要拆分引用的字符串。这是一种方式:
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
/*
Outputs:
input_data: 00000001 output_data: 00000000 result: 00000037
*/
答案 1 :(得分:3)
更一般地说,您还可以使用字符串连接运算符:
{" string1"," string2"," string3"}
答案 2 :(得分:1)
来自http://www.asic-world.com/systemverilog/literal_values4.html
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
///您将拥有^ M,它是新行的dos字符。如果要避免这种情况,则应使用下一个解决方案
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
*/