diff options
author | Clifford Wolf <clifford@clifford.at> | 2019-04-30 11:25:15 +0200 |
---|---|---|
committer | Clifford Wolf <clifford@clifford.at> | 2019-04-30 11:25:15 +0200 |
commit | b515fd2d25851c90c9a0b08414c5ea5edeb916a0 (patch) | |
tree | 18e75d1f0b5ad39801b3cfcb72905ca048847ab7 /passes/pmgen/peepopt_muldiv.pmg | |
parent | 4306bebe586dc3a6a954a6630b9f0292c1b1b1dd (diff) | |
download | yosys-b515fd2d25851c90c9a0b08414c5ea5edeb916a0.tar.gz yosys-b515fd2d25851c90c9a0b08414c5ea5edeb916a0.tar.bz2 yosys-b515fd2d25851c90c9a0b08414c5ea5edeb916a0.zip |
Add peepopt_muldiv, fixes #930
Signed-off-by: Clifford Wolf <clifford@clifford.at>
Diffstat (limited to 'passes/pmgen/peepopt_muldiv.pmg')
-rw-r--r-- | passes/pmgen/peepopt_muldiv.pmg | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/passes/pmgen/peepopt_muldiv.pmg b/passes/pmgen/peepopt_muldiv.pmg new file mode 100644 index 000000000..06c275834 --- /dev/null +++ b/passes/pmgen/peepopt_muldiv.pmg @@ -0,0 +1,36 @@ +pattern muldiv + +state <SigSpec> t x y + +match mul + select mul->type == $mul + select GetSize(port(mul, \A)) + GetSize(port(mul, \B)) <= GetSize(port(mul, \Y)) +endmatch + +code t x y + t = port(mul, \Y); + x = port(mul, \A); + y = port(mul, \B); + branch; + std::swap(x, y); +endcode + +match div + select div->type.in($div) + index <SigSpec> port(div, \A) === t + index <SigSpec> port(div, \B) === x +endmatch + +code + SigSpec div_y = port(div, \Y); + SigSpec val_y = y; + + if (GetSize(div_y) != GetSize(val_y)) + val_y.extend_u0(GetSize(div_y), param(div, \A_SIGNED).as_bool()); + + did_something = true; + log("muldiv pattern in %s: mul=%s, div=%s\n", log_id(module), log_id(mul), log_id(div)); + module->connect(div_y, val_y); + autoremove(div); + reject; +endcode |