diff options
author | Clifford Wolf <clifford@clifford.at> | 2019-05-03 20:39:50 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-03 20:39:50 +0200 |
commit | 373b236108b254e3c01daa56a2b5ab75f2f87da2 (patch) | |
tree | 7725a9150eab6dcfbf895abf08d855b3dce4e9f4 /passes/opt | |
parent | f170fb6383477af453ca90ce4f67102e98b03f6e (diff) | |
parent | 2b29aa5c86021eb79c461975a0281b6d7635bb67 (diff) | |
download | yosys-373b236108b254e3c01daa56a2b5ab75f2f87da2.tar.gz yosys-373b236108b254e3c01daa56a2b5ab75f2f87da2.tar.bz2 yosys-373b236108b254e3c01daa56a2b5ab75f2f87da2.zip |
Merge pull request #969 from YosysHQ/clifford/pmgenstuff
Improve pmgen, Add "peepopt" pass with shift-mul pattern
Diffstat (limited to 'passes/opt')
-rw-r--r-- | passes/opt/wreduce.cc | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/passes/opt/wreduce.cc b/passes/opt/wreduce.cc index 41de8aad1..58c6e4b4b 100644 --- a/passes/opt/wreduce.cc +++ b/passes/opt/wreduce.cc @@ -531,6 +531,42 @@ struct WreducePass : public Pass { module->connect(sig, Const(0, GetSize(sig))); } } + + if (c->type.in("$div", "$mod", "$pow")) + { + SigSpec A = c->getPort("\\A"); + int original_a_width = GetSize(A); + if (c->getParam("\\A_SIGNED").as_bool()) { + while (GetSize(A) > 1 && A[GetSize(A)-1] == State::S0 && A[GetSize(A)-2] == State::S0) + A.remove(GetSize(A)-1, 1); + } else { + while (GetSize(A) > 0 && A[GetSize(A)-1] == State::S0) + A.remove(GetSize(A)-1, 1); + } + if (original_a_width != GetSize(A)) { + log("Removed top %d bits (of %d) from port A of cell %s.%s (%s).\n", + original_a_width-GetSize(A), original_a_width, log_id(module), log_id(c), log_id(c->type)); + c->setPort("\\A", A); + c->setParam("\\A_WIDTH", GetSize(A)); + } + + SigSpec B = c->getPort("\\B"); + int original_b_width = GetSize(B); + if (c->getParam("\\B_SIGNED").as_bool()) { + while (GetSize(B) > 1 && B[GetSize(B)-1] == State::S0 && B[GetSize(B)-2] == State::S0) + B.remove(GetSize(B)-1, 1); + } else { + while (GetSize(B) > 0 && B[GetSize(B)-1] == State::S0) + B.remove(GetSize(B)-1, 1); + } + if (original_b_width != GetSize(B)) { + log("Removed top %d bits (of %d) from port B of cell %s.%s (%s).\n", + original_b_width-GetSize(B), original_b_width, log_id(module), log_id(c), log_id(c->type)); + c->setPort("\\B", B); + c->setParam("\\B_WIDTH", GetSize(B)); + } + } + if (!opt_memx && c->type.in("$memrd", "$memwr", "$meminit")) { IdString memid = c->getParam("\\MEMID").decode_string(); RTLIL::Memory *mem = module->memories.at(memid); |