Add PCOUT -> PCIN non-shifted cascading

This commit is contained in:
Eddie Hung 2019-09-11 13:48:45 -07:00
parent c0f26c2da8
commit 690b1a064d
1 changed files with 22 additions and 15 deletions

View File

@ -272,7 +272,6 @@ void pack_xilinx_dsp(dict<SigBit, Cell*> &bit_to_driver, xilinx_dsp_pm &pm)
log("Analysing %s.%s for Xilinx DSP packing.\n", log_id(pm.module), log_id(st.dsp)); log("Analysing %s.%s for Xilinx DSP packing.\n", log_id(pm.module), log_id(st.dsp));
Cell *cell = st.dsp; Cell *cell = st.dsp;
bit_to_driver.insert(std::make_pair(cell->getPort("\\P")[17], cell));
if (st.preAdd) { if (st.preAdd) {
log(" preadder %s (%s)\n", log_id(st.preAdd), log_id(st.preAdd->type)); log(" preadder %s (%s)\n", log_id(st.preAdd), log_id(st.preAdd->type));
@ -317,10 +316,10 @@ void pack_xilinx_dsp(dict<SigBit, Cell*> &bit_to_driver, xilinx_dsp_pm &pm)
opmode[5] = State::S1; opmode[5] = State::S1;
if (opmode[4] != State::S0) { if (opmode[4] != State::S0) {
if (st.postAddMuxAB == "\\A") //if (st.postAddMuxAB == "\\A")
st.sigC.extend_u0(48, st.postAdd->getParam("\\B_SIGNED").as_bool()); // st.sigC.extend_u0(48, st.postAdd->getParam("\\B_SIGNED").as_bool());
else //else
st.sigC.extend_u0(48, st.postAdd->getParam("\\A_SIGNED").as_bool()); // st.sigC.extend_u0(48, st.postAdd->getParam("\\A_SIGNED").as_bool());
cell->setPort("\\C", st.sigC); cell->setPort("\\C", st.sigC);
} }
@ -436,6 +435,9 @@ void pack_xilinx_dsp(dict<SigBit, Cell*> &bit_to_driver, xilinx_dsp_pm &pm)
P.append(pm.module->addWire(NEW_ID, 48-GetSize(P))); P.append(pm.module->addWire(NEW_ID, 48-GetSize(P)));
cell->setPort("\\P", P); cell->setPort("\\P", P);
bit_to_driver.insert(std::make_pair(P[0], cell));
bit_to_driver.insert(std::make_pair(P[17], cell));
pm.blacklist(cell); pm.blacklist(cell);
} }
@ -489,6 +491,7 @@ struct XilinxDspPass : public Pass {
auto f = [&bit_to_driver](xilinx_dsp_pm &pm){ pack_xilinx_dsp(bit_to_driver, pm); }; auto f = [&bit_to_driver](xilinx_dsp_pm &pm){ pack_xilinx_dsp(bit_to_driver, pm); };
pm.run_xilinx_dsp(f); pm.run_xilinx_dsp(f);
auto &unextend = pm.ud_xilinx_dsp.unextend;
// Look for ability to convert C input from another DSP into PCIN // Look for ability to convert C input from another DSP into PCIN
// NB: Needs to be done after pattern matcher has folded all // NB: Needs to be done after pattern matcher has folded all
// $add cells into the DSP // $add cells into the DSP
@ -500,22 +503,26 @@ struct XilinxDspPass : public Pass {
SigSpec &opmode = cell->connections_.at("\\OPMODE"); SigSpec &opmode = cell->connections_.at("\\OPMODE");
if (opmode.extract(4,3) != Const::from_string("011")) if (opmode.extract(4,3) != Const::from_string("011"))
continue; continue;
SigSpec C = pm.sigmap(cell->getPort("\\C")); SigSpec C = unextend(pm.sigmap(cell->getPort("\\C")));
if (C.has_const()) if (!C[0].wire)
continue; continue;
auto it = bit_to_driver.find(C[0]); auto it = bit_to_driver.find(C[0]);
if (it == bit_to_driver.end()) if (it == bit_to_driver.end())
continue; continue;
auto driver = it->second; auto driver = it->second;
// Unextend C SigSpec P = driver->getPort("\\P");
int i; if (GetSize(P) >= GetSize(C) && P.extract(0, GetSize(C)) == C) {
for (i = GetSize(C)-1; i > 0; i--) cell->setPort("\\C", Const(0, 48));
if (C[i] != C[i-1]) Wire *cascade = module->addWire(NEW_ID, 48);
break; driver->setPort("\\PCOUT", cascade);
if (i > 48-17) cell->setPort("\\PCIN", cascade);
continue; opmode[6] = State::S0;
if (driver->getPort("\\P").extract(17, i) == C.extract(0, i)) { opmode[5] = State::S0;
opmode[4] = State::S1;
bit_to_driver.erase(it);
}
else if (GetSize(P) >= GetSize(C)+17 && P.extract(17, GetSize(C)) == C) {
cell->setPort("\\C", Const(0, 48)); cell->setPort("\\C", Const(0, 48));
Wire *cascade = module->addWire(NEW_ID, 48); Wire *cascade = module->addWire(NEW_ID, 48);
driver->setPort("\\PCOUT", cascade); driver->setPort("\\PCOUT", cascade);