aboutsummaryrefslogtreecommitdiffstats
path: root/bugs/yosys_9.md
diff options
context:
space:
mode:
authorYann Herklotz <git@yannherklotz.com>2019-11-14 16:27:19 +0000
committerYann Herklotz <git@yannherklotz.com>2019-11-14 16:27:19 +0000
commit798f54c05376ec3b4ebbe8326d0a91eec807df3d (patch)
tree29274e92b775d280238ea15e0b46fb545b55b559 /bugs/yosys_9.md
parent809d342084e39432615945edac7662e6f9968b7f (diff)
downloadverismith-798f54c05376ec3b4ebbe8326d0a91eec807df3d.tar.gz
verismith-798f54c05376ec3b4ebbe8326d0a91eec807df3d.zip
Add proper reports to bugs
Diffstat (limited to 'bugs/yosys_9.md')
-rw-r--r--bugs/yosys_9.md78
1 files changed, 78 insertions, 0 deletions
diff --git a/bugs/yosys_9.md b/bugs/yosys_9.md
new file mode 100644
index 0000000..cafdf86
--- /dev/null
+++ b/bugs/yosys_9.md
@@ -0,0 +1,78 @@
+# Unexpected behaviour of for loop and if statement
+
+[ [Issue 1243](https://github.com/YosysHQ/yosys/issues/1243) ]
+
+## Steps to reproduce the issue
+
+Consider the following piece of code:
+
+```verilog
+module top (y, clk, sel);
+ output wire y ;
+ input clk;
+ input sel;
+ reg reg_assign = (1'h0) ;
+ reg [1:0] reg_count = (1'h0) ;
+ assign y = reg_assign ;
+ always @(posedge clk)
+ if (sel)
+ for (reg_count = 0; reg_count < 2; reg_count = reg_count + 1'h1)
+ if (0);
+ else reg_assign <= 1;
+ else reg_assign <= 0;
+endmodule
+```
+
+First of all, the for loop in the code does seem a bit dodgy, however, I would still expect `reg_assign` to be set to 1 when `sel` is high. When `sel` is low, `reg_assign` should then be reset to 0.
+
+However, when synthesised with
+
+```
+Yosys 0.8+618 (git sha1 acd8bc0a, clang -fPIC -Os)
+```
+
+using
+
+```
+yosys -p "read_verilog rtl.v; synth; write_verilog -noattr synth.v"
+```
+
+`reg_assign` is set to a constant 0 instead of to what the value of `sel` is. Removing the dead if statement in the for loop results in the correct behaviour.
+
+I have also attached a folder containing a test bench and SymbiYosys script to compare the design to the synthesised net list.
+
+## Expected behaviour
+
+I would expect this to be implemented by assigning `sel` to `y`. This is actually also the output of a previous version of Yosys (`Yosys 0.8+508 (git sha1 c2ea3746, clang 8.0.0 -fPIC -Os)`)
+
+```verilog
+module top(y, clk, sel);
+ input clk;
+ wire reg_assign;
+ wire [1:0] reg_count;
+ input sel;
+ output y;
+ assign reg_assign = 1'h0;
+ assign reg_count = 2'h0;
+ assign y = sel;
+endmodule
+```
+
+## Actual behaviour
+
+However, with Yosys, `y` is set to a constant 0.
+
+```verilog
+module top(y, clk, sel);
+ input clk;
+ wire reg_assign;
+ wire [1:0] reg_count;
+ input sel;
+ output y;
+ assign reg_assign = 1'h0;
+ assign reg_count = 2'h0;
+ assign y = 1'h0;
+endmodule
+```
+
+[test.zip](https://github.com/YosysHQ/yosys/files/3457004/test.zip)