I'm trying to use the display function in Verilog to print the 2's complement of a binary number.
E.g. I have the following testbench output being printed:
Test 1 data: input A is 0b'0011010100100100 or 0h'3524 or 13604 ;
Test 2 data: input A is 0b'1101011000001001 or 0h'd609 or 54793 ;
Test 3 data: input A is 0b'0111101100001101 or 0h'7b0d or 31501 ;
And I use the following code to generate that:
$display ("Test %0d data: input A is 0b'%16b or 0h'%4h or %d ;", counter,X,X,X);
But I would like the decimal %d
of the variable to be printed in 2's complement.
So for the middle example 0xd609, the decimal should be -10743 not 54793.
How to do it?