|
From: Martin W. <mai...@ma...> - 2016-03-14 20:30:09
|
Hello Larry,
Extracting the rounded_down_power_of_two function from the output of vhdlpp and converting to a
simple SystemVerilog test case gives:
module test();
function int rounded_down_power_of_two(input int value);
int n = 32'd0;
int temp = value;
while (temp > 32'd1) begin
temp = temp / 32'd2;
n = n + 32'd1;
end
return n;
endfunction
localparam value = rounded_down_power_of_two(34);
initial begin
$display("%d", value);
end
endmodule
This is illegal, because the standard says:
"Variables declared in a static task, function, or procedural block default to a static lifetime and
a local scope. However, an explicit static keyword shall be required when an initialization value is
specified as part of a static variable’s declaration to indicate the user’s intent of executing that
initialization only once at the beginning of simulation."
(at least the 2012 standard does - I haven't checked earlier versions).
It appears Icarus silently accepts static initialisation, and doesn't currently support
static/automatic overrides on variable declarations.
Declaring the function as automatic should work round this problem, but it appears this is broken too.
Martin
P.S. I think there is another issue with the converted function - vhdlpp has output unsigned literal
values, whereas I think they should be signed values.
Larry Doolittle wrote:
> Friends -
>
> See attached test case for VHDL functions, which fails because the
> width of bit_counter comes out as 1, not 4. I'd like to thank
> Maciej for huge strides towards making this work! This has turned
> into a SystemVerilog question. With all the recent changes in
> iverilog git master, I thought I should check if the problem is
> still present. It is.
>
> It's a pretty small tar file, 3122 bytes spread across 7 files.
> If you bypass the use of next_highest_power_of_two() in use_func.vhd,
> you get
> $ make
> iverilog -Wall -Wno-timescale -g2005-sv -civhdl.cfg -o use_func_tb use_func_tb.v use_func.vhd
> vvp -n use_func_tb | awk -f testcode.awk
> 3 PASS
> But with the buggy next_highest_power_of_two() call in place,
> out-of-the-tarball, you get
> $ make
> iverilog -Wall -Wno-timescale -g2005-sv -civhdl.cfg -o use_func_tb use_func_tb.v use_func.vhd
> vvp -n use_func_tb | awk -f testcode.awk
> 20 FAIL
> make: *** [use_func_check] Error 1
>
> Back on 28 Jan 2016, when I discussed this with Maciej,
> he discovered that if you change the following line:
> int \temp = \value ;
> to
> int \temp ; \temp = \value ;
> in the generated code, function next_highest_power_of_two(), then it
> works correctly. The question is if Icarus' SystemVerilog processing
> should be fixed, or ivlpp should stop emitting broken SystemVerilog.
>
> - Larry
>
>
>
> ------------------------------------------------------------------------------
> Transform Data into Opportunity.
> Accelerate data analysis in your applications with
> Intel Data Analytics Acceleration Library.
> Click to learn more.
> http://pubads.g.doubleclick.net/gampad/clk?id=278785111&iu=/4140
>
>
>
> _______________________________________________
> Iverilog-devel mailing list
> Ive...@li...
> https://lists.sourceforge.net/lists/listinfo/iverilog-devel
>
|