A print error with the description

Status
Not open for further replies.

ruwan2

Member level 5
Joined
Nov 29, 2011
Messages
90
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Visit site
Activity points
2,141
Hi,

The following lines has a print value: 1431655761, while the picture shows that it is 21841.





Code:
[COLOR="#0000CD"]


integer intA;
reg [15:0] regA;

intA = -4'd12 / 3;
$display ("\$display: A4 = %b, A4 = %d", intA, intA); // 

step
# $display: A4 = 01010101010101010101010101010001, A4 =  1431655761[/COLOR]



What is wrong? My code or the description?

Thanks,
 
Last edited:

integers are always 32-bits.

Try this out.
Code:
module test1 ();

integer intA;
reg [15:0] intB;
reg [15:0] regA;

initial begin
  intA = -4'd12 / 3;
  intB = -4'd12 / 3;
  $display ("\$display: A4 = %b, A4 = %d", intA, intA); // 
  $display ("\$display: B4 = %b, B4 = %d", intB, intB); // 
end

endmodule

If the value is correctly defined as 16 bits you get the answer in the picture.

Regards
 
Reactions: ruwan2

    ruwan2

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…