yosys/passes/pmgen/xilinx_dsp.pmg

95 lines
2.0 KiB
Plaintext
Raw Normal View History

2019-07-15 16:46:31 -05:00
pattern xilinx_dsp
state <SigBit> clock
2019-07-16 16:06:32 -05:00
state <int> P_WIDTH
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-07-16 16:06:32 -05:00
select ffA->type.in($dff, $dffe)
2019-07-16 17:54:07 -05:00
select param(ffA, \CLK_POLARITY).as_bool()
2019-07-15 16:46:31 -05:00
// select nusers(port(ffA, \Q)) == 2
2019-07-18 15:18:04 -05:00
index <pool<SigBit>> port(ffA, \Q).to_sigbit_pool() === port(dsp, \A).remove_const().to_sigbit_pool()
2019-07-15 16:46:31 -05:00
// DSP48E1 does not support clock inversion
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-07-16 16:06:32 -05:00
select ffB->type.in($dff, $dffe)
2019-07-16 17:54:07 -05:00
select param(ffB, \CLK_POLARITY).as_bool()
2019-07-15 16:46:31 -05:00
// select nusers(port(ffB, \Q)) == 2
2019-07-18 15:18:04 -05:00
index <pool<SigBit>> port(ffB, \Q).to_sigbit_pool() === port(dsp, \B).remove_const().to_sigbit_pool()
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-16 16:06:32 -05:00
code P_WIDTH
SigSpec P = port(dsp, \P);
int i;
for (i = GetSize(P); i > 0; i--)
if (nusers(P[i-1]) > 1)
break;
P_WIDTH = i;
endcode
match ffP
select ffP->type.in($dff, $dffe)
select nusers(port(ffP, \D)) == 2
filter param(ffP, \WIDTH).as_int() == P_WIDTH
filter port(ffP, \D) == port(dsp, \P).extract(0, P_WIDTH)
index <Const> param(ffP, \CLK_POLARITY) === State::S1
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
if !ffP
select muxP->type.in($mux)
select port(muxP, \A).is_fully_undef()
filter param(muxP, \WIDTH).as_int() == P_WIDTH
filter port(muxP, \B) == port(dsp, \P).extract(0, P_WIDTH)
select nusers(port(muxP, \B)) == 2
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-16 16:06:32 -05:00
index <SigSpec> port(ffY, \D) === port(muxP, \Y)
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