F2ET_Wplus2_Wplus2.java 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. // by Boyang Wei
  2. package YaoGC;
  3. public class F2ET_Wplus2_Wplus2 extends CompositeCircuit {
  4. private final int w;
  5. private int s1; // sigmas
  6. private int s2;
  7. public F2ET_Wplus2_Wplus2(int w, int s1, int s2) {
  8. super(w + 2, w + 2, 2 * w + 2, "F2ET_" + (w + 2) + "_" + w + 2);
  9. this.w = w;
  10. this.s1 = s1;
  11. this.s2 = s2;
  12. }
  13. protected void createSubCircuits() throws Exception {
  14. for (int i = 0; i < 2 * w; i++)
  15. subCircuits[i] = XOR_2_1.newInstance();
  16. subCircuits[2 * w] = new FF10_Wplus1_Wplus1(w, false, s1);
  17. subCircuits[2 * w + 1] = new FF10_Wplus1_Wplus1(w, false, s2);
  18. s1 = s2 = 0;
  19. super.createSubCircuits();
  20. }
  21. protected void connectWires() throws Exception {
  22. // Enable wires
  23. inputWires[0].connectTo(subCircuits[2 * w].inputWires, 0);
  24. inputWires[1].connectTo(subCircuits[2 * w + 1].inputWires, 0);
  25. for (int i = 0; i < w; i++) {
  26. inputWires[i + 2].connectTo(subCircuits[2 * w].inputWires, i + 1);
  27. inputWires[i + 2].connectTo(subCircuits[i].inputWires, 1);
  28. subCircuits[2 * w].outputWires[i].connectTo(
  29. subCircuits[i].inputWires, 0);
  30. subCircuits[2 * w].outputWires[i].connectTo(
  31. subCircuits[i + w].inputWires, 1);
  32. subCircuits[i].outputWires[0].connectTo(
  33. subCircuits[2 * w + 1].inputWires, i + 1);
  34. subCircuits[2 * w + 1].outputWires[i].connectTo(
  35. subCircuits[i + w].inputWires, 0);
  36. }
  37. }
  38. protected void defineOutputWires() {
  39. outputWires[0] = subCircuits[2 * w].outputWires[w];
  40. outputWires[1] = subCircuits[2 * w + 1].outputWires[w];
  41. for (int i = 0; i < w; i++)
  42. outputWires[i + 2] = subCircuits[i + w].outputWires[0];
  43. }
  44. }