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