2019-07-15 16:46:31 -05:00
|
|
|
pattern xilinx_dsp
|
|
|
|
|
|
|
|
state <SigBit> clock
|
2019-07-19 12:57:32 -05:00
|
|
|
state <SigSpec> sigPused
|
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
|
|
|
|
|
|
|
|
match ffA
|
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-08-08 12:51:19 -05:00
|
|
|
filter param(dsp, \AREG).as_int() == 0
|
2019-07-18 17:22:00 -05:00
|
|
|
filter !port(dsp, \A).remove_const().empty()
|
2019-07-18 15:30:35 -05:00
|
|
|
filter includes(port(ffA, \Q).to_sigbit_set(), port(dsp, \A).remove_const().to_sigbit_set())
|
2019-07-15 16:46:31 -05:00
|
|
|
optional
|
|
|
|
endmatch
|
|
|
|
|
2019-07-16 16:06:32 -05:00
|
|
|
code clock
|
|
|
|
if (ffA)
|
2019-07-15 16:46:31 -05:00
|
|
|
clock = port(ffA, \CLK).as_bit();
|
|
|
|
endcode
|
|
|
|
|
|
|
|
match ffB
|
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-08-08 12:51:19 -05:00
|
|
|
filter param(dsp, \BREG).as_int() == 0
|
2019-07-18 17:22:00 -05:00
|
|
|
filter !port(dsp, \B).remove_const().empty()
|
2019-07-18 15:30:35 -05:00
|
|
|
filter includes(port(ffB, \Q).to_sigbit_set(), port(dsp, \B).remove_const().to_sigbit_set())
|
2019-07-15 16:46:31 -05:00
|
|
|
optional
|
|
|
|
endmatch
|
|
|
|
|
2019-07-16 16:06:32 -05:00
|
|
|
code clock
|
2019-07-15 16:46:31 -05:00
|
|
|
if (ffB) {
|
|
|
|
SigBit c = port(ffB, \CLK).as_bit();
|
|
|
|
|
|
|
|
if (clock != SigBit() && c != clock)
|
|
|
|
reject;
|
|
|
|
|
|
|
|
clock = c;
|
|
|
|
}
|
|
|
|
endcode
|
|
|
|
|
2019-07-18 16:08:18 -05:00
|
|
|
// Extract the bits of P that actually have a consumer
|
|
|
|
// (as opposed to being a sign extension)
|
2019-07-19 12:57:32 -05:00
|
|
|
code sigPused
|
2019-07-16 16:06:32 -05:00
|
|
|
SigSpec P = port(dsp, \P);
|
|
|
|
int i;
|
|
|
|
for (i = GetSize(P); i > 0; i--)
|
|
|
|
if (nusers(P[i-1]) > 1)
|
|
|
|
break;
|
2019-07-19 12:57:32 -05:00
|
|
|
sigPused = P.extract(0, i).remove_const();
|
2019-07-16 16:06:32 -05:00
|
|
|
endcode
|
|
|
|
|
|
|
|
match ffP
|
2019-07-19 12:57:32 -05:00
|
|
|
if !sigPused.empty()
|
2019-08-08 12:51:19 -05:00
|
|
|
select ffP->type.in($dff)
|
2019-07-16 16:06:32 -05:00
|
|
|
select nusers(port(ffP, \D)) == 2
|
2019-07-18 15:30:35 -05:00
|
|
|
// DSP48E1 does not support clock inversion
|
|
|
|
select param(ffP, \CLK_POLARITY).as_bool()
|
2019-08-08 12:51:19 -05:00
|
|
|
filter param(dsp, \PREG).as_int() == 0
|
2019-07-19 12:57:32 -05:00
|
|
|
filter param(ffP, \WIDTH).as_int() >= GetSize(sigPused)
|
|
|
|
filter includes(port(ffP, \D).to_sigbit_set(), sigPused.to_sigbit_set())
|
2019-07-16 16:06:32 -05:00
|
|
|
optional
|
|
|
|
endmatch
|
|
|
|
|
|
|
|
// $mux cell left behind by dff2dffe
|
|
|
|
// would prefer not to run 'opt_expr -mux_undef'
|
|
|
|
// since that would lose information helpful for
|
|
|
|
// efficient wide-mux inference
|
|
|
|
match muxP
|
2019-07-19 12:57:32 -05:00
|
|
|
if !sigPused.empty() && !ffP
|
2019-07-16 16:06:32 -05:00
|
|
|
select muxP->type.in($mux)
|
|
|
|
select nusers(port(muxP, \B)) == 2
|
2019-07-18 16:08:18 -05:00
|
|
|
select port(muxP, \A).is_fully_undef()
|
2019-07-19 12:57:32 -05:00
|
|
|
filter param(muxP, \WIDTH).as_int() >= GetSize(sigPused)
|
|
|
|
filter includes(port(muxP, \B).to_sigbit_set(), sigPused.to_sigbit_set())
|
2019-07-16 16:06:32 -05:00
|
|
|
optional
|
|
|
|
endmatch
|
|
|
|
|
2019-07-15 16:46:31 -05:00
|
|
|
match ffY
|
2019-07-16 16:06:32 -05:00
|
|
|
if muxP
|
|
|
|
select ffY->type.in($dff, $dffe)
|
2019-07-15 16:46:31 -05:00
|
|
|
select nusers(port(ffY, \D)) == 2
|
2019-07-18 15:30:35 -05:00
|
|
|
// DSP48E1 does not support clock inversion
|
|
|
|
select param(ffY, \CLK_POLARITY).as_bool()
|
2019-07-19 12:57:32 -05:00
|
|
|
filter param(ffY, \WIDTH).as_int() >= GetSize(sigPused)
|
2019-07-18 16:08:18 -05:00
|
|
|
filter includes(port(ffY, \D).to_sigbit_set(), port(muxP, \Y).to_sigbit_set())
|
2019-07-15 16:46:31 -05:00
|
|
|
endmatch
|
|
|
|
|
2019-07-16 16:06:32 -05:00
|
|
|
code ffP clock
|
|
|
|
if (ffY)
|
|
|
|
ffP = ffY;
|
2019-07-15 16:46:31 -05:00
|
|
|
|
2019-07-16 16:06:32 -05:00
|
|
|
if (ffP) {
|
|
|
|
SigBit c = port(ffP, \CLK).as_bit();
|
2019-07-15 16:46:31 -05:00
|
|
|
|
|
|
|
if (clock != SigBit() && c != clock)
|
|
|
|
reject;
|
|
|
|
|
|
|
|
clock = c;
|
|
|
|
}
|
|
|
|
endcode
|