aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorUdi Finkelstein <github@udifink.com>2018-03-09 10:35:33 +0200
committerUdi Finkelstein <github@udifink.com>2018-03-11 23:09:34 +0200
commit2b9c75f8e372f6886e073743d1df11bcd1c58281 (patch)
tree756704366060541ff047db59878e059971503ec6 /tests
parentefaef82f75d8e477baf958eac39f538e6eed5b03 (diff)
downloadyosys-2b9c75f8e372f6886e073743d1df11bcd1c58281.tar.gz
yosys-2b9c75f8e372f6886e073743d1df11bcd1c58281.tar.bz2
yosys-2b9c75f8e372f6886e073743d1df11bcd1c58281.zip
This PR should be the base for discussion, do not merge it yet!
It correctly detects reg/wire mix and incorrect use on blocking,nonblocking assignments within blocks and assign statements. What it DOES'T do: Detect registers connected to output ports of instances. Where it FAILS: memorty nonblocking assignments causes spurious (I assume??) errors on yosys-generated "_ADDR", "_DATA", "EN" signals. You can test it with tests/simple/reg_wire_error.v (look inside for the comments to enable/disable specific lines)
Diffstat (limited to 'tests')
-rw-r--r--tests/simple/reg_wire_error.v40
1 files changed, 40 insertions, 0 deletions
diff --git a/tests/simple/reg_wire_error.v b/tests/simple/reg_wire_error.v
new file mode 100644
index 000000000..ab461b95a
--- /dev/null
+++ b/tests/simple/reg_wire_error.v
@@ -0,0 +1,40 @@
+module sub_mod(input i_in, output o_out);
+assign o_out = i_in;
+endmodule
+
+module test(i_clk, i_reg, o_reg, o_wire);
+input i_clk;
+input i_reg;
+output o_reg;
+output o_wire;
+
+// Enable this to see how it doesn't fail on yosys although it should
+//reg o_wire;
+// Enable this instead of the above to see how logic can be mapped to a wire
+logic o_wire;
+// Enable this to see how it doesn't fail on yosys although it should
+//reg i_reg;
+// Disable this to see how it doesn't fail on yosys although it should
+reg o_reg;
+
+logic l_reg;
+
+// Enable this to tst if logic-turne-reg will catch assignments even if done before it turned into a reg
+//assign l_reg = !o_reg;
+initial o_reg = 1'b0;
+always @(posedge i_clk)
+begin
+ o_reg <= !o_reg;
+ l_reg <= !o_reg;
+end
+
+assign o_wire = !o_reg;
+// Uncomment this to see how a logic already turned intoa reg can be freely assigned on yosys
+//assign l_reg = !o_reg;
+
+sub_mod sm_inst (
+ .i_in(1'b1),
+ .o_out(o_reg)
+);
+endmodule
+