3
0
Fork 0
mirror of https://github.com/YosysHQ/yosys synced 2025-05-16 12:14:46 +00:00

Add muldiv_c peepopt pass

This commit is contained in:
Akash Levy 2025-04-30 08:06:59 -07:00
parent bfe05965f9
commit 4bd91fbb11
7 changed files with 488 additions and 0 deletions

View file

@ -29,6 +29,14 @@ bool did_something;
// scratchpad configurations for pmgen
int shiftadd_max_ratio;
// Helper function, removes LSB 0s
SigSpec remove_bottom_padding(SigSpec sig)
{
int i = 0;
for (; i < sig.size() - 1 && sig[i] == State::S0; i++);
return sig.extract(i, sig.size() - i);
}
#include "passes/opt/peepopt_pm.h"
struct PeepoptPass : public Pass {
@ -45,6 +53,8 @@ struct PeepoptPass : public Pass {
log("\n");
log(" * muldiv - Replace (A*B)/B with A\n");
log("\n");
log(" * muldiv_c - Replace (A*B)/C with A*(B/C) when C is a const divisible by B.\n");
log("\n");
log(" * shiftmul - Replace A>>(B*C) with A'>>(B<<K) where C and K are constants\n");
log(" and A' is derived from A by appropriately inserting padding\n");
log(" into the signal. (right variant)\n");
@ -106,6 +116,7 @@ struct PeepoptPass : public Pass {
pm.run_shiftmul_right();
pm.run_shiftmul_left();
pm.run_muldiv();
pm.run_muldiv_c();
}
}
}