CompositeCircuit.java 913 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. // Copyright (C) 2010 by Yan Huang <yhuang@virginia.edu>
  2. package YaoGC;
  3. public abstract class CompositeCircuit extends Circuit {
  4. protected Circuit[] subCircuits;
  5. protected int nSubCircuits;
  6. public CompositeCircuit(int inDegree, int outDegree, int nSubCircuits,
  7. String name) {
  8. super(inDegree, outDegree, name);
  9. this.nSubCircuits = nSubCircuits;
  10. subCircuits = new Circuit[nSubCircuits];
  11. }
  12. public void build() throws Exception {
  13. createInputWires();
  14. createSubCircuits();
  15. connectWires();
  16. defineOutputWires();
  17. fixInternalWires();
  18. }
  19. protected void createSubCircuits() throws Exception {
  20. for (int i = 0; i < nSubCircuits; i++)
  21. subCircuits[i].build();
  22. }
  23. abstract protected void connectWires() throws Exception;
  24. abstract protected void defineOutputWires();
  25. protected void fixInternalWires() {
  26. }
  27. protected void compute() {
  28. }
  29. protected void execute(boolean evaluate) {
  30. }
  31. }