log("ffB: %s\n", log_id(st.ffB, "--"));
log("dsp: %s\n", log_id(st.dsp, "--"));
log("ffM: %s\n", log_id(st.ffM, "--"));
- log("addAB: %s\n", log_id(st.addAB, "--"));
+ log("postAdd: %s\n", log_id(st.postAdd, "--"));
log("muxAB: %s\n", log_id(st.muxAB, "--"));
log("ffP: %s\n", log_id(st.ffP, "--"));
//log("muxP: %s\n", log_id(st.muxP, "--"));
SigSpec C = st.sigC;
SigSpec P = st.sigP;
- if (st.addAB) {
- log_assert(st.addAB->getParam("\\A_SIGNED").as_bool());
- log_assert(st.addAB->getParam("\\B_SIGNED").as_bool());
- log(" adder %s (%s)\n", log_id(st.addAB), log_id(st.addAB->type));
+ if (st.postAdd) {
+ log_assert(st.postAdd->getParam("\\A_SIGNED").as_bool());
+ log_assert(st.postAdd->getParam("\\B_SIGNED").as_bool());
+ log(" adder %s (%s)\n", log_id(st.postAdd), log_id(st.postAdd->type));
SigSpec &opmode = cell->connections_.at("\\OPMODE");
if (st.ffP && st.muxAB) {
opmode[6] = State::S0;
opmode[5] = State::S1;
- pm.autoremove(st.addAB);
+ pm.autoremove(st.postAdd);
}
if (st.clock != SigBit())
state <SigBit> clock
state <std::set<SigBit>> sigAset sigBset
state <SigSpec> sigC sigM sigMused sigP sigPused
-state <Cell*> addAB muxAB
+state <Cell*> postAdd muxAB
+state <IdString> postAddAB
match dsp
select dsp->type.in(\DSP48E1)
sigP = sigM;
endcode
-match addA
- select addA->type.in($add)
- select param(addA, \A_SIGNED).as_bool() && param(addA, \B_SIGNED).as_bool()
- select nusers(port(addA, \A)) == 2
- //index <SigSpec> port(addA, \A) === sigP.extract(0, param(addA, \A_WIDTH).as_int()) // TODO: Why doesn't this work!?!
- filter GetSize(port(addA, \A)) <= GetSize(sigP)
- filter port(addA, \A) == sigP.extract(0, GetSize(port(addA, \A)))
- filter nusers(sigP.extract_end(GetSize(port(addA, \A)))) <= 1
+match postAdd
+ // Ensure that Z mux is not already used
+ if port(dsp, \OPMODE).extract(4,3).is_fully_zero()
+
+ select postAdd->type.in($postAdd)
+ select param(postAdd, \A_SIGNED).as_bool() && param(postAdd, \B_SIGNED).as_bool()
+ choice <IdString> AB {\A, \B}
+ define <IdString> AB_WIDTH (AB == \A ? \A_WIDTH : \B_WIDTH)
+ select nusers(port(postAdd, AB)) == 2
+ filter GetSize(port(postAdd, AB)) <= GetSize(sigP)
+ filter port(postAdd, AB) == sigP.extract(0, GetSize(port(postAdd, AB)))
+ filter nusers(sigP.extract_end(GetSize(port(postAdd, AB)))) <= 1
+ set postAddAB AB
optional
endmatch
-match addB
- if !addA
- select addB->type.in($add, $sub)
- select param(addB, \A_SIGNED).as_bool() && param(addB, \B_SIGNED).as_bool()
- index <int> nusers(port(addB, \B)) === 2
- //index <SigSpec> port(addB, \B) === sigP.extract(0, param(addB, \B_WIDTH).as_int()) // TODO: Why doesn't this work!?!
- filter GetSize(port(addB, \B)) <= GetSize(sigP)
- filter port(addB, \B) == sigP.extract(0, GetSize(port(addB, \B)))
- filter nusers(sigP.extract_end(GetSize(port(addB, \B)))) <= 1
- optional
-endmatch
-
-code addAB sigC sigP
- if (addA) {
- addAB = addA;
- sigC = port(addAB, \B);
- }
- if (addB) {
- addAB = addB;
- sigC = port(addAB, \A);
- }
- if (addAB) {
- // Ensure that adder is not used
- SigSpec opmodeZ = port(dsp, \OPMODE).extract(4,3);
- if (!opmodeZ.is_fully_zero())
- reject;
+code sigC sigP
+ if (postAdd) {
+ sigC = port(postAdd, postAddAB == \A ? \B : \A);
// TODO for DSP48E1, which will have sign extended inputs/outputs
//int natural_mul_width = GetSize(port(dsp, \A)) + GetSize(port(dsp, \B));
//if ((actual_acc_width > actual_mul_width) && (natural_mul_width > actual_mul_width))
// reject;
- //if ((actual_acc_width != actual_mul_width) && (param(dsp, \A_SIGNED).as_bool() != param(addAB, \A_SIGNED).as_bool()))
+ //if ((actual_acc_width != actual_mul_width) && (param(dsp, \A_SIGNED).as_bool() != param(postAdd, \A_SIGNED).as_bool()))
// reject;
- sigP = port(addAB, \Y);
+ sigP = port(postAdd, \Y);
}
endcode
endcode
match muxA
- if addAB
+ if postAdd
select muxA->type.in($mux)
select nusers(port(muxA, \Y)) == 2
index <SigSpec> port(muxA, \A) === sigP
endmatch
match muxB
- if addAB
+ if postAdd
select muxB->type.in($mux)
select nusers(port(muxB, \Y)) == 2
index <SigSpec> port(muxB, \B) === sigP
sigC = port(muxAB, \A);
}
if (muxAB) {
- // Ensure that adder is not used
+ // Ensure that postAdder is not used
SigSpec opmodeZ = port(dsp, \OPMODE).extract(4,3);
if (!opmodeZ.is_fully_zero())
reject;