I have a small program below. I understand the results from the first 2 statements inside the initial block. But I am not able to understand the last $display statement. How did it yield 'hff_ffff_ffff? I thought it should give the same result as in the first $display ('hffff_ffff). I am not sure what I am missing here.
typedef bit unsigned [63 : 0] my_type;
int unsigned addr_width = 40;
initial begin
$display("A: $bits((1 << addr_width)-1) = %0d\n ((1 << addr_width) -1) ='h%0h\n",
$bits( (1 << addr_width) -1 ),
(1 << addr_width) -1);
$display("B: $bits( 64'd1 << addr_width) = %0d\n ((64'd1 << addr_width) -1) ='h%0h\n",
$bits( 64'd1 << addr_width),
( 64'd1 << addr_width) -1);
$display("C: $bits( my_type'( ((1 << addr_width)-1)) ) = %0d\n my_type'( ((1 << addr_width)-1)) = 'h%0h\n",
$bits( my_type'( ((1 << addr_width)-1)) ),
my_type'( ((1 << addr_width)-1)));
end
Simulation results:
A: $bits((1 << addr_width)-1) = 32
((1 << addr_width) -1) ='hffffffff
B: $bits( 64’d1 << addr_width) = 64
((64’d1 << addr_width) -1) ='hffffffffff
C: $bits( my_type’( ((1 << addr_width)-1)) ) = 64
my_type’( ((1 << addr_width)-1)) = 'hffffffffff