2019-07-15 16:46:31 -05:00
|
|
|
pattern xilinx_dsp
|
|
|
|
|
|
|
|
state <SigBit> clock
|
2019-09-06 16:06:57 -05:00
|
|
|
state <SigSpec> sigA sigffAmuxY sigB sigffBmuxY sigC sigD sigM sigP
|
2019-09-05 23:38:35 -05:00
|
|
|
state <IdString> postAddAB postAddMuxAB
|
2019-09-06 16:06:57 -05:00
|
|
|
state <bool> ffAenpol ffADenpol ffBenpol ffMenpol ffPenpol
|
2019-09-06 13:58:56 -05:00
|
|
|
state <int> ffPoffset
|
2019-07-15 16:46:31 -05:00
|
|
|
|
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-06 16:06:57 -05:00
|
|
|
code sigA sigffAmuxY sigB sigffBmuxY sigD sigM
|
2019-09-04 19:18:49 -05:00
|
|
|
sigA = port(dsp, \A);
|
|
|
|
int i;
|
|
|
|
for (i = GetSize(sigA)-1; i > 0; i--)
|
|
|
|
if (sigA[i] != sigA[i-1])
|
|
|
|
break;
|
2019-09-05 12:07:26 -05:00
|
|
|
// Do not remove non-const sign bit
|
|
|
|
if (sigA[i].wire)
|
|
|
|
++i;
|
2019-09-04 19:18:49 -05:00
|
|
|
sigA.remove(i, GetSize(sigA)-i);
|
2019-09-04 19:22:02 -05:00
|
|
|
sigB = port(dsp, \B);
|
|
|
|
for (i = GetSize(sigB)-1; i > 0; i--)
|
|
|
|
if (sigB[i] != sigB[i-1])
|
|
|
|
break;
|
2019-09-05 12:07:26 -05:00
|
|
|
// Do not remove non-const sign bit
|
|
|
|
if (sigB[i].wire)
|
|
|
|
++i;
|
2019-09-04 19:22:02 -05:00
|
|
|
sigB.remove(i, GetSize(sigB)-i);
|
2019-08-13 19:11:35 -05:00
|
|
|
|
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);
|
|
|
|
// Only care about those bits that are used
|
|
|
|
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);
|
|
|
|
//if (GetSize(sigM) <= 10)
|
2019-08-30 17:00:56 -05:00
|
|
|
// reject;
|
2019-09-06 11:47:32 -05:00
|
|
|
|
|
|
|
sigffAmuxY = SigSpec();
|
|
|
|
sigffBmuxY = SigSpec();
|
2019-08-30 17:00:56 -05:00
|
|
|
endcode
|
|
|
|
|
2019-09-06 16:06:57 -05:00
|
|
|
match ffAD
|
|
|
|
if param(dsp, \ADREG).as_int() == 0
|
|
|
|
select ffAD->type.in($dff)
|
|
|
|
// DSP48E1 does not support clock inversion
|
|
|
|
select param(ffAD, \CLK_POLARITY).as_bool()
|
|
|
|
filter GetSize(port(ffAD, \Q)) >= GetSize(sigA)
|
|
|
|
slice offset GetSize(port(ffAD, \Q))
|
|
|
|
filter offset+GetSize(sigA) <= GetSize(port(ffAD, \Q))
|
|
|
|
filter port(ffAD, \Q).extract(offset, GetSize(sigA)) == sigA
|
|
|
|
optional
|
|
|
|
endmatch
|
|
|
|
|
|
|
|
code sigA sigffAmuxY clock
|
|
|
|
if (ffAD) {
|
|
|
|
for (auto b : port(ffAD, \Q))
|
|
|
|
if (b.wire->get_bool_attribute(\keep))
|
|
|
|
reject;
|
|
|
|
|
|
|
|
clock = port(ffAD, \CLK).as_bit();
|
|
|
|
|
|
|
|
SigSpec A = sigA;
|
|
|
|
A.replace(port(ffAD, \Q), port(ffAD, \D));
|
|
|
|
// Only search for ffAmux if ffA.Q has at
|
|
|
|
// least 3 users (ffA, dsp, ffAmux) and
|
|
|
|
// its ffA.D only has two (ffA, ffAmux)
|
|
|
|
if (nusers(sigA) >= 3 && nusers(A) == 2)
|
|
|
|
sigffAmuxY = sigA;
|
|
|
|
sigA = std::move(A);
|
|
|
|
}
|
|
|
|
endcode
|
|
|
|
|
|
|
|
match ffADmux
|
|
|
|
if !sigffAmuxY.empty()
|
|
|
|
select ffADmux->type.in($mux)
|
|
|
|
index <SigSpec> port(ffADmux, \Y) === port(ffAD, \D)
|
|
|
|
filter GetSize(port(ffADmux, \Y)) >= GetSize(sigA)
|
|
|
|
slice offset GetSize(port(ffADmux, \Y))
|
|
|
|
filter offset+GetSize(sigA) <= GetSize(port(ffADmux, \Y))
|
|
|
|
filter port(ffADmux, \Y).extract(offset, GetSize(sigA)) == sigA
|
2019-09-06 16:36:10 -05:00
|
|
|
choice <IdString> AB {\A, \B}
|
2019-09-06 16:06:57 -05:00
|
|
|
filter offset+GetSize(sigffAmuxY) <= GetSize(port(ffADmux, \Y))
|
2019-09-06 16:36:10 -05:00
|
|
|
filter port(ffADmux, AB).extract(offset, GetSize(sigffAmuxY)) == sigffAmuxY
|
|
|
|
define <bool> pol (AB == \A)
|
2019-09-06 16:06:57 -05:00
|
|
|
set ffADenpol pol
|
|
|
|
optional
|
|
|
|
endmatch
|
|
|
|
|
|
|
|
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-07-15 16:46:31 -05:00
|
|
|
match ffA
|
2019-09-06 16:06:57 -05:00
|
|
|
if !preAdd
|
2019-08-09 17:47:40 -05:00
|
|
|
if param(dsp, \AREG).as_int() == 0
|
2019-08-08 12:51:19 -05:00
|
|
|
select ffA->type.in($dff)
|
2019-07-15 16:46:31 -05:00
|
|
|
// DSP48E1 does not support clock inversion
|
2019-07-18 15:30:35 -05:00
|
|
|
select param(ffA, \CLK_POLARITY).as_bool()
|
2019-09-04 19:18:49 -05:00
|
|
|
filter GetSize(port(ffA, \Q)) >= GetSize(sigA)
|
|
|
|
slice offset GetSize(port(ffA, \Q))
|
2019-09-06 13:39:20 -05:00
|
|
|
filter offset+GetSize(sigA) <= GetSize(port(ffA, \Q))
|
|
|
|
filter port(ffA, \Q).extract(offset, GetSize(sigA)) == sigA
|
2019-07-15 16:46:31 -05:00
|
|
|
optional
|
|
|
|
endmatch
|
|
|
|
|
2019-09-06 11:47:32 -05:00
|
|
|
code sigA sigffAmuxY clock
|
2019-08-15 14:34:11 -05:00
|
|
|
if (ffA) {
|
|
|
|
for (auto b : port(ffA, \Q))
|
|
|
|
if (b.wire->get_bool_attribute(\keep))
|
|
|
|
reject;
|
2019-09-04 19:18:49 -05:00
|
|
|
|
|
|
|
clock = port(ffA, \CLK).as_bit();
|
2019-09-05 12:07:26 -05:00
|
|
|
|
2019-09-06 11:47:32 -05:00
|
|
|
SigSpec A = sigA;
|
|
|
|
A.replace(port(ffA, \Q), port(ffA, \D));
|
|
|
|
// Only search for ffAmux if ffA.Q has at
|
|
|
|
// least 3 users (ffA, dsp, ffAmux) and
|
|
|
|
// its ffA.D only has two (ffA, ffAmux)
|
|
|
|
if (nusers(sigA) >= 3 && nusers(A) == 2)
|
|
|
|
sigffAmuxY = sigA;
|
|
|
|
sigA = std::move(A);
|
2019-08-15 14:34:11 -05:00
|
|
|
}
|
2019-09-06 16:06:57 -05:00
|
|
|
else if (!preAdd) {
|
|
|
|
sigffAmuxY = SigSpec();
|
|
|
|
}
|
2019-07-15 16:46:31 -05:00
|
|
|
endcode
|
|
|
|
|
2019-09-05 12:07:26 -05:00
|
|
|
match ffAmux
|
2019-09-06 11:47:32 -05:00
|
|
|
if !sigffAmuxY.empty()
|
2019-09-05 12:07:26 -05:00
|
|
|
select ffAmux->type.in($mux)
|
2019-09-06 14:07:35 -05:00
|
|
|
index <SigSpec> port(ffAmux, \Y) === port(ffA, \D)
|
2019-09-05 13:55:14 -05:00
|
|
|
filter GetSize(port(ffAmux, \Y)) >= GetSize(sigA)
|
|
|
|
slice offset GetSize(port(ffAmux, \Y))
|
2019-09-06 13:39:20 -05:00
|
|
|
filter offset+GetSize(sigA) <= GetSize(port(ffAmux, \Y))
|
|
|
|
filter port(ffAmux, \Y).extract(offset, GetSize(sigA)) == sigA
|
2019-09-06 16:36:10 -05:00
|
|
|
choice <IdString> AB {\A, \B}
|
2019-09-06 13:39:20 -05:00
|
|
|
filter offset+GetSize(sigffAmuxY) <= GetSize(port(ffAmux, \Y))
|
2019-09-06 16:36:10 -05:00
|
|
|
filter port(ffAmux, AB).extract(offset, GetSize(sigffAmuxY)) == sigffAmuxY
|
|
|
|
define <bool> pol (AB == \A)
|
2019-09-05 23:28:28 -05:00
|
|
|
set ffAenpol pol
|
2019-09-06 12:35:06 -05:00
|
|
|
optional
|
2019-09-05 12:07:26 -05:00
|
|
|
endmatch
|
|
|
|
|
2019-09-06 16:06:57 -05:00
|
|
|
code ffA ffAmux ffAenpol ffAD ffADmux
|
|
|
|
// Move AD register to A if no pre-adder
|
|
|
|
if (!ffA && !preAdd && ffAD) {
|
|
|
|
ffA = ffAD;
|
|
|
|
ffAmux = ffADmux;
|
|
|
|
ffAenpol = ffADenpol;
|
|
|
|
|
|
|
|
ffAD = nullptr;
|
|
|
|
ffADmux = nullptr;
|
|
|
|
}
|
|
|
|
endcode
|
|
|
|
|
2019-07-15 16:46:31 -05:00
|
|
|
match ffB
|
2019-08-09 17:47:40 -05:00
|
|
|
if param(dsp, \BREG).as_int() == 0
|
2019-08-08 12:51:19 -05:00
|
|
|
select ffB->type.in($dff)
|
2019-07-18 15:30:35 -05:00
|
|
|
// DSP48E1 does not support clock inversion
|
2019-07-16 17:54:07 -05:00
|
|
|
select param(ffB, \CLK_POLARITY).as_bool()
|
2019-09-04 19:22:02 -05:00
|
|
|
filter GetSize(port(ffB, \Q)) >= GetSize(sigB)
|
|
|
|
slice offset GetSize(port(ffB, \Q))
|
2019-09-06 13:39:20 -05:00
|
|
|
filter offset+GetSize(sigB) <= GetSize(port(ffB, \Q))
|
|
|
|
filter port(ffB, \Q).extract(offset, GetSize(sigB)) == sigB
|
2019-07-15 16:46:31 -05:00
|
|
|
optional
|
|
|
|
endmatch
|
|
|
|
|
2019-09-06 11:47:32 -05:00
|
|
|
code sigB sigffBmuxY clock
|
2019-07-15 16:46:31 -05:00
|
|
|
if (ffB) {
|
2019-08-15 14:34:11 -05:00
|
|
|
for (auto b : port(ffB, \Q))
|
|
|
|
if (b.wire->get_bool_attribute(\keep))
|
|
|
|
reject;
|
|
|
|
|
2019-07-15 16:46:31 -05:00
|
|
|
SigBit c = port(ffB, \CLK).as_bit();
|
|
|
|
if (clock != SigBit() && c != clock)
|
|
|
|
reject;
|
|
|
|
clock = c;
|
2019-09-05 12:46:33 -05:00
|
|
|
|
2019-09-06 11:47:32 -05:00
|
|
|
SigSpec B = sigB;
|
|
|
|
B.replace(port(ffB, \Q), port(ffB, \D));
|
|
|
|
// Only search for ffBmux if ffB.Q has at
|
|
|
|
// least 3 users (ffB, dsp, ffBmux) and
|
|
|
|
// its ffB.D only has two (ffB, ffBmux)
|
|
|
|
if (nusers(sigB) >= 3 && nusers(B) == 2)
|
|
|
|
sigffBmuxY = sigB;
|
|
|
|
sigB = std::move(B);
|
2019-07-15 16:46:31 -05:00
|
|
|
}
|
|
|
|
endcode
|
|
|
|
|
2019-09-05 12:46:33 -05:00
|
|
|
match ffBmux
|
2019-09-06 11:47:32 -05:00
|
|
|
if !sigffBmuxY.empty()
|
2019-09-05 12:46:33 -05:00
|
|
|
select ffBmux->type.in($mux)
|
2019-09-06 14:07:35 -05:00
|
|
|
index <SigSpec> port(ffBmux, \Y) === port(ffB, \D)
|
2019-09-05 13:55:14 -05:00
|
|
|
filter GetSize(port(ffBmux, \Y)) >= GetSize(sigB)
|
|
|
|
slice offset GetSize(port(ffBmux, \Y))
|
2019-09-06 13:39:20 -05:00
|
|
|
filter offset+GetSize(sigB) <= GetSize(port(ffBmux, \Y))
|
|
|
|
filter port(ffBmux, \Y).extract(offset, GetSize(sigB)) == sigB
|
2019-09-06 16:36:10 -05:00
|
|
|
choice <IdString> AB {\A, \B}
|
2019-09-06 13:39:20 -05:00
|
|
|
filter offset+GetSize(sigffBmuxY) <= GetSize(port(ffBmux, \Y))
|
2019-09-06 16:36:10 -05:00
|
|
|
filter port(ffBmux, AB).extract(offset, GetSize(sigffBmuxY)) == sigffBmuxY
|
|
|
|
define <bool> pol (AB == \A)
|
2019-09-05 23:38:35 -05:00
|
|
|
set ffBenpol pol
|
2019-09-06 12:35:06 -05:00
|
|
|
optional
|
2019-09-05 12:46:33 -05:00
|
|
|
endmatch
|
|
|
|
|
2019-09-04 12:52:51 -05:00
|
|
|
match ffMmux
|
2019-09-06 13:58:56 -05:00
|
|
|
if param(dsp, \MREG).as_int() == 0
|
|
|
|
if nusers(sigM) == 2
|
2019-09-04 12:52:51 -05:00
|
|
|
select ffMmux->type.in($mux)
|
2019-09-06 11:59:35 -05:00
|
|
|
choice <IdString> BA {\B, \A}
|
|
|
|
// new-value net must have exactly two users: dsp and ffM
|
|
|
|
select nusers(port(ffMmux, BA)) == 2
|
|
|
|
define <IdString> AB (BA == \B ? \A : \B)
|
|
|
|
// keep-last-value net must have at least three users: ffMmux, ffM, downstream sink(s)
|
|
|
|
select nusers(port(ffMmux, AB)) >= 3
|
|
|
|
// ffMmux output must have two users: ffMmux and ffM.D
|
2019-09-04 12:52:51 -05:00
|
|
|
select nusers(port(ffMmux, \Y)) == 2
|
|
|
|
filter GetSize(port(ffMmux, \Y)) <= GetSize(sigM)
|
2019-09-05 23:38:35 -05:00
|
|
|
filter port(ffMmux, BA) == sigM.extract(0, GetSize(port(ffMmux, \Y)))
|
2019-09-06 11:59:35 -05:00
|
|
|
// Remaining bits on sigM must not have any other users
|
2019-09-05 23:38:35 -05:00
|
|
|
filter nusers(sigM.extract_end(GetSize(port(ffMmux, BA)))) <= 1
|
2019-09-06 16:36:10 -05:00
|
|
|
define <bool> pol (AB == \A)
|
2019-09-05 23:38:35 -05:00
|
|
|
set ffMenpol pol
|
2019-09-05 13:46:38 -05:00
|
|
|
optional
|
2019-09-04 12:52:51 -05:00
|
|
|
endmatch
|
|
|
|
|
|
|
|
code sigM
|
|
|
|
if (ffMmux)
|
|
|
|
sigM = port(ffMmux, \Y);
|
|
|
|
endcode
|
|
|
|
|
2019-09-06 14:07:35 -05:00
|
|
|
match ffM_enable
|
|
|
|
if ffMmux
|
|
|
|
if nusers(sigM) == 2
|
|
|
|
select ffM_enable->type.in($dff)
|
|
|
|
// DSP48E1 does not support clock inversion
|
|
|
|
select param(ffM_enable, \CLK_POLARITY).as_bool()
|
|
|
|
index <SigSpec> port(ffM_enable, \D) === sigM
|
|
|
|
index <SigSpec> port(ffM_enable, \Q) === port(ffMmux, ffMenpol ? \A : \B)
|
|
|
|
endmatch
|
|
|
|
|
2019-08-30 17:00:56 -05:00
|
|
|
match ffM
|
2019-09-06 14:07:35 -05:00
|
|
|
if !ffM_enable
|
2019-08-30 17:00:56 -05:00
|
|
|
if param(dsp, \MREG).as_int() == 0
|
2019-09-06 13:58:56 -05:00
|
|
|
if nusers(sigM) == 2
|
2019-08-30 17:00:56 -05:00
|
|
|
select ffM->type.in($dff)
|
|
|
|
// DSP48E1 does not support clock inversion
|
|
|
|
select param(ffM, \CLK_POLARITY).as_bool()
|
2019-09-06 14:07:35 -05:00
|
|
|
index <SigSpec> port(ffM, \D) === sigM
|
2019-08-30 17:00:56 -05:00
|
|
|
optional
|
|
|
|
endmatch
|
|
|
|
|
2019-09-06 14:07:35 -05:00
|
|
|
code ffM clock sigM sigP
|
|
|
|
if (ffM_enable) {
|
|
|
|
log_assert(!ffM);
|
|
|
|
ffM = ffM_enable;
|
|
|
|
}
|
2019-08-30 17:00:56 -05:00
|
|
|
if (ffM) {
|
|
|
|
sigM = port(ffM, \Q);
|
2019-09-04 12:52:51 -05:00
|
|
|
|
2019-08-30 17:00:56 -05:00
|
|
|
for (auto b : sigM)
|
|
|
|
if (b.wire->get_bool_attribute(\keep))
|
|
|
|
reject;
|
|
|
|
|
2019-08-30 18:18:58 -05:00
|
|
|
SigBit c = port(ffM, \CLK).as_bit();
|
2019-08-30 17:00:56 -05:00
|
|
|
if (clock != SigBit() && c != clock)
|
|
|
|
reject;
|
|
|
|
clock = c;
|
|
|
|
}
|
|
|
|
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-03 18:10:16 -05:00
|
|
|
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
|
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-05 13:00:27 -05:00
|
|
|
match ffPmux
|
2019-09-06 13:38:19 -05:00
|
|
|
if param(dsp, \PREG).as_int() == 0
|
2019-09-06 13:58:56 -05:00
|
|
|
// new-value net must have exactly two users: dsp and ffP
|
2019-09-06 13:38:19 -05:00
|
|
|
if nusers(sigP) == 2
|
2019-09-05 13:00:27 -05:00
|
|
|
select ffPmux->type.in($mux)
|
2019-09-06 13:58:56 -05:00
|
|
|
// ffPmux output must have two users: ffPmux and ffP.D
|
|
|
|
select nusers(port(ffPmux, \Y)) == 2
|
|
|
|
filter GetSize(port(ffPmux, \Y)) >= GetSize(sigP)
|
|
|
|
|
|
|
|
slice offset GetSize(port(ffPmux, \Y))
|
|
|
|
filter offset+GetSize(sigP) <= GetSize(port(ffPmux, \Y))
|
2019-09-06 16:36:10 -05:00
|
|
|
choice <IdString> BA {\B, \A}
|
2019-09-06 13:58:56 -05:00
|
|
|
filter port(ffPmux, BA).extract(offset, GetSize(sigP)) == sigP
|
|
|
|
|
2019-09-06 11:59:35 -05:00
|
|
|
define <IdString> AB (BA == \B ? \A : \B)
|
|
|
|
// keep-last-value net must have at least three users: ffPmux, ffP, downstream sink(s)
|
2019-09-06 13:58:56 -05:00
|
|
|
filter nusers(port(ffPmux, AB)) >= 3
|
2019-09-06 16:36:10 -05:00
|
|
|
define <bool> pol (AB == \A)
|
2019-09-05 23:38:35 -05:00
|
|
|
set ffPenpol pol
|
2019-09-06 13:58:56 -05:00
|
|
|
set ffPoffset offset
|
2019-09-05 13:46:38 -05:00
|
|
|
optional
|
2019-09-05 13:00:27 -05:00
|
|
|
endmatch
|
|
|
|
|
|
|
|
code sigP
|
|
|
|
if (ffPmux)
|
2019-09-06 13:58:56 -05:00
|
|
|
sigP.replace(port(ffPmux, ffPenpol ? \B : \A), port(ffPmux, \Y));
|
2019-09-05 13:00:27 -05:00
|
|
|
endcode
|
|
|
|
|
2019-09-06 13:58:56 -05:00
|
|
|
match ffP_enable
|
|
|
|
if ffPmux
|
|
|
|
if nusers(sigP) == 2
|
|
|
|
select ffP_enable->type.in($dff)
|
|
|
|
// DSP48E1 does not support clock inversion
|
|
|
|
select param(ffP_enable, \CLK_POLARITY).as_bool()
|
|
|
|
index <SigSpec> port(ffP_enable, \D) === port(ffPmux, \Y)
|
|
|
|
index <SigSpec> port(ffP_enable, \Q) === port(ffPmux, ffPenpol ? \A : \B)
|
|
|
|
filter GetSize(port(ffP_enable, \D)) >= GetSize(sigP)
|
|
|
|
filter ffPoffset+GetSize(sigP) <= GetSize(port(ffP_enable, \D))
|
|
|
|
filter port(ffP_enable, \D).extract(ffPoffset, GetSize(sigP)) == sigP
|
|
|
|
endmatch
|
|
|
|
|
2019-07-16 16:06:32 -05:00
|
|
|
match ffP
|
2019-09-06 13:58:56 -05:00
|
|
|
if !ffP_enable
|
2019-08-09 17:47:40 -05:00
|
|
|
if param(dsp, \PREG).as_int() == 0
|
2019-09-06 13:38:19 -05:00
|
|
|
if nusers(sigP) == 2
|
2019-08-08 12:51:19 -05:00
|
|
|
select ffP->type.in($dff)
|
2019-07-18 15:30:35 -05:00
|
|
|
// DSP48E1 does not support clock inversion
|
|
|
|
select param(ffP, \CLK_POLARITY).as_bool()
|
2019-09-04 19:06:17 -05:00
|
|
|
filter GetSize(port(ffP, \D)) >= GetSize(sigP)
|
|
|
|
slice offset GetSize(port(ffP, \D))
|
2019-09-06 13:38:19 -05:00
|
|
|
filter offset+GetSize(sigP) <= GetSize(port(ffP, \D))
|
|
|
|
filter port(ffP, \D).extract(offset, GetSize(sigP)) == sigP
|
2019-07-16 16:06:32 -05:00
|
|
|
optional
|
|
|
|
endmatch
|
|
|
|
|
2019-09-03 17:53:10 -05:00
|
|
|
code ffP sigP clock
|
2019-09-06 13:58:56 -05:00
|
|
|
if (ffP_enable) {
|
|
|
|
log_assert(!ffP);
|
|
|
|
ffP = ffP_enable;
|
|
|
|
}
|
2019-07-16 16:06:32 -05:00
|
|
|
if (ffP) {
|
2019-08-15 14:34:11 -05:00
|
|
|
for (auto b : port(ffP, \Q))
|
|
|
|
if (b.wire->get_bool_attribute(\keep))
|
|
|
|
reject;
|
|
|
|
|
2019-07-16 16:06:32 -05:00
|
|
|
SigBit c = port(ffP, \CLK).as_bit();
|
2019-07-15 16:46:31 -05:00
|
|
|
|
|
|
|
if (clock != SigBit() && c != clock)
|
|
|
|
reject;
|
|
|
|
|
|
|
|
clock = c;
|
2019-09-03 17:53:10 -05:00
|
|
|
|
2019-09-04 18:59:57 -05:00
|
|
|
sigP.replace(port(ffP, \D), port(ffP, \Q));
|
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-03 17:53:10 -05:00
|
|
|
code
|
2019-08-30 13:02:10 -05:00
|
|
|
accept;
|
2019-07-15 16:46:31 -05:00
|
|
|
endcode
|