2019-07-15 16:46:31 -05:00
|
|
|
pattern xilinx_dsp
|
|
|
|
|
2019-09-06 23:01:36 -05:00
|
|
|
state <std::function<SigSpec(const SigSpec&)>> unextend
|
2019-07-15 16:46:31 -05:00
|
|
|
state <SigBit> clock
|
2019-09-06 23:01:36 -05:00
|
|
|
state <SigSpec> sigA sigffAmuxY sigB sigffBmuxY sigC sigffCmuxY sigD sigffDmuxY sigM sigP
|
2019-09-05 23:38:35 -05:00
|
|
|
state <IdString> postAddAB postAddMuxAB
|
2019-09-06 23:01:36 -05:00
|
|
|
state <bool> ffAenpol ffADenpol ffBenpol ffCenpol ffDenpol ffMenpol ffPenpol
|
2019-09-06 13:58:56 -05:00
|
|
|
state <int> ffPoffset
|
2019-07-15 16:46:31 -05:00
|
|
|
|
2019-09-10 20:27:05 -05:00
|
|
|
state <Cell*> ffAD ffADmux ffA ffAmux ffB ffBmux ffC ffCmux ffD ffDmux ffM ffMmux ffP ffPmux
|
2019-09-09 17:51:14 -05:00
|
|
|
|
|
|
|
// subpattern
|
2019-09-10 20:27:05 -05:00
|
|
|
state <SigSpec> argQ argD
|
2019-09-09 18:45:38 -05:00
|
|
|
state <bool> ffenpol
|
2019-09-10 20:27:05 -05:00
|
|
|
udata <SigSpec> dffD dffQ
|
2019-09-09 17:51:14 -05:00
|
|
|
udata <SigBit> dffclock
|
|
|
|
udata <Cell*> dff dffmux
|
|
|
|
udata <bool> dffenpol
|
|
|
|
|
2019-07-16 16:06:32 -05:00
|
|
|
match dsp
|
|
|
|
select dsp->type.in(\DSP48E1)
|
2019-07-15 16:46:31 -05:00
|
|
|
endmatch
|
|
|
|
|
2019-09-09 17:51:14 -05:00
|
|
|
code unextend sigA sigB sigC sigD sigM
|
2019-09-06 23:01:36 -05:00
|
|
|
unextend = [](const SigSpec &sig) {
|
2019-09-06 20:40:11 -05:00
|
|
|
int i;
|
|
|
|
for (i = GetSize(sig)-1; i > 0; i--)
|
|
|
|
if (sig[i] != sig[i-1])
|
|
|
|
break;
|
|
|
|
// Do not remove non-const sign bit
|
2019-09-06 23:01:36 -05:00
|
|
|
if (sig[i].wire)
|
2019-09-06 20:40:11 -05:00
|
|
|
++i;
|
|
|
|
return sig.extract(0, i);
|
|
|
|
};
|
2019-09-06 23:01:36 -05:00
|
|
|
sigA = unextend(port(dsp, \A));
|
|
|
|
sigB = unextend(port(dsp, \B));
|
2019-08-13 19:11:35 -05:00
|
|
|
|
2019-09-06 20:40:11 -05:00
|
|
|
sigC = dsp->connections_.at(\C, SigSpec());
|
2019-09-06 16:06:57 -05:00
|
|
|
sigD = dsp->connections_.at(\D, SigSpec());
|
|
|
|
|
2019-09-04 19:06:17 -05:00
|
|
|
SigSpec P = port(dsp, \P);
|
2019-09-09 22:57:03 -05:00
|
|
|
if (dsp->parameters.at(\USE_MULT, Const("MULTIPLY")).decode_string() == "MULTIPLY") {
|
|
|
|
// Only care about those bits that are used
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < GetSize(P); i++) {
|
|
|
|
if (nusers(P[i]) <= 1)
|
|
|
|
break;
|
|
|
|
sigM.append(P[i]);
|
|
|
|
}
|
|
|
|
log_assert(nusers(P.extract_end(i)) <= 1);
|
2019-09-04 19:06:17 -05:00
|
|
|
}
|
2019-09-09 22:57:03 -05:00
|
|
|
else
|
|
|
|
sigM = P;
|
2019-08-30 17:00:56 -05:00
|
|
|
endcode
|
|
|
|
|
2019-09-09 18:45:38 -05:00
|
|
|
code argQ ffAD ffADmux ffADenpol sigA clock
|
2019-09-09 17:51:14 -05:00
|
|
|
if (param(dsp, \ADREG).as_int() == 0) {
|
2019-09-09 18:45:38 -05:00
|
|
|
argQ = sigA;
|
2019-09-09 17:51:14 -05:00
|
|
|
subpattern(in_dffe);
|
|
|
|
if (dff) {
|
|
|
|
ffAD = dff;
|
|
|
|
clock = dffclock;
|
|
|
|
if (dffmux) {
|
|
|
|
ffADmux = dffmux;
|
|
|
|
ffADenpol = dffenpol;
|
|
|
|
}
|
|
|
|
sigA = dffD;
|
|
|
|
}
|
2019-09-06 16:06:57 -05:00
|
|
|
}
|
|
|
|
endcode
|
|
|
|
|
|
|
|
match preAdd
|
|
|
|
if sigD.empty() || sigD.is_fully_zero()
|
|
|
|
// Ensure that preAdder not already used
|
|
|
|
if dsp->parameters.at(\USE_DPORT, Const("FALSE")).decode_string() == "FALSE"
|
|
|
|
if dsp->connections_.at(\INMODE, Const(0, 5)).is_fully_zero()
|
|
|
|
|
|
|
|
select preAdd->type.in($add)
|
|
|
|
// Output has to be 25 bits or less
|
|
|
|
select GetSize(port(preAdd, \Y)) <= 25
|
|
|
|
select nusers(port(preAdd, \Y)) == 2
|
|
|
|
choice <IdString> AB {\A, \B}
|
|
|
|
// A port has to be 30 bits or less
|
|
|
|
select GetSize(port(preAdd, AB)) <= 30
|
|
|
|
define <IdString> BA (AB == \A ? \B : \A)
|
|
|
|
// D port has to be 25 bits or less
|
|
|
|
select GetSize(port(preAdd, BA)) <= 25
|
|
|
|
index <SigSpec> port(preAdd, \Y) === sigA
|
|
|
|
|
|
|
|
optional
|
|
|
|
endmatch
|
|
|
|
|
|
|
|
code sigA sigD
|
|
|
|
if (preAdd) {
|
|
|
|
sigA = port(preAdd, \A);
|
|
|
|
sigD = port(preAdd, \B);
|
|
|
|
if (GetSize(sigA) < GetSize(sigD))
|
|
|
|
std::swap(sigA, sigD);
|
|
|
|
}
|
|
|
|
endcode
|
|
|
|
|
2019-09-09 18:45:38 -05:00
|
|
|
code argQ ffA ffAmux ffAenpol sigA clock ffAD ffADmux ffADenpol
|
2019-09-09 17:51:14 -05:00
|
|
|
// Only search for ffA if there was a pre-adder
|
|
|
|
// (otherwise ffA would have been matched as ffAD)
|
|
|
|
if (preAdd) {
|
|
|
|
if (param(dsp, \AREG).as_int() == 0) {
|
2019-09-09 18:45:38 -05:00
|
|
|
argQ = sigA;
|
2019-09-09 17:51:14 -05:00
|
|
|
subpattern(in_dffe);
|
|
|
|
if (dff) {
|
|
|
|
ffA = dff;
|
|
|
|
clock = dffclock;
|
|
|
|
if (dffmux) {
|
|
|
|
ffAmux = dffmux;
|
|
|
|
ffAenpol = dffenpol;
|
|
|
|
}
|
|
|
|
sigA = dffD;
|
|
|
|
}
|
|
|
|
}
|
2019-09-06 16:06:57 -05:00
|
|
|
}
|
2019-09-09 17:51:14 -05:00
|
|
|
// And if there wasn't a pre-adder,
|
|
|
|
// move AD register to A
|
|
|
|
else if (ffAD) {
|
|
|
|
log_assert(!ffA && !ffAmux);
|
|
|
|
std::swap(ffA, ffAD);
|
|
|
|
std::swap(ffAmux, ffADmux);
|
2019-09-06 16:06:57 -05:00
|
|
|
ffAenpol = ffADenpol;
|
|
|
|
}
|
|
|
|
endcode
|
|
|
|
|
2019-09-09 18:45:38 -05:00
|
|
|
code argQ ffB ffBmux ffBenpol sigB clock
|
2019-09-09 17:51:14 -05:00
|
|
|
if (param(dsp, \BREG).as_int() == 0) {
|
2019-09-09 18:45:38 -05:00
|
|
|
argQ = sigB;
|
2019-09-09 17:51:14 -05:00
|
|
|
subpattern(in_dffe);
|
|
|
|
if (dff) {
|
|
|
|
ffB = dff;
|
|
|
|
clock = dffclock;
|
|
|
|
if (dffmux) {
|
|
|
|
ffBmux = dffmux;
|
|
|
|
ffBenpol = dffenpol;
|
|
|
|
}
|
|
|
|
sigB = dffD;
|
|
|
|
}
|
2019-07-15 16:46:31 -05:00
|
|
|
}
|
|
|
|
endcode
|
|
|
|
|
2019-09-09 18:45:38 -05:00
|
|
|
code argQ ffD ffDmux ffDenpol sigD clock
|
2019-09-09 17:51:14 -05:00
|
|
|
if (param(dsp, \DREG).as_int() == 0) {
|
2019-09-09 18:45:38 -05:00
|
|
|
argQ = sigD;
|
2019-09-09 17:51:14 -05:00
|
|
|
subpattern(in_dffe);
|
|
|
|
if (dff) {
|
|
|
|
ffD = dff;
|
|
|
|
clock = dffclock;
|
|
|
|
if (dffmux) {
|
|
|
|
ffDmux = dffmux;
|
|
|
|
ffDenpol = dffenpol;
|
|
|
|
}
|
|
|
|
sigD = dffD;
|
|
|
|
}
|
2019-09-06 17:32:26 -05:00
|
|
|
}
|
|
|
|
endcode
|
|
|
|
|
2019-09-10 20:27:05 -05:00
|
|
|
code argD ffM ffMmux ffMenpol sigM sigP clock
|
|
|
|
if (param(dsp, \MREG).as_int() == 0 && nusers(sigM) == 2) {
|
|
|
|
argD = sigM;
|
|
|
|
subpattern(out_dffe);
|
|
|
|
if (dff) {
|
|
|
|
ffM = dff;
|
|
|
|
clock = dffclock;
|
|
|
|
if (dffmux) {
|
|
|
|
ffMmux = dffmux;
|
|
|
|
ffMenpol = dffenpol;
|
|
|
|
}
|
|
|
|
sigM = dffQ;
|
|
|
|
}
|
2019-08-30 17:00:56 -05:00
|
|
|
}
|
|
|
|
sigP = sigM;
|
2019-08-09 17:19:33 -05:00
|
|
|
endcode
|
|
|
|
|
2019-09-03 18:10:16 -05:00
|
|
|
match postAdd
|
|
|
|
// Ensure that Z mux is not already used
|
|
|
|
if port(dsp, \OPMODE).extract(4,3).is_fully_zero()
|
|
|
|
|
2019-09-03 18:24:59 -05:00
|
|
|
select postAdd->type.in($add)
|
2019-09-06 12:35:06 -05:00
|
|
|
select GetSize(port(postAdd, \Y)) <= 48
|
|
|
|
select nusers(port(postAdd, \Y)) == 2
|
2019-09-03 18:10:16 -05:00
|
|
|
choice <IdString> AB {\A, \B}
|
2019-09-04 12:52:51 -05:00
|
|
|
select nusers(port(postAdd, AB)) <= 3
|
|
|
|
filter ffMmux || nusers(port(postAdd, AB)) == 2
|
|
|
|
filter !ffMmux || nusers(port(postAdd, AB)) == 3
|
2019-09-06 23:01:36 -05:00
|
|
|
filter GetSize(unextend(port(postAdd, AB))) <= GetSize(sigP)
|
|
|
|
filter unextend(port(postAdd, AB)) == sigP.extract(0, GetSize(unextend(port(postAdd, AB))))
|
|
|
|
filter nusers(sigP.extract_end(GetSize(unextend(port(postAdd, AB))))) <= 1
|
2019-09-03 18:10:16 -05:00
|
|
|
set postAddAB AB
|
2019-08-09 17:19:33 -05:00
|
|
|
optional
|
|
|
|
endmatch
|
|
|
|
|
2019-09-03 18:10:16 -05:00
|
|
|
code sigC sigP
|
|
|
|
if (postAdd) {
|
|
|
|
sigC = port(postAdd, postAddAB == \A ? \B : \A);
|
2019-08-09 17:19:33 -05:00
|
|
|
|
2019-08-30 18:18:58 -05:00
|
|
|
// TODO for DSP48E1, which will have sign extended inputs/outputs
|
|
|
|
//int natural_mul_width = GetSize(port(dsp, \A)) + GetSize(port(dsp, \B));
|
|
|
|
//int actual_mul_width = GetSize(sigP);
|
|
|
|
//int actual_acc_width = GetSize(sigC);
|
2019-08-09 17:19:33 -05:00
|
|
|
|
2019-08-30 18:18:58 -05:00
|
|
|
//if ((actual_acc_width > actual_mul_width) && (natural_mul_width > actual_mul_width))
|
|
|
|
// reject;
|
2019-09-03 18:10:16 -05:00
|
|
|
//if ((actual_acc_width != actual_mul_width) && (param(dsp, \A_SIGNED).as_bool() != param(postAdd, \A_SIGNED).as_bool()))
|
2019-08-09 17:19:33 -05:00
|
|
|
// reject;
|
|
|
|
|
2019-09-03 18:10:16 -05:00
|
|
|
sigP = port(postAdd, \Y);
|
2019-08-09 17:19:33 -05:00
|
|
|
}
|
|
|
|
endcode
|
|
|
|
|
2019-09-10 20:27:05 -05:00
|
|
|
code argD ffP ffPmux ffPenpol sigP clock
|
|
|
|
if (param(dsp, \PREG).as_int() == 0) {
|
|
|
|
// If ffMmux and no postAdd new-value net must have exactly three users: ffMmux, ffM and ffPmux
|
|
|
|
if ((ffMmux && !postAdd && nusers(sigP) == 3) ||
|
|
|
|
// Otherwise new-value net must have exactly two users: dsp and ffPmux
|
|
|
|
((!ffMmux || postAdd) && nusers(sigP) == 2)) {
|
|
|
|
argD = sigP;
|
|
|
|
subpattern(out_dffe);
|
|
|
|
if (dff) {
|
|
|
|
ffP = dff;
|
|
|
|
clock = dffclock;
|
|
|
|
if (dffmux) {
|
|
|
|
ffPmux = dffmux;
|
|
|
|
ffPenpol = dffenpol;
|
|
|
|
}
|
|
|
|
sigP = dffQ;
|
|
|
|
}
|
|
|
|
}
|
2019-09-03 17:53:10 -05:00
|
|
|
}
|
|
|
|
endcode
|
|
|
|
|
2019-09-03 18:24:59 -05:00
|
|
|
match postAddMux
|
2019-09-03 18:10:16 -05:00
|
|
|
if postAdd
|
2019-09-03 18:24:59 -05:00
|
|
|
if ffP
|
|
|
|
select postAddMux->type.in($mux)
|
|
|
|
select nusers(port(postAddMux, \Y)) == 2
|
|
|
|
choice <IdString> AB {\A, \B}
|
|
|
|
index <SigSpec> port(postAddMux, AB) === sigP
|
|
|
|
index <SigSpec> port(postAddMux, \Y) === sigC
|
|
|
|
set postAddMuxAB AB
|
2019-09-03 17:53:10 -05:00
|
|
|
optional
|
|
|
|
endmatch
|
|
|
|
|
2019-09-03 18:24:59 -05:00
|
|
|
code sigC
|
|
|
|
if (postAddMux)
|
|
|
|
sigC = port(postAddMux, postAddMuxAB == \A ? \B : \A);
|
2019-09-03 17:53:10 -05:00
|
|
|
endcode
|
2019-08-30 13:02:10 -05:00
|
|
|
|
2019-09-09 18:45:38 -05:00
|
|
|
code argQ ffC ffCmux ffCenpol sigC clock
|
2019-09-09 17:51:14 -05:00
|
|
|
if (param(dsp, \CREG).as_int() == 0) {
|
2019-09-09 18:45:38 -05:00
|
|
|
argQ = sigC;
|
2019-09-09 17:51:14 -05:00
|
|
|
subpattern(in_dffe);
|
|
|
|
if (dff) {
|
|
|
|
ffC = dff;
|
|
|
|
clock = dffclock;
|
|
|
|
if (dffmux) {
|
|
|
|
ffCmux = dffmux;
|
|
|
|
ffCenpol = dffenpol;
|
|
|
|
}
|
|
|
|
sigC = dffD;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
endcode
|
|
|
|
|
|
|
|
code
|
|
|
|
accept;
|
|
|
|
endcode
|
|
|
|
|
2019-09-10 20:27:05 -05:00
|
|
|
// #######################
|
|
|
|
|
2019-09-09 17:51:14 -05:00
|
|
|
subpattern in_dffe
|
2019-09-09 18:45:38 -05:00
|
|
|
arg argQ clock ffenpol
|
2019-09-09 17:51:14 -05:00
|
|
|
|
|
|
|
match ff
|
|
|
|
select ff->type.in($dff)
|
2019-09-06 23:01:36 -05:00
|
|
|
// DSP48E1 does not support clock inversion
|
2019-09-09 17:51:14 -05:00
|
|
|
select param(ff, \CLK_POLARITY).as_bool()
|
2019-09-09 18:45:38 -05:00
|
|
|
filter GetSize(port(ff, \Q)) >= GetSize(argQ)
|
2019-09-09 17:51:14 -05:00
|
|
|
slice offset GetSize(port(ff, \Q))
|
2019-09-09 18:45:38 -05:00
|
|
|
filter offset+GetSize(argQ) <= GetSize(port(ff, \Q))
|
|
|
|
filter port(ff, \Q).extract(offset, GetSize(argQ)) == argQ
|
2019-09-09 17:51:14 -05:00
|
|
|
semioptional
|
2019-09-06 23:01:36 -05:00
|
|
|
endmatch
|
|
|
|
|
2019-09-09 18:45:38 -05:00
|
|
|
code argQ
|
2019-09-09 17:51:14 -05:00
|
|
|
if (ff) {
|
2019-09-09 18:45:38 -05:00
|
|
|
for (auto b : argQ)
|
2019-09-06 23:01:36 -05:00
|
|
|
if (b.wire->get_bool_attribute(\keep))
|
|
|
|
reject;
|
|
|
|
|
2019-09-09 17:51:14 -05:00
|
|
|
if (clock != SigBit()) {
|
|
|
|
if (port(ff, \CLK) != clock)
|
|
|
|
reject;
|
|
|
|
}
|
2019-09-09 18:07:40 -05:00
|
|
|
dffclock = port(ff, \CLK);
|
2019-09-09 17:51:14 -05:00
|
|
|
|
|
|
|
dff = ff;
|
2019-09-09 18:45:38 -05:00
|
|
|
dffD = argQ;
|
2019-09-09 17:51:14 -05:00
|
|
|
dffD.replace(port(ff, \Q), port(ff, \D));
|
|
|
|
// Only search for ffmux if ff.Q has at
|
|
|
|
// least 3 users (ff, dsp, ffmux) and
|
|
|
|
// its ff.D only has two (ff, ffmux)
|
2019-09-09 18:45:38 -05:00
|
|
|
if (!(nusers(argQ) >= 3 && nusers(dffD) == 2))
|
|
|
|
argQ = SigSpec();
|
2019-09-06 23:01:36 -05:00
|
|
|
}
|
2019-09-09 17:59:10 -05:00
|
|
|
else {
|
|
|
|
dff = nullptr;
|
2019-09-09 18:45:38 -05:00
|
|
|
argQ = SigSpec();
|
2019-09-09 17:59:10 -05:00
|
|
|
}
|
2019-09-06 23:01:36 -05:00
|
|
|
endcode
|
|
|
|
|
2019-09-09 17:51:14 -05:00
|
|
|
match ffmux
|
2019-09-09 18:45:38 -05:00
|
|
|
if !argQ.empty()
|
2019-09-09 17:51:14 -05:00
|
|
|
select ffmux->type.in($mux)
|
|
|
|
index <SigSpec> port(ffmux, \Y) === port(ff, \D)
|
|
|
|
filter GetSize(port(ffmux, \Y)) >= GetSize(dffD)
|
|
|
|
slice offset GetSize(port(ffmux, \Y))
|
|
|
|
filter offset+GetSize(dffD) <= GetSize(port(ffmux, \Y))
|
|
|
|
filter port(ffmux, \Y).extract(offset, GetSize(dffD)) == dffD
|
2019-09-06 23:01:36 -05:00
|
|
|
choice <IdString> AB {\A, \B}
|
2019-09-09 18:45:38 -05:00
|
|
|
filter offset+GetSize(argQ) <= GetSize(port(ffmux, \Y))
|
|
|
|
filter port(ffmux, AB).extract(offset, GetSize(argQ)) == argQ
|
2019-09-06 23:01:36 -05:00
|
|
|
define <bool> pol (AB == \A)
|
2019-09-09 18:45:38 -05:00
|
|
|
set ffenpol pol
|
2019-09-09 17:51:14 -05:00
|
|
|
semioptional
|
2019-09-06 23:01:36 -05:00
|
|
|
endmatch
|
|
|
|
|
2019-09-03 17:53:10 -05:00
|
|
|
code
|
2019-09-09 17:51:14 -05:00
|
|
|
if (ffmux) {
|
|
|
|
dffmux = ffmux;
|
2019-09-09 18:45:38 -05:00
|
|
|
dffenpol = ffenpol;
|
2019-09-09 17:51:14 -05:00
|
|
|
dffD = port(ffmux, dffenpol ? \B : \A);
|
|
|
|
}
|
2019-09-09 17:59:10 -05:00
|
|
|
else
|
|
|
|
dffmux = nullptr;
|
2019-07-15 16:46:31 -05:00
|
|
|
endcode
|
2019-09-10 20:27:05 -05:00
|
|
|
|
|
|
|
// #######################
|
|
|
|
|
|
|
|
subpattern out_dffe
|
|
|
|
arg argD clock ffenpol
|
|
|
|
arg unextend
|
|
|
|
|
|
|
|
match ffmux
|
|
|
|
select ffmux->type.in($mux)
|
|
|
|
// ffmux output must have two users: ffmux and ff.D
|
|
|
|
select nusers(port(ffmux, \Y)) == 2
|
|
|
|
filter GetSize(port(ffmux, \Y)) >= GetSize(argD)
|
|
|
|
|
|
|
|
choice <IdString> BA {\B, \A}
|
|
|
|
// new-value net must have exactly two users: (upstream) and ffmux
|
|
|
|
select nusers(port(ffmux, BA)) == 2
|
|
|
|
|
|
|
|
slice offset GetSize(port(ffmux, \Y))
|
|
|
|
filter offset+GetSize(argD) <= GetSize(port(ffmux, \Y))
|
|
|
|
filter port(ffmux, BA).extract(offset, GetSize(argD)) == argD
|
|
|
|
|
|
|
|
define <IdString> AB (BA == \B ? \A : \B)
|
|
|
|
// keep-last-value net must have at least three users: ffmux, ff, downstream sink(s)
|
|
|
|
select nusers(port(ffmux, AB)) >= 3
|
|
|
|
|
|
|
|
filter GetSize(unextend(port(ffmux, BA))) <= GetSize(argD)
|
|
|
|
filter unextend(port(ffmux, BA)) == argD.extract(0, GetSize(unextend(port(ffmux, BA))))
|
|
|
|
// Remaining bits on argD must not have any other users
|
|
|
|
filter nusers(argD.extract_end(GetSize(unextend(port(ffmux, BA))))) <= 1
|
|
|
|
|
|
|
|
define <bool> pol (AB == \A)
|
|
|
|
set ffenpol pol
|
|
|
|
semioptional
|
|
|
|
endmatch
|
|
|
|
|
|
|
|
code argD
|
|
|
|
if (ffmux) {
|
|
|
|
dffmux = ffmux;
|
|
|
|
dffenpol = ffenpol;
|
|
|
|
argD = port(ffmux, \Y);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
dffmux = nullptr;
|
|
|
|
endcode
|
|
|
|
|
|
|
|
match ff_enable
|
|
|
|
if ffmux
|
|
|
|
select ff_enable->type.in($dff)
|
|
|
|
// DSP48E1 does not support clock inversion
|
|
|
|
select param(ff_enable, \CLK_POLARITY).as_bool()
|
|
|
|
index <SigSpec> port(ff_enable, \D) === argD
|
|
|
|
index <SigSpec> port(ff_enable, \Q) === port(ffmux, ffenpol ? \A : \B)
|
|
|
|
endmatch
|
|
|
|
|
|
|
|
match ff
|
|
|
|
if !ff_enable
|
|
|
|
select ff->type.in($dff)
|
|
|
|
// DSP48E1 does not support clock inversion
|
|
|
|
select param(ff, \CLK_POLARITY).as_bool()
|
|
|
|
index <SigSpec> port(ff, \D) === argD
|
|
|
|
semioptional
|
|
|
|
endmatch
|
|
|
|
|
|
|
|
code
|
|
|
|
if (ff_enable)
|
|
|
|
dff = ff_enable;
|
|
|
|
else
|
|
|
|
dff = ff;
|
|
|
|
log_dump("ffM", dff, dffmux);
|
|
|
|
if (dff) {
|
|
|
|
dffQ = port(dff, \Q);
|
|
|
|
|
|
|
|
for (auto b : dffQ)
|
|
|
|
if (b.wire->get_bool_attribute(\keep))
|
|
|
|
reject;
|
|
|
|
|
|
|
|
if (clock != SigBit()) {
|
|
|
|
if (port(dff, \CLK) != clock)
|
|
|
|
reject;
|
|
|
|
}
|
|
|
|
dffclock = port(dff, \CLK);
|
|
|
|
}
|
|
|
|
// No enable mux possible without flop
|
|
|
|
else if (ffmux)
|
|
|
|
reject;
|
|
|
|
endcode
|