Menu

#1009 Parameter no set correctly

devel
open
nobody
None
7
2016-11-25
2016-11-18
Arie Peled
No

As the number of bits of a is known at compile time i expected that the value of WIDTH will be 32 and not 0.

i usef the following command line with version 10.1 compiler:
iverilog test1.v

module test1();

reg [31:0] a;
parameter WIDTH=$bits(a);
reg [7:0] b;

initial
begin
b=$bits(a);

$display("a has %d bits,WIDTH=%d, b is %d",$bits(a),WIDTH,b);
$finish;
 end

endmodule

Actual output:

a has 32 bits,WIDTH= 0, b is 32

best regards,
Arie

Discussion

  • Martin Whitaker

    Martin Whitaker - 2016-11-25
    • Group: v10 --> devel
    • Priority: 5 --> 7
     
  • Martin Whitaker

    Martin Whitaker - 2016-11-25

    Setting priority to 7, as this is an incorrect result without any obvious workaround. But it's not obvious how to fix it. The problem is that parameters are evaluated early in the compilation, before the width of variables is calculated.

    Setting the target to devel, as that's where it will be fixed first.

     

Log in to post a comment.