-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor std_fp_div_pipe
primitive to avoid Verilog features not supported by Icarus
#2253
Comments
std_fp_div_pipe
primitive to avoid Verilog features not supported by Icarus
Thanks! I updated the title to point to the specific issue at hand. The first step here will be to figure out what Icarus means by "constant selects". It's something about the |
My immediate guess from the error being thrown is that Icarus does not like the This StackOverflow does something similar to what is done with the bit concatenation with the constant, but using SystemVerilog's |
Ok, after some tinkering, I have narrowed down the problematic expression in the You can run each of these examples with the following one-line command: $ iverilog -g2012 test.v module std_fp_div_pipe #(
parameter WIDTH = 32
) (
input logic [WIDTH-1:0] right,
output logic done
);
logic [WIDTH-1:0] quotient, quotient_next;
logic [WIDTH:0] acc, acc_next;
// always_comb is the problem.
always_comb begin
if (acc >= {1'b0, right}) begin
acc_next = acc - right;
{acc_next, quotient_next} = {acc_next[WIDTH-1:0], quotient, 1'b1};
end else begin
{acc_next, quotient_next} = {acc, quotient} << 1;
end
end
endmodule The command on this minimized version produces the error mentioned above: $ iverilog -g2012 test.v
test.v:13: sorry: constant selects in always_* processes are not currently supported (all bits will be included). If I remove the bit slicing, then the error goes away. module std_fp_div_pipe #(
parameter WIDTH = 32
) (
input logic [WIDTH-1:0] right,
output logic done
);
logic [WIDTH-1:0] quotient, quotient_next;
logic [WIDTH:0] acc, acc_next;
// always_comb is the problem.
always_comb begin
if (acc >= {1'b0, right}) begin
acc_next = acc - right;
// NOTE: [WIDTH-1:0] is gone from acc_next!
{acc_next, quotient_next} = {acc_next, quotient, 1'b1};
end else begin
{acc_next, quotient_next} = {acc, quotient} << 1;
end
end
endmodule The output from this module: $ iverilog -g2012 test.v
$ echo $?
0 |
You can probably rewrite this to used assign test = (acc >= {1'b0, right});
assign true_branch = {acc_next, quotient, 1'b1};
assign false_branch = {acc, quotient} << 1;
assign acc_next = test ? ... : ...; // annoying slicing for `true_branch` and `false_branch`
assign quotient_next = test ? ... : ...; |
We may not even need to go that far, depending on how Calyx uses module std_fp_div_pipe #(
parameter WIDTH = 32
) (
input logic [WIDTH-1:0] right,
output logic done
);
logic [WIDTH-1:0] quotient, quotient_next;
logic [WIDTH:0] acc, acc_next;
// always_comb is the problem.
always @* begin
if (acc >= {1'b0, right}) begin
acc_next = acc - right;
{acc_next, quotient_next} = {acc_next[WIDTH-1:0], quotient, 1'b1};
end else begin
{acc_next, quotient_next} = {acc, quotient} << 1;
end
end
endmodule $ iverilog -g2012 test.v
$ echo $?
0 |
Calyx does not emit always_comb so the only uses are in the standard library. |
I saw that, which means the blast radius of this kind of change will shrink. If I make this change to |
Your best bet is the tests we already run in the CI. If you're suspicious of particular things failing, you can try to write more tests. |
It seems that portions of Calyx's standard library written in SystemVerilog is not able to be simulated by Icarus.
[nix-shell:~/Repos/calyx] 11:12:38 $ iverilog -v Icarus Verilog version 12.0 (stable) () ...
Taking a unit-test circuit from Cider and running it through
fud2
, we get the following plan, which I then execute.The error on line 149 is coming from:
The Calyx component's output Verilog that being simulated is attached below. (It is a .txt to allow me to upload to GitHub.)
verilog-noverify.txt
The text was updated successfully, but these errors were encountered: