diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/ice40/div_mod.ys | 2 | ||||
-rw-r--r-- | tests/opt/opt_expr.ys | 14 | ||||
-rw-r--r-- | tests/techmap/dff2dffs.ys | 50 | ||||
-rw-r--r-- | tests/techmap/wireinit.ys | 98 | ||||
-rw-r--r-- | tests/various/abc9.v | 4 | ||||
-rw-r--r-- | tests/various/equiv_opt_multiclock.ys | 12 |
6 files changed, 171 insertions, 9 deletions
diff --git a/tests/ice40/div_mod.ys b/tests/ice40/div_mod.ys index 21cac7144..821d6c301 100644 --- a/tests/ice40/div_mod.ys +++ b/tests/ice40/div_mod.ys @@ -4,6 +4,6 @@ flatten equiv_opt -assert -map +/ice40/cells_sim.v synth_ice40 # equivalency check design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) cd top # Constrain all select calls below inside the top module -select -assert-count 62 t:SB_LUT4 +select -assert-count 59 t:SB_LUT4 select -assert-count 41 t:SB_CARRY select -assert-none t:SB_LUT4 t:SB_CARRY %% t:* %D diff --git a/tests/opt/opt_expr.ys b/tests/opt/opt_expr.ys index ecc2c8da8..e0acead82 100644 --- a/tests/opt/opt_expr.ys +++ b/tests/opt/opt_expr.ys @@ -204,7 +204,7 @@ endmodule EOT check -equiv_opt opt_expr -fine +equiv_opt -assert opt_expr -fine design -load postopt select -assert-count 1 t:$alu r:A_WIDTH=4 r:B_WIDTH=4 r:Y_WIDTH=5 %i %i %i @@ -218,7 +218,7 @@ endmodule EOT check -equiv_opt opt_expr -fine +equiv_opt -assert opt_expr -fine design -load postopt select -assert-count 1 t:$alu r:A_WIDTH=8 r:B_WIDTH=8 r:Y_WIDTH=9 %i %i %i @@ -232,7 +232,7 @@ endmodule EOT check -equiv_opt opt_expr +equiv_opt -assert opt_expr design -load postopt select -assert-count 1 t:$shiftx r:A_WIDTH=3 %i @@ -246,7 +246,7 @@ endmodule EOT check -equiv_opt opt_expr +equiv_opt -assert opt_expr design -load postopt select -assert-count 1 t:$shiftx r:A_WIDTH=12 %i @@ -260,7 +260,7 @@ endmodule EOT check -equiv_opt opt_expr +equiv_opt -assert opt_expr design -load postopt select -assert-count 1 t:$shift r:A_WIDTH=3 %i @@ -274,7 +274,7 @@ endmodule EOT check -equiv_opt opt_expr +equiv_opt -assert opt_expr design -load postopt select -assert-count 1 t:$shift r:A_WIDTH=10 %i @@ -288,6 +288,6 @@ endmodule EOT check -equiv_opt opt_expr -keepdc +equiv_opt -assert opt_expr -keepdc design -load postopt select -assert-count 1 t:$shift r:A_WIDTH=13 %i diff --git a/tests/techmap/dff2dffs.ys b/tests/techmap/dff2dffs.ys new file mode 100644 index 000000000..13f1a3cf3 --- /dev/null +++ b/tests/techmap/dff2dffs.ys @@ -0,0 +1,50 @@ +read_verilog << EOT +module top(...); +input clk; +input d; +input sr; +output reg q0, q1, q2, q3, q4, q5; + +initial q0 = 1'b0; +initial q1 = 1'b0; +initial q2 = 1'b1; +initial q3 = 1'b1; +initial q4 = 1'bx; +initial q5 = 1'bx; + +always @(posedge clk) begin + q0 <= sr ? 1'b0 : d; + q1 <= sr ? 1'b1 : d; + q2 <= sr ? 1'b0 : d; + q3 <= sr ? 1'b1 : d; + q4 <= sr ? 1'b0 : d; + q5 <= sr ? 1'b1 : d; +end + +endmodule +EOT + +proc +simplemap +design -save ref + +dff2dffs +clean + +select -assert-count 1 w:q0 %x t:$__DFFS_PP0_ %i +select -assert-count 1 w:q1 %x t:$__DFFS_PP1_ %i +select -assert-count 1 w:q2 %x t:$__DFFS_PP0_ %i +select -assert-count 1 w:q3 %x t:$__DFFS_PP1_ %i +select -assert-count 1 w:q4 %x t:$__DFFS_PP0_ %i +select -assert-count 1 w:q5 %x t:$__DFFS_PP1_ %i + +design -load ref +dff2dffs -match-init +clean + +select -assert-count 1 w:q0 %x t:$__DFFS_PP0_ %i +select -assert-count 0 w:q1 %x t:$__DFFS_PP1_ %i +select -assert-count 0 w:q2 %x t:$__DFFS_PP0_ %i +select -assert-count 1 w:q3 %x t:$__DFFS_PP1_ %i +select -assert-count 1 w:q4 %x t:$__DFFS_PP0_ %i +select -assert-count 1 w:q5 %x t:$__DFFS_PP1_ %i diff --git a/tests/techmap/wireinit.ys b/tests/techmap/wireinit.ys new file mode 100644 index 000000000..1396839fe --- /dev/null +++ b/tests/techmap/wireinit.ys @@ -0,0 +1,98 @@ +read_verilog <<EOT +(* techmap_celltype = "$_DFF_P_" *) +module ffmap(...); +input D; +input C; +output Q; +parameter [0:0] _TECHMAP_WIREINIT_Q_ = 1'bx; + +ffbb #(.INIT(_TECHMAP_WIREINIT_Q_)) _TECHMAP_REPLACE_(.D(D), .Q(Q), .C(C)); + +wire _TECHMAP_FAIL_ = _TECHMAP_WIREINIT_Q_ === 1'b1; + +wire _TECHMAP_REMOVEINIT_Q_ = 1'b1; + +endmodule +EOT +design -stash map + +read_verilog <<EOT +(* techmap_celltype = "$_DFF_P_" *) +module ffmap(...); +input D; +input C; +output Q; +parameter [0:0] _TECHMAP_WIREINIT_Q_ = 1'bx; + +ffbb #(.INIT(_TECHMAP_WIREINIT_Q_)) _TECHMAP_REPLACE_(.D(D), .Q(Q), .C(C)); + +wire _TECHMAP_FAIL_ = _TECHMAP_WIREINIT_Q_ === 1'b1; + +wire _TECHMAP_REMOVEINIT_Q_ = 1'b0; + +endmodule +EOT +design -stash map_noremove + +read_verilog <<EOT +module ffbb (...); +parameter [0:0] INIT = 1'bx; +input D, C; +output Q; +endmodule + +module top(...); +input clk; +input d; +output reg q0 = 0; +output reg q1 = 1; +output reg qx; + +always @(posedge clk) begin + q0 <= d; + q1 <= d; + qx <= d; +end +endmodule +EOT + +design -save ref + +hierarchy -auto-top +proc +simplemap +techmap -map %map +clean +# Make sure the parameter was used properly. +select -assert-count 2 top/t:ffbb +select -set ff0 top/w:q0 %ci t:ffbb %i +select -set ffx top/w:qx %ci t:ffbb %i +select -assert-count 1 @ff0 +select -assert-count 1 @ffx +select -assert-count 1 @ff0 r:INIT=1'b0 %i +select -assert-count 1 @ffx r:INIT=1'bx %i +select -assert-count 0 top/w:q1 %ci t:ffbb %i +# Make sure the init values are dropped from the wires iff mapping was performed. +select -assert-count 0 top/w:q0 a:init %i +select -assert-count 1 top/w:q1 a:init=1'b1 %i +select -assert-count 0 top/w:qx a:init %i + +design -load ref +hierarchy -auto-top +proc +simplemap +techmap -map %map_noremove +clean +# Make sure the parameter was used properly. +select -assert-count 2 top/t:ffbb +select -set ff0 top/w:q0 %ci t:ffbb %i +select -set ffx top/w:qx %ci t:ffbb %i +select -assert-count 1 @ff0 +select -assert-count 1 @ffx +select -assert-count 1 @ff0 r:INIT=1'b0 %i +select -assert-count 1 @ffx r:INIT=1'bx %i +select -assert-count 0 top/w:q1 %ci t:ffbb %i +# Make sure the init values are not dropped from the wires. +select -assert-count 1 top/w:q0 a:init=1'b0 %i +select -assert-count 1 top/w:q1 a:init=1'b1 %i +select -assert-count 0 top/w:qx a:init %i diff --git a/tests/various/abc9.v b/tests/various/abc9.v index a08b613a8..30ebd4e26 100644 --- a/tests/various/abc9.v +++ b/tests/various/abc9.v @@ -5,5 +5,7 @@ always @* endmodule module abc9_test028(input i, output o); -unknown u(~i, o); +wire w; +unknown u(~i, w); +unknown2 u2(w, o); endmodule diff --git a/tests/various/equiv_opt_multiclock.ys b/tests/various/equiv_opt_multiclock.ys new file mode 100644 index 000000000..81e36d018 --- /dev/null +++ b/tests/various/equiv_opt_multiclock.ys @@ -0,0 +1,12 @@ +read_verilog <<EOT +module top(input clk, pre, d, output reg q); + always @(posedge clk, posedge pre) + if (pre) + q <= 1'b1; + else + q <= d; +endmodule +EOT + +prep +equiv_opt -assert -multiclock -map +/simcells.v synth |