打印存储在 reg 类型变量中的有符号整数值 [英] Printing signed integer value stored in a variable of type reg
本文介绍了打印存储在 reg 类型变量中的有符号整数值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何打印存储在声明为的 8 位寄存器中的有符号整数值:
How do I print a signed integer value stored in an 8-bit register declared as:
reg [7:0] acc;
使用:
$display("acc : %d", acc)
打印无符号值.
$display
函数的正确语法是什么?
What's the correct syntax for the $display
function?
推荐答案
如果您将 reg
声明为 signed
,$display
将显示减号:
If you declare the reg
as signed
, $display
will show the minus sign:
module tb;
reg signed [7:0] acc;
initial begin
acc = 8'hf0;
$display("acc : %d", acc);
end
endmodule
打印出来:
acc : -16
这篇关于打印存储在 reg 类型变量中的有符号整数值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文