%s 与 %0s在 verilog中的区别

2025-09-19 03:03:09

what is different between %s and %0s?(%s和%零s)

%s prints the string as it is with spaces at the begining if string contents

are less than string variable size.

whereas %0s supress printing spaces.

(如果字符串的内容小于字符串变量的尺寸,%s打印字符串时前面会添加空格;而%0s不会添加空格(字符串顶头打印))

Here is an example. Hope this helps!

Code:

module test();

reg [10*8:0] str = "hello";

initial begin

$display("%s", str);

$display("%0s", str);

end

endmodule // test