shiftx2mux: fix select out of bounds
authorEddie Hung <eddie@fpgeh.com>
Thu, 6 Feb 2020 00:41:09 +0000 (16:41 -0800)
committerEddie Hung <eddie@fpgeh.com>
Thu, 6 Feb 2020 00:41:09 +0000 (16:41 -0800)
techlibs/common/techmap.v
tests/techmap/run-test.sh
tests/techmap/shiftx2mux.ys

index 75a51e55e17fdf3aff77bb453210dcd4652558ef..be6530eb4367118f768ee1fd2ce39321e65fe400 100644 (file)
@@ -152,10 +152,11 @@ module _90_shift_shiftx (A, B, Y);
                        localparam len = 2**(B_WIDTH-1);
                        localparam Y_WIDTH2 = 2**CLOG2_Y_WIDTH;
                        wire [len-1:0] T, F, AA;
+                       wire [(A_WIDTH+Y_WIDTH2*2):0] Apad = {{Y_WIDTH2*2{extbit}}, A};
                        genvar i;
                        for (i = 0; i < A_WIDTH; i=i+Y_WIDTH2*2) begin
                                assign F[i/2 +: Y_WIDTH2] = A[i +: Y_WIDTH2];
-                               assign T[i/2 +: Y_WIDTH2] = (i + Y_WIDTH2 < A_WIDTH) ? A[i+Y_WIDTH2 +: Y_WIDTH2] : {Y_WIDTH2{extbit}};
+                               assign T[i/2 +: Y_WIDTH2] = Apad[i+Y_WIDTH2 +: Y_WIDTH2];
                                assign AA[i/2 +: Y_WIDTH2] = B[CLOG2_Y_WIDTH] ? T[i/2 +: Y_WIDTH2] : F[i/2 +: Y_WIDTH2];
                        end
                        wire [B_WIDTH-2:0] BB = {B[B_WIDTH-1:CLOG2_Y_WIDTH+1], {CLOG2_Y_WIDTH{1'b0}}};
index 96489ff155c0c5118af8e6fa4c2a1231f1dc4212..c16f204d9708ae9e9cbc012084a48d9ee97d782e 100755 (executable)
@@ -6,7 +6,7 @@ for x in *.ys; do
        echo "all:: run-$x"
        echo "run-$x:"
        echo "  @echo 'Running $x..'"
-       echo "  @../../yosys -ql ${x%.ys}.log $x"
+       echo "  @../../yosys -ql ${x%.ys}.log -e 'select out of bounds' $x"
 done
 for s in *.sh; do
        if [ "$s" != "run-test.sh" ]; then
index c13b5f600baf9ee635980056b01a2bd55a297b56..eb29680f6659ea98e40cf3e7290dca1783c09e80 100644 (file)
@@ -108,3 +108,14 @@ design -import gate -as gate
 miter -equiv -flatten -make_assert -make_outputs gold gate miter
 sat -verify -prove-asserts -show-ports miter
 
+
+design -reset
+read_verilog <<EOT
+module top(input [6:0] A, input [1:0] B, output [1:0] Y);
+wire [7:0] AA = {1'bx, A};
+assign Y = AA[B*2 +: 2];
+endmodule
+EOT
+opt
+wreduce
+equiv_opt techmap