Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

A print error with the description

Status
Not open for further replies.

ruwan2

Member level 5
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]

4d12.PNG

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
 
  • Like
Reactions: ruwan2

    ruwan2

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top