arnaucube
arnaucube/poulpyPublic Self-hosted repository
poulpy/poulpy-schemes/src/tfhe/bdd_arithmetic/circuits/u32/and_codegen.rs
poulpy-schemes/src/tfhe/bdd_arithmetic/circuits/u32/and_codegen.rsRaw
  1use crate::tfhe::bdd_arithmetic::{BitCircuit, BitCircuitInfo, Circuit, GetBitCircuitInfo, Node};
  2pub(crate) enum AnyBitCircuit {
  3    B0(BitCircuit<3, 2>),
  4    B1(BitCircuit<3, 2>),
  5    B2(BitCircuit<3, 2>),
  6    B3(BitCircuit<3, 2>),
  7    B4(BitCircuit<3, 2>),
  8    B5(BitCircuit<3, 2>),
  9    B6(BitCircuit<3, 2>),
 10    B7(BitCircuit<3, 2>),
 11    B8(BitCircuit<3, 2>),
 12    B9(BitCircuit<3, 2>),
 13    B10(BitCircuit<3, 2>),
 14    B11(BitCircuit<3, 2>),
 15    B12(BitCircuit<3, 2>),
 16    B13(BitCircuit<3, 2>),
 17    B14(BitCircuit<3, 2>),
 18    B15(BitCircuit<3, 2>),
 19    B16(BitCircuit<3, 2>),
 20    B17(BitCircuit<3, 2>),
 21    B18(BitCircuit<3, 2>),
 22    B19(BitCircuit<3, 2>),
 23    B20(BitCircuit<3, 2>),
 24    B21(BitCircuit<3, 2>),
 25    B22(BitCircuit<3, 2>),
 26    B23(BitCircuit<3, 2>),
 27    B24(BitCircuit<3, 2>),
 28    B25(BitCircuit<3, 2>),
 29    B26(BitCircuit<3, 2>),
 30    B27(BitCircuit<3, 2>),
 31    B28(BitCircuit<3, 2>),
 32    B29(BitCircuit<3, 2>),
 33    B30(BitCircuit<3, 2>),
 34    B31(BitCircuit<3, 2>),
 35}
 36
 37impl BitCircuitInfo for AnyBitCircuit {
 38    fn info(&self) -> (&[Node], &[usize], usize) {
 39        match self {
 40            AnyBitCircuit::B0(bit_circuit) => (
 41                bit_circuit.nodes.as_ref(),
 42                bit_circuit.levels.as_ref(),
 43                bit_circuit.max_inter_state,
 44            ),
 45            AnyBitCircuit::B1(bit_circuit) => (
 46                bit_circuit.nodes.as_ref(),
 47                bit_circuit.levels.as_ref(),
 48                bit_circuit.max_inter_state,
 49            ),
 50            AnyBitCircuit::B2(bit_circuit) => (
 51                bit_circuit.nodes.as_ref(),
 52                bit_circuit.levels.as_ref(),
 53                bit_circuit.max_inter_state,
 54            ),
 55            AnyBitCircuit::B3(bit_circuit) => (
 56                bit_circuit.nodes.as_ref(),
 57                bit_circuit.levels.as_ref(),
 58                bit_circuit.max_inter_state,
 59            ),
 60            AnyBitCircuit::B4(bit_circuit) => (
 61                bit_circuit.nodes.as_ref(),
 62                bit_circuit.levels.as_ref(),
 63                bit_circuit.max_inter_state,
 64            ),
 65            AnyBitCircuit::B5(bit_circuit) => (
 66                bit_circuit.nodes.as_ref(),
 67                bit_circuit.levels.as_ref(),
 68                bit_circuit.max_inter_state,
 69            ),
 70            AnyBitCircuit::B6(bit_circuit) => (
 71                bit_circuit.nodes.as_ref(),
 72                bit_circuit.levels.as_ref(),
 73                bit_circuit.max_inter_state,
 74            ),
 75            AnyBitCircuit::B7(bit_circuit) => (
 76                bit_circuit.nodes.as_ref(),
 77                bit_circuit.levels.as_ref(),
 78                bit_circuit.max_inter_state,
 79            ),
 80            AnyBitCircuit::B8(bit_circuit) => (
 81                bit_circuit.nodes.as_ref(),
 82                bit_circuit.levels.as_ref(),
 83                bit_circuit.max_inter_state,
 84            ),
 85            AnyBitCircuit::B9(bit_circuit) => (
 86                bit_circuit.nodes.as_ref(),
 87                bit_circuit.levels.as_ref(),
 88                bit_circuit.max_inter_state,
 89            ),
 90            AnyBitCircuit::B10(bit_circuit) => (
 91                bit_circuit.nodes.as_ref(),
 92                bit_circuit.levels.as_ref(),
 93                bit_circuit.max_inter_state,
 94            ),
 95            AnyBitCircuit::B11(bit_circuit) => (
 96                bit_circuit.nodes.as_ref(),
 97                bit_circuit.levels.as_ref(),
 98                bit_circuit.max_inter_state,
 99            ),
100            AnyBitCircuit::B12(bit_circuit) => (
101                bit_circuit.nodes.as_ref(),
102                bit_circuit.levels.as_ref(),
103                bit_circuit.max_inter_state,
104            ),
105            AnyBitCircuit::B13(bit_circuit) => (
106                bit_circuit.nodes.as_ref(),
107                bit_circuit.levels.as_ref(),
108                bit_circuit.max_inter_state,
109            ),
110            AnyBitCircuit::B14(bit_circuit) => (
111                bit_circuit.nodes.as_ref(),
112                bit_circuit.levels.as_ref(),
113                bit_circuit.max_inter_state,
114            ),
115            AnyBitCircuit::B15(bit_circuit) => (
116                bit_circuit.nodes.as_ref(),
117                bit_circuit.levels.as_ref(),
118                bit_circuit.max_inter_state,
119            ),
120            AnyBitCircuit::B16(bit_circuit) => (
121                bit_circuit.nodes.as_ref(),
122                bit_circuit.levels.as_ref(),
123                bit_circuit.max_inter_state,
124            ),
125            AnyBitCircuit::B17(bit_circuit) => (
126                bit_circuit.nodes.as_ref(),
127                bit_circuit.levels.as_ref(),
128                bit_circuit.max_inter_state,
129            ),
130            AnyBitCircuit::B18(bit_circuit) => (
131                bit_circuit.nodes.as_ref(),
132                bit_circuit.levels.as_ref(),
133                bit_circuit.max_inter_state,
134            ),
135            AnyBitCircuit::B19(bit_circuit) => (
136                bit_circuit.nodes.as_ref(),
137                bit_circuit.levels.as_ref(),
138                bit_circuit.max_inter_state,
139            ),
140            AnyBitCircuit::B20(bit_circuit) => (
141                bit_circuit.nodes.as_ref(),
142                bit_circuit.levels.as_ref(),
143                bit_circuit.max_inter_state,
144            ),
145            AnyBitCircuit::B21(bit_circuit) => (
146                bit_circuit.nodes.as_ref(),
147                bit_circuit.levels.as_ref(),
148                bit_circuit.max_inter_state,
149            ),
150            AnyBitCircuit::B22(bit_circuit) => (
151                bit_circuit.nodes.as_ref(),
152                bit_circuit.levels.as_ref(),
153                bit_circuit.max_inter_state,
154            ),
155            AnyBitCircuit::B23(bit_circuit) => (
156                bit_circuit.nodes.as_ref(),
157                bit_circuit.levels.as_ref(),
158                bit_circuit.max_inter_state,
159            ),
160            AnyBitCircuit::B24(bit_circuit) => (
161                bit_circuit.nodes.as_ref(),
162                bit_circuit.levels.as_ref(),
163                bit_circuit.max_inter_state,
164            ),
165            AnyBitCircuit::B25(bit_circuit) => (
166                bit_circuit.nodes.as_ref(),
167                bit_circuit.levels.as_ref(),
168                bit_circuit.max_inter_state,
169            ),
170            AnyBitCircuit::B26(bit_circuit) => (
171                bit_circuit.nodes.as_ref(),
172                bit_circuit.levels.as_ref(),
173                bit_circuit.max_inter_state,
174            ),
175            AnyBitCircuit::B27(bit_circuit) => (
176                bit_circuit.nodes.as_ref(),
177                bit_circuit.levels.as_ref(),
178                bit_circuit.max_inter_state,
179            ),
180            AnyBitCircuit::B28(bit_circuit) => (
181                bit_circuit.nodes.as_ref(),
182                bit_circuit.levels.as_ref(),
183                bit_circuit.max_inter_state,
184            ),
185            AnyBitCircuit::B29(bit_circuit) => (
186                bit_circuit.nodes.as_ref(),
187                bit_circuit.levels.as_ref(),
188                bit_circuit.max_inter_state,
189            ),
190            AnyBitCircuit::B30(bit_circuit) => (
191                bit_circuit.nodes.as_ref(),
192                bit_circuit.levels.as_ref(),
193                bit_circuit.max_inter_state,
194            ),
195            AnyBitCircuit::B31(bit_circuit) => (
196                bit_circuit.nodes.as_ref(),
197                bit_circuit.levels.as_ref(),
198                bit_circuit.max_inter_state,
199            ),
200        }
201    }
202}
203
204impl GetBitCircuitInfo<u32> for Circuit<AnyBitCircuit, 32usize> {
205    fn input_size(&self) -> usize {
206        2 * u32::BITS as usize
207    }
208    fn output_size(&self) -> usize {
209        u32::BITS as usize
210    }
211    fn get_circuit(&self, bit: usize) -> (&[Node], &[usize], usize) {
212        self.0[bit].info()
213    }
214}
215
216pub(crate) static OUTPUT_CIRCUITS: Circuit<AnyBitCircuit, 32usize> = Circuit([
217    AnyBitCircuit::B0(BitCircuit::new(
218        [Node::new(0, 0, 0), Node::new(32, 1, 0), Node::new(0, 1, 0)],
219        [0, 2],
220        2,
221    )),
222    AnyBitCircuit::B1(BitCircuit::new(
223        [Node::new(1, 0, 0), Node::new(33, 1, 0), Node::new(1, 1, 0)],
224        [0, 2],
225        2,
226    )),
227    AnyBitCircuit::B2(BitCircuit::new(
228        [Node::new(2, 0, 0), Node::new(34, 1, 0), Node::new(2, 1, 0)],
229        [0, 2],
230        2,
231    )),
232    AnyBitCircuit::B3(BitCircuit::new(
233        [Node::new(3, 0, 0), Node::new(35, 1, 0), Node::new(3, 1, 0)],
234        [0, 2],
235        2,
236    )),
237    AnyBitCircuit::B4(BitCircuit::new(
238        [Node::new(4, 0, 0), Node::new(36, 1, 0), Node::new(4, 1, 0)],
239        [0, 2],
240        2,
241    )),
242    AnyBitCircuit::B5(BitCircuit::new(
243        [Node::new(5, 0, 0), Node::new(37, 1, 0), Node::new(5, 1, 0)],
244        [0, 2],
245        2,
246    )),
247    AnyBitCircuit::B6(BitCircuit::new(
248        [Node::new(6, 0, 0), Node::new(38, 1, 0), Node::new(6, 1, 0)],
249        [0, 2],
250        2,
251    )),
252    AnyBitCircuit::B7(BitCircuit::new(
253        [Node::new(7, 0, 0), Node::new(39, 1, 0), Node::new(7, 1, 0)],
254        [0, 2],
255        2,
256    )),
257    AnyBitCircuit::B8(BitCircuit::new(
258        [Node::new(8, 0, 0), Node::new(40, 1, 0), Node::new(8, 1, 0)],
259        [0, 2],
260        2,
261    )),
262    AnyBitCircuit::B9(BitCircuit::new(
263        [Node::new(9, 0, 0), Node::new(41, 1, 0), Node::new(9, 1, 0)],
264        [0, 2],
265        2,
266    )),
267    AnyBitCircuit::B10(BitCircuit::new(
268        [
269            Node::new(10, 0, 0),
270            Node::new(42, 1, 0),
271            Node::new(10, 1, 0),
272        ],
273        [0, 2],
274        2,
275    )),
276    AnyBitCircuit::B11(BitCircuit::new(
277        [
278            Node::new(11, 0, 0),
279            Node::new(43, 1, 0),
280            Node::new(11, 1, 0),
281        ],
282        [0, 2],
283        2,
284    )),
285    AnyBitCircuit::B12(BitCircuit::new(
286        [
287            Node::new(12, 0, 0),
288            Node::new(44, 1, 0),
289            Node::new(12, 1, 0),
290        ],
291        [0, 2],
292        2,
293    )),
294    AnyBitCircuit::B13(BitCircuit::new(
295        [
296            Node::new(13, 0, 0),
297            Node::new(45, 1, 0),
298            Node::new(13, 1, 0),
299        ],
300        [0, 2],
301        2,
302    )),
303    AnyBitCircuit::B14(BitCircuit::new(
304        [
305            Node::new(14, 0, 0),
306            Node::new(46, 1, 0),
307            Node::new(14, 1, 0),
308        ],
309        [0, 2],
310        2,
311    )),
312    AnyBitCircuit::B15(BitCircuit::new(
313        [
314            Node::new(15, 0, 0),
315            Node::new(47, 1, 0),
316            Node::new(15, 1, 0),
317        ],
318        [0, 2],
319        2,
320    )),
321    AnyBitCircuit::B16(BitCircuit::new(
322        [
323            Node::new(16, 0, 0),
324            Node::new(48, 1, 0),
325            Node::new(16, 1, 0),
326        ],
327        [0, 2],
328        2,
329    )),
330    AnyBitCircuit::B17(BitCircuit::new(
331        [
332            Node::new(17, 0, 0),
333            Node::new(49, 1, 0),
334            Node::new(17, 1, 0),
335        ],
336        [0, 2],
337        2,
338    )),
339    AnyBitCircuit::B18(BitCircuit::new(
340        [
341            Node::new(18, 0, 0),
342            Node::new(50, 1, 0),
343            Node::new(18, 1, 0),
344        ],
345        [0, 2],
346        2,
347    )),
348    AnyBitCircuit::B19(BitCircuit::new(
349        [
350            Node::new(19, 0, 0),
351            Node::new(51, 1, 0),
352            Node::new(19, 1, 0),
353        ],
354        [0, 2],
355        2,
356    )),
357    AnyBitCircuit::B20(BitCircuit::new(
358        [
359            Node::new(20, 0, 0),
360            Node::new(52, 1, 0),
361            Node::new(20, 1, 0),
362        ],
363        [0, 2],
364        2,
365    )),
366    AnyBitCircuit::B21(BitCircuit::new(
367        [
368            Node::new(21, 0, 0),
369            Node::new(53, 1, 0),
370            Node::new(21, 1, 0),
371        ],
372        [0, 2],
373        2,
374    )),
375    AnyBitCircuit::B22(BitCircuit::new(
376        [
377            Node::new(22, 0, 0),
378            Node::new(54, 1, 0),
379            Node::new(22, 1, 0),
380        ],
381        [0, 2],
382        2,
383    )),
384    AnyBitCircuit::B23(BitCircuit::new(
385        [
386            Node::new(23, 0, 0),
387            Node::new(55, 1, 0),
388            Node::new(23, 1, 0),
389        ],
390        [0, 2],
391        2,
392    )),
393    AnyBitCircuit::B24(BitCircuit::new(
394        [
395            Node::new(24, 0, 0),
396            Node::new(56, 1, 0),
397            Node::new(24, 1, 0),
398        ],
399        [0, 2],
400        2,
401    )),
402    AnyBitCircuit::B25(BitCircuit::new(
403        [
404            Node::new(25, 0, 0),
405            Node::new(57, 1, 0),
406            Node::new(25, 1, 0),
407        ],
408        [0, 2],
409        2,
410    )),
411    AnyBitCircuit::B26(BitCircuit::new(
412        [
413            Node::new(26, 0, 0),
414            Node::new(58, 1, 0),
415            Node::new(26, 1, 0),
416        ],
417        [0, 2],
418        2,
419    )),
420    AnyBitCircuit::B27(BitCircuit::new(
421        [
422            Node::new(27, 0, 0),
423            Node::new(59, 1, 0),
424            Node::new(27, 1, 0),
425        ],
426        [0, 2],
427        2,
428    )),
429    AnyBitCircuit::B28(BitCircuit::new(
430        [
431            Node::new(28, 0, 0),
432            Node::new(60, 1, 0),
433            Node::new(28, 1, 0),
434        ],
435        [0, 2],
436        2,
437    )),
438    AnyBitCircuit::B29(BitCircuit::new(
439        [
440            Node::new(29, 0, 0),
441            Node::new(61, 1, 0),
442            Node::new(29, 1, 0),
443        ],
444        [0, 2],
445        2,
446    )),
447    AnyBitCircuit::B30(BitCircuit::new(
448        [
449            Node::new(30, 0, 0),
450            Node::new(62, 1, 0),
451            Node::new(30, 1, 0),
452        ],
453        [0, 2],
454        2,
455    )),
456    AnyBitCircuit::B31(BitCircuit::new(
457        [
458            Node::new(31, 0, 0),
459            Node::new(63, 1, 0),
460            Node::new(31, 1, 0),
461        ],
462        [0, 2],
463        2,
464    )),
465]);