4 state <bool> clock_pol clock_vld
5 state <SigSpec> sigA sigB sigY sigS
6 state <Cell*> addAB muxAB
9 select mul->type.in($mul)
10 select GetSize(mul->getPort(\A)) + GetSize(mul->getPort(\B)) > 10
11 select GetSize(mul->getPort(\Y)) > 10
15 select ffA->type.in($dff)
16 // select nusers(port(ffA, \Q)) == 2
17 index <SigSpec> port(ffA, \Q) === port(mul, \A)
21 code sigA clock clock_pol clock_vld
27 clock = port(ffA, \CLK).as_bit();
28 clock_pol = param(ffA, \CLK_POLARITY).as_bool();
34 select ffB->type.in($dff)
35 // select nusers(port(ffB, \Q)) == 2
36 index <SigSpec> port(ffB, \Q) === port(mul, \B)
40 code sigB clock clock_pol clock_vld
45 SigBit c = port(ffB, \CLK).as_bit();
46 bool cp = param(ffB, \CLK_POLARITY).as_bool();
48 if (clock_vld && (c != clock || cp != clock_pol))
58 select ffY->type.in($dff)
59 select nusers(port(ffY, \D)) == 2
60 index <SigSpec> port(ffY, \D) === port(mul, \Y)
64 code sigY clock clock_pol clock_vld
69 SigBit c = port(ffY, \CLK).as_bit();
70 bool cp = param(ffY, \CLK_POLARITY).as_bool();
72 if (clock_vld && (c != clock || cp != clock_pol))
82 select addA->type.in($add)
83 select nusers(port(addA, \A)) == 2
84 index <SigSpec> port(addA, \A) === sigY
90 select addB->type.in($add, $sub)
91 select nusers(port(addB, \B)) == 2
92 index <SigSpec> port(addB, \B) === sigY
99 sigS = port(addA, \B);
103 sigS = port(addB, \A);
106 int natural_mul_width = GetSize(sigA) + GetSize(sigB);
107 int actual_mul_width = GetSize(sigY);
108 int actual_acc_width = GetSize(sigS);
110 if ((actual_acc_width > actual_mul_width) && (natural_mul_width > actual_mul_width))
112 if ((actual_acc_width != actual_mul_width) && (param(mul, \A_SIGNED).as_bool() != param(addAB, \A_SIGNED).as_bool()))
119 select muxA->type.in($mux)
120 select nusers(port(muxA, \A)) == 2
121 index <SigSpec> port(muxA, \A) === port(addAB, \Y)
128 select muxB->type.in($mux)
129 select nusers(port(muxB, \B)) == 2
130 index <SigSpec> port(muxB, \B) === port(addAB, \Y)
144 select ffS->type.in($dff)
145 select nusers(port(ffS, \D)) == 2
146 index <SigSpec> port(ffS, \D) === port(muxAB, \Y)
147 index <SigSpec> port(ffS, \Q) === sigS
150 code clock clock_pol clock_vld
152 SigBit c = port(ffS, \CLK).as_bit();
153 bool cp = param(ffS, \CLK_POLARITY).as_bool();
155 if (clock_vld && (c != clock || cp != clock_pol))