if (st.ffAmux) {
SigSpec Y = st.ffAmux->getPort("\\Y");
SigSpec AB = st.ffAmux->getPort(st.ffAenpol ? "\\A" : "\\B");
- A.replace(Y, AB);
SigSpec S = st.ffAmux->getPort("\\S");
+ A.replace(Y, AB);
cell->setPort("\\CEA2", st.ffAenpol ? S : pm.module->Not(NEW_ID, S));
}
else
B.replace(Q, D);
if (st.ffBmux) {
SigSpec Y = st.ffBmux->getPort("\\Y");
- SigSpec AB = st.ffBmux->getPort(st.ffBmuxAB == "\\A" ? "\\B" : "\\A");
+ SigSpec AB = st.ffBmux->getPort(st.ffBenpol ? "\\A" : "\\B");
+ SigSpec S = st.ffBmux->getPort("\\S");
B.replace(Y, AB);
- cell->setPort("\\CEB2", st.ffBmux->getPort("\\S"));
+ cell->setPort("\\CEB2", st.ffBenpol ? S : pm.module->Not(NEW_ID, S));
}
else
cell->setPort("\\CEB2", State::S1);
}
if (st.ffM) {
if (st.ffMmux) {
- cell->setPort("\\CEM", st.ffMmux->getPort("\\S"));
+ SigSpec S = st.ffMmux->getPort("\\S");
+ cell->setPort("\\CEM", st.ffMenpol ? S : pm.module->Not(NEW_ID, S));
pm.autoremove(st.ffMmux);
}
else
}
if (st.ffP) {
if (st.ffPmux) {
- cell->setPort("\\CEP", st.ffPmux->getPort("\\S"));
+ SigSpec S = st.ffPmux->getPort("\\S");
+ cell->setPort("\\CEP", st.ffPenpol ? S : pm.module->Not(NEW_ID, S));
st.ffPmux->connections_.at("\\Y").replace(P, pm.module->addWire(NEW_ID, GetSize(P)));
}
else
state <SigBit> clock
state <SigSpec> sigA sigffAmux sigB sigffBmux sigC sigM sigP
-state <IdString> ffBmuxAB ffMmuxAB ffPmuxAB postAddAB postAddMuxAB
-state <bool> ffAenpol
+state <IdString> postAddAB postAddMuxAB
+state <bool> ffAenpol ffBenpol ffMenpol ffPenpol
match dsp
select dsp->type.in(\DSP48E1)
filter GetSize(port(ffBmux, \Y)) >= GetSize(sigB)
slice offset GetSize(port(ffBmux, \Y))
filter offset+GetSize(sigB) <= GetSize(port(ffBmux, \Y)) && port(ffBmux, \Y).extract(offset, GetSize(sigB)) == sigB
- choice <IdString> AB {\A, \B}
- filter offset+GetSize(sigffBmux) <= GetSize(port(ffBmux, \Y)) && port(ffBmux, AB).extract(offset, GetSize(sigffBmux)) == sigffBmux
- set ffBmuxAB AB
+ choice <IdString> BA {\B, \A}
+ filter offset+GetSize(sigffBmux) <= GetSize(port(ffBmux, \Y)) && port(ffBmux, BA).extract(offset, GetSize(sigffBmux)) == sigffBmux
+ define <bool> pol (BA == \B)
+ set ffBenpol pol
semioptional
endmatch
select ffMmux->type.in($mux)
select nusers(port(ffMmux, \Y)) == 2
filter GetSize(port(ffMmux, \Y)) <= GetSize(sigM)
- choice <IdString> AB {\A, \B}
- filter port(ffMmux, AB) == sigM.extract(0, GetSize(port(ffMmux, \Y)))
- filter nusers(sigM.extract_end(GetSize(port(ffMmux, AB)))) <= 1
- set ffMmuxAB AB
+ choice <IdString> BA {\B, \A}
+ filter port(ffMmux, BA) == sigM.extract(0, GetSize(port(ffMmux, \Y)))
+ filter nusers(sigM.extract_end(GetSize(port(ffMmux, BA)))) <= 1
+ define <bool> pol (BA == \B)
+ set ffMenpol pol
optional
endmatch
filter port(ffM, \D) == sigM.extract(0, GetSize(port(ffM, \D)))
filter nusers(sigM.extract_end(GetSize(port(ffM, \D)))) <= 1
// Check ffMmux (when present) is a $dff enable mux
- filter !ffMmux || port(ffM, \Q) == port(ffMmux, ffMmuxAB == \A ? \B : \A)
+ filter !ffMmux || port(ffM, \Q) == port(ffMmux, ffMenpol ? \A : \B)
optional
endmatch
select ffPmux->type.in($mux)
select nusers(port(ffPmux, \Y)) == 2
filter GetSize(port(ffPmux, \Y)) <= GetSize(sigP)
- choice <IdString> AB {\A, \B}
- filter port(ffPmux, AB) == sigP.extract(0, GetSize(port(ffPmux, \Y)))
- filter nusers(sigP.extract_end(GetSize(port(ffPmux, AB)))) <= 1
- set ffPmuxAB AB
+ choice <IdString> BA {\B, \A}
+ filter port(ffPmux, BA) == sigP.extract(0, GetSize(port(ffPmux, \Y)))
+ filter nusers(sigP.extract_end(GetSize(port(ffPmux, BA)))) <= 1
+ define <bool> pol (BA == \B)
+ set ffPenpol pol
optional
endmatch
code sigP
if (ffPmux)
- sigP.replace(port(ffPmux, ffPmuxAB), port(ffPmux, \Y));
+ sigP.replace(port(ffPmux, ffPenpol ? \A : \B), port(ffPmux, \Y));
endcode
match ffP
slice offset GetSize(port(ffP, \D))
filter offset+GetSize(sigP) <= GetSize(port(ffP, \D)) && port(ffP, \D).extract(offset, GetSize(sigP)) == sigP
// Check ffPmux (when present) is a $dff enable mux
- filter !ffPmux || port(ffP, \Q) == port(ffPmux, ffPmuxAB == \A ? \B : \A)
+ filter !ffPmux || port(ffP, \Q) == port(ffPmux, ffPenpol ? \A : \B)
optional
endmatch