Ensure \A_SIGNED is never used with $shiftx
authorXiretza <xiretza@xiretza.xyz>
Fri, 3 Jul 2020 11:13:21 +0000 (13:13 +0200)
committerMarcelina Koƛcielnicka <mwk@0x04.net>
Tue, 18 Aug 2020 17:36:24 +0000 (19:36 +0200)
It has no effect on the output ($shiftx doesn't perform any sign
extension whatsoever), so an attempt to use it should be caught early.

kernel/rtlil.cc
passes/tests/test_cell.cc

index d7d2269422b8a2bb3addc5145fd5ce34560d9976..c56f0dcabe0338b91cc308e1958756ef2053afe9 100644 (file)
@@ -1035,7 +1035,11 @@ namespace {
                        }
 
                        if (cell->type.in(ID($shift), ID($shiftx))) {
-                               param_bool(ID::A_SIGNED);
+                               if (cell->type == ID($shiftx)) {
+                                       param_bool(ID::A_SIGNED, /*expected=*/false);
+                               } else {
+                                       param_bool(ID::A_SIGNED);
+                               }
                                param_bool(ID::B_SIGNED);
                                port(ID::A, param(ID::A_WIDTH));
                                port(ID::B, param(ID::B_WIDTH));
index bdb475d3b3501fd872ff45b16bd757e9952d3ca1..228b6b67afe6f284f9d22a2186252bee468c0fc1 100644 (file)
@@ -264,6 +264,10 @@ static void create_gold_module(RTLIL::Design *design, RTLIL::IdString cell_type,
                cell->setPort(ID::Y, wire);
        }
 
+       if (cell_type.in(ID($shiftx))) {
+               cell->parameters[ID::A_SIGNED] = false;
+       }
+
        if (cell_type.in(ID($shl), ID($shr), ID($sshl), ID($sshr))) {
                cell->parameters[ID::B_SIGNED] = false;
        }