How do I print a signed integer value stored in an 8 bit register declared as
reg [7:0] acc;
Using
$display("acc : %d", acc)
It prints the unsigned value.
Whats the correct syntax for the $display function ?
How do I print a signed integer value stored in an 8 bit register declared as
reg [7:0] acc;
Using
$display("acc : %d", acc)
It prints the unsigned value.
Whats the correct syntax for the $display function ?
If you declare the
reg
assigned
,$display
will show the minus sign:Ran into this problem as well and looked through the SystemVerilog 2012 standard, but didn't see any mention of signedness in the section about format specifiers. Here's an alternative (basically equivalent) solution that also works:
The "$signed" function converts the input value into a signed type with the same bitwidth.