diff --git a/passes/pmgen/peepopt_muldiv_c.pmg b/passes/pmgen/peepopt_muldiv_c.pmg index a24e47b8cd8..411ff3122ff 100644 --- a/passes/pmgen/peepopt_muldiv_c.pmg +++ b/passes/pmgen/peepopt_muldiv_c.pmg @@ -19,9 +19,8 @@ code a b_const mul_y mul_y = port(mul, \Y); // Fanout of each multiplier Y bit should be 1 (no bit-split) - for (auto bit : mul_y) - if (nusers(bit) != 2) - reject; + if (nusers(mul_y) != 2) + reject; // A and B can be interchanged branch; diff --git a/passes/pmgen/peepopt_muxadd.pmg b/passes/pmgen/peepopt_muxadd.pmg index 7f114c93ee2..856875e3f63 100644 --- a/passes/pmgen/peepopt_muxadd.pmg +++ b/passes/pmgen/peepopt_muxadd.pmg @@ -6,17 +6,19 @@ pattern muxadd // state add_a add_b add_y +state add_a_signed +state add_a_id match add // Select adder select add->type == $add choice A {\A, \B} - define B (A == \A ? \B : \A) - set add_y port(add, \Y) - set add_a port(add, A) - set add_b port(add, B) - set add_a_signed param(add, (A == \A) ? \A_SIGNED : \B_SIGNED)) - set add_a_id A + define B (A == \A ? \B : \A) + set add_y port(add, \Y) + set add_a port(add, A) + set add_b port(add, B) + set add_a_signed param(add, (A == \A) ? \A_SIGNED : \B_SIGNED) + set add_a_id A endmatch code add_y add_a add_b @@ -26,8 +28,8 @@ code add_y add_a add_b add_y = port(add, \Y); // Fanout of each adder Y bit should be 1 (no bit-split) - if (nusers(add_y) != 2) - reject; + if (nusers(add_y) != 2) + reject; // A and B can be interchanged branch; @@ -37,7 +39,7 @@ endcode match mux // Select mux of form s ? (a + b) : a, allow leading 0s when A_WIDTH != Y_WIDTH select mux->type == $mux - index port(mux, \A) === SigSpec({Const(State::S0, GetSize(add_y)-GetSize(add_a)), add_a}) + index port(mux, \A) === SigSpec({Const(!param(add, \A_SIGNED).bool() ? () : State::S0, GetSize(add_y)-GetSize(add_a)), add_a}) index port(mux, \B) === add_y endmatch