arnaucube
arnaucube/poulpyPublic Self-hosted repository
poulpy/poulpy-schemes/src/bin_fhe/bdd_arithmetic/circuits/u32/and_codegen.rs
poulpy-schemes/src/bin_fhe/bdd_arithmetic/circuits/u32/and_codegen.rsRaw
  1use crate::bin_fhe::bdd_arithmetic::{BitCircuit, BitCircuitFamily, BitCircuitInfo, Circuit, Node};
  2pub(crate) enum AnyBitCircuit {
  3    B0(BitCircuit<4>),
  4    B1(BitCircuit<4>),
  5    B2(BitCircuit<4>),
  6    B3(BitCircuit<4>),
  7    B4(BitCircuit<4>),
  8    B5(BitCircuit<4>),
  9    B6(BitCircuit<4>),
 10    B7(BitCircuit<4>),
 11    B8(BitCircuit<4>),
 12    B9(BitCircuit<4>),
 13    B10(BitCircuit<4>),
 14    B11(BitCircuit<4>),
 15    B12(BitCircuit<4>),
 16    B13(BitCircuit<4>),
 17    B14(BitCircuit<4>),
 18    B15(BitCircuit<4>),
 19    B16(BitCircuit<4>),
 20    B17(BitCircuit<4>),
 21    B18(BitCircuit<4>),
 22    B19(BitCircuit<4>),
 23    B20(BitCircuit<4>),
 24    B21(BitCircuit<4>),
 25    B22(BitCircuit<4>),
 26    B23(BitCircuit<4>),
 27    B24(BitCircuit<4>),
 28    B25(BitCircuit<4>),
 29    B26(BitCircuit<4>),
 30    B27(BitCircuit<4>),
 31    B28(BitCircuit<4>),
 32    B29(BitCircuit<4>),
 33    B30(BitCircuit<4>),
 34    B31(BitCircuit<4>),
 35}
 36impl BitCircuitInfo for AnyBitCircuit {
 37    fn info(&self) -> (&[Node], usize) {
 38        match self {
 39            AnyBitCircuit::B0(bit_circuit) => (bit_circuit.nodes.as_ref(), bit_circuit.max_inter_state),
 40            AnyBitCircuit::B1(bit_circuit) => (bit_circuit.nodes.as_ref(), bit_circuit.max_inter_state),
 41            AnyBitCircuit::B2(bit_circuit) => (bit_circuit.nodes.as_ref(), bit_circuit.max_inter_state),
 42            AnyBitCircuit::B3(bit_circuit) => (bit_circuit.nodes.as_ref(), bit_circuit.max_inter_state),
 43            AnyBitCircuit::B4(bit_circuit) => (bit_circuit.nodes.as_ref(), bit_circuit.max_inter_state),
 44            AnyBitCircuit::B5(bit_circuit) => (bit_circuit.nodes.as_ref(), bit_circuit.max_inter_state),
 45            AnyBitCircuit::B6(bit_circuit) => (bit_circuit.nodes.as_ref(), bit_circuit.max_inter_state),
 46            AnyBitCircuit::B7(bit_circuit) => (bit_circuit.nodes.as_ref(), bit_circuit.max_inter_state),
 47            AnyBitCircuit::B8(bit_circuit) => (bit_circuit.nodes.as_ref(), bit_circuit.max_inter_state),
 48            AnyBitCircuit::B9(bit_circuit) => (bit_circuit.nodes.as_ref(), bit_circuit.max_inter_state),
 49            AnyBitCircuit::B10(bit_circuit) => (bit_circuit.nodes.as_ref(), bit_circuit.max_inter_state),
 50            AnyBitCircuit::B11(bit_circuit) => (bit_circuit.nodes.as_ref(), bit_circuit.max_inter_state),
 51            AnyBitCircuit::B12(bit_circuit) => (bit_circuit.nodes.as_ref(), bit_circuit.max_inter_state),
 52            AnyBitCircuit::B13(bit_circuit) => (bit_circuit.nodes.as_ref(), bit_circuit.max_inter_state),
 53            AnyBitCircuit::B14(bit_circuit) => (bit_circuit.nodes.as_ref(), bit_circuit.max_inter_state),
 54            AnyBitCircuit::B15(bit_circuit) => (bit_circuit.nodes.as_ref(), bit_circuit.max_inter_state),
 55            AnyBitCircuit::B16(bit_circuit) => (bit_circuit.nodes.as_ref(), bit_circuit.max_inter_state),
 56            AnyBitCircuit::B17(bit_circuit) => (bit_circuit.nodes.as_ref(), bit_circuit.max_inter_state),
 57            AnyBitCircuit::B18(bit_circuit) => (bit_circuit.nodes.as_ref(), bit_circuit.max_inter_state),
 58            AnyBitCircuit::B19(bit_circuit) => (bit_circuit.nodes.as_ref(), bit_circuit.max_inter_state),
 59            AnyBitCircuit::B20(bit_circuit) => (bit_circuit.nodes.as_ref(), bit_circuit.max_inter_state),
 60            AnyBitCircuit::B21(bit_circuit) => (bit_circuit.nodes.as_ref(), bit_circuit.max_inter_state),
 61            AnyBitCircuit::B22(bit_circuit) => (bit_circuit.nodes.as_ref(), bit_circuit.max_inter_state),
 62            AnyBitCircuit::B23(bit_circuit) => (bit_circuit.nodes.as_ref(), bit_circuit.max_inter_state),
 63            AnyBitCircuit::B24(bit_circuit) => (bit_circuit.nodes.as_ref(), bit_circuit.max_inter_state),
 64            AnyBitCircuit::B25(bit_circuit) => (bit_circuit.nodes.as_ref(), bit_circuit.max_inter_state),
 65            AnyBitCircuit::B26(bit_circuit) => (bit_circuit.nodes.as_ref(), bit_circuit.max_inter_state),
 66            AnyBitCircuit::B27(bit_circuit) => (bit_circuit.nodes.as_ref(), bit_circuit.max_inter_state),
 67            AnyBitCircuit::B28(bit_circuit) => (bit_circuit.nodes.as_ref(), bit_circuit.max_inter_state),
 68            AnyBitCircuit::B29(bit_circuit) => (bit_circuit.nodes.as_ref(), bit_circuit.max_inter_state),
 69            AnyBitCircuit::B30(bit_circuit) => (bit_circuit.nodes.as_ref(), bit_circuit.max_inter_state),
 70            AnyBitCircuit::B31(bit_circuit) => (bit_circuit.nodes.as_ref(), bit_circuit.max_inter_state),
 71        }
 72    }
 73}
 74
 75impl BitCircuitFamily for AnyBitCircuit {
 76    const INPUT_BITS: usize = 64;
 77    const OUTPUT_BITS: usize = 32;
 78}
 79
 80pub(crate) static OUTPUT_CIRCUITS: Circuit<AnyBitCircuit, 32usize> = Circuit([
 81    AnyBitCircuit::B0(BitCircuit::new(
 82        [
 83            Node::Copy,
 84            Node::Cmux(32, 1, 0),
 85            Node::Cmux(0, 1, 0),
 86            Node::None,
 87        ],
 88        2,
 89    )),
 90    AnyBitCircuit::B1(BitCircuit::new(
 91        [
 92            Node::Copy,
 93            Node::Cmux(33, 1, 0),
 94            Node::Cmux(1, 1, 0),
 95            Node::None,
 96        ],
 97        2,
 98    )),
 99    AnyBitCircuit::B2(BitCircuit::new(
100        [
101            Node::Copy,
102            Node::Cmux(34, 1, 0),
103            Node::Cmux(2, 1, 0),
104            Node::None,
105        ],
106        2,
107    )),
108    AnyBitCircuit::B3(BitCircuit::new(
109        [
110            Node::Copy,
111            Node::Cmux(35, 1, 0),
112            Node::Cmux(3, 1, 0),
113            Node::None,
114        ],
115        2,
116    )),
117    AnyBitCircuit::B4(BitCircuit::new(
118        [
119            Node::Copy,
120            Node::Cmux(36, 1, 0),
121            Node::Cmux(4, 1, 0),
122            Node::None,
123        ],
124        2,
125    )),
126    AnyBitCircuit::B5(BitCircuit::new(
127        [
128            Node::Copy,
129            Node::Cmux(37, 1, 0),
130            Node::Cmux(5, 1, 0),
131            Node::None,
132        ],
133        2,
134    )),
135    AnyBitCircuit::B6(BitCircuit::new(
136        [
137            Node::Copy,
138            Node::Cmux(38, 1, 0),
139            Node::Cmux(6, 1, 0),
140            Node::None,
141        ],
142        2,
143    )),
144    AnyBitCircuit::B7(BitCircuit::new(
145        [
146            Node::Copy,
147            Node::Cmux(39, 1, 0),
148            Node::Cmux(7, 1, 0),
149            Node::None,
150        ],
151        2,
152    )),
153    AnyBitCircuit::B8(BitCircuit::new(
154        [
155            Node::Copy,
156            Node::Cmux(40, 1, 0),
157            Node::Cmux(8, 1, 0),
158            Node::None,
159        ],
160        2,
161    )),
162    AnyBitCircuit::B9(BitCircuit::new(
163        [
164            Node::Copy,
165            Node::Cmux(41, 1, 0),
166            Node::Cmux(9, 1, 0),
167            Node::None,
168        ],
169        2,
170    )),
171    AnyBitCircuit::B10(BitCircuit::new(
172        [
173            Node::Copy,
174            Node::Cmux(42, 1, 0),
175            Node::Cmux(10, 1, 0),
176            Node::None,
177        ],
178        2,
179    )),
180    AnyBitCircuit::B11(BitCircuit::new(
181        [
182            Node::Copy,
183            Node::Cmux(43, 1, 0),
184            Node::Cmux(11, 1, 0),
185            Node::None,
186        ],
187        2,
188    )),
189    AnyBitCircuit::B12(BitCircuit::new(
190        [
191            Node::Copy,
192            Node::Cmux(44, 1, 0),
193            Node::Cmux(12, 1, 0),
194            Node::None,
195        ],
196        2,
197    )),
198    AnyBitCircuit::B13(BitCircuit::new(
199        [
200            Node::Copy,
201            Node::Cmux(45, 1, 0),
202            Node::Cmux(13, 1, 0),
203            Node::None,
204        ],
205        2,
206    )),
207    AnyBitCircuit::B14(BitCircuit::new(
208        [
209            Node::Copy,
210            Node::Cmux(46, 1, 0),
211            Node::Cmux(14, 1, 0),
212            Node::None,
213        ],
214        2,
215    )),
216    AnyBitCircuit::B15(BitCircuit::new(
217        [
218            Node::Copy,
219            Node::Cmux(47, 1, 0),
220            Node::Cmux(15, 1, 0),
221            Node::None,
222        ],
223        2,
224    )),
225    AnyBitCircuit::B16(BitCircuit::new(
226        [
227            Node::Copy,
228            Node::Cmux(48, 1, 0),
229            Node::Cmux(16, 1, 0),
230            Node::None,
231        ],
232        2,
233    )),
234    AnyBitCircuit::B17(BitCircuit::new(
235        [
236            Node::Copy,
237            Node::Cmux(49, 1, 0),
238            Node::Cmux(17, 1, 0),
239            Node::None,
240        ],
241        2,
242    )),
243    AnyBitCircuit::B18(BitCircuit::new(
244        [
245            Node::Copy,
246            Node::Cmux(50, 1, 0),
247            Node::Cmux(18, 1, 0),
248            Node::None,
249        ],
250        2,
251    )),
252    AnyBitCircuit::B19(BitCircuit::new(
253        [
254            Node::Copy,
255            Node::Cmux(51, 1, 0),
256            Node::Cmux(19, 1, 0),
257            Node::None,
258        ],
259        2,
260    )),
261    AnyBitCircuit::B20(BitCircuit::new(
262        [
263            Node::Copy,
264            Node::Cmux(52, 1, 0),
265            Node::Cmux(20, 1, 0),
266            Node::None,
267        ],
268        2,
269    )),
270    AnyBitCircuit::B21(BitCircuit::new(
271        [
272            Node::Copy,
273            Node::Cmux(53, 1, 0),
274            Node::Cmux(21, 1, 0),
275            Node::None,
276        ],
277        2,
278    )),
279    AnyBitCircuit::B22(BitCircuit::new(
280        [
281            Node::Copy,
282            Node::Cmux(54, 1, 0),
283            Node::Cmux(22, 1, 0),
284            Node::None,
285        ],
286        2,
287    )),
288    AnyBitCircuit::B23(BitCircuit::new(
289        [
290            Node::Copy,
291            Node::Cmux(55, 1, 0),
292            Node::Cmux(23, 1, 0),
293            Node::None,
294        ],
295        2,
296    )),
297    AnyBitCircuit::B24(BitCircuit::new(
298        [
299            Node::Copy,
300            Node::Cmux(56, 1, 0),
301            Node::Cmux(24, 1, 0),
302            Node::None,
303        ],
304        2,
305    )),
306    AnyBitCircuit::B25(BitCircuit::new(
307        [
308            Node::Copy,
309            Node::Cmux(57, 1, 0),
310            Node::Cmux(25, 1, 0),
311            Node::None,
312        ],
313        2,
314    )),
315    AnyBitCircuit::B26(BitCircuit::new(
316        [
317            Node::Copy,
318            Node::Cmux(58, 1, 0),
319            Node::Cmux(26, 1, 0),
320            Node::None,
321        ],
322        2,
323    )),
324    AnyBitCircuit::B27(BitCircuit::new(
325        [
326            Node::Copy,
327            Node::Cmux(59, 1, 0),
328            Node::Cmux(27, 1, 0),
329            Node::None,
330        ],
331        2,
332    )),
333    AnyBitCircuit::B28(BitCircuit::new(
334        [
335            Node::Copy,
336            Node::Cmux(60, 1, 0),
337            Node::Cmux(28, 1, 0),
338            Node::None,
339        ],
340        2,
341    )),
342    AnyBitCircuit::B29(BitCircuit::new(
343        [
344            Node::Copy,
345            Node::Cmux(61, 1, 0),
346            Node::Cmux(29, 1, 0),
347            Node::None,
348        ],
349        2,
350    )),
351    AnyBitCircuit::B30(BitCircuit::new(
352        [
353            Node::Copy,
354            Node::Cmux(62, 1, 0),
355            Node::Cmux(30, 1, 0),
356            Node::None,
357        ],
358        2,
359    )),
360    AnyBitCircuit::B31(BitCircuit::new(
361        [
362            Node::Copy,
363            Node::Cmux(63, 1, 0),
364            Node::Cmux(31, 1, 0),
365            Node::None,
366        ],
367        2,
368    )),
369]);