/** * ********************************************************************* * * <p>Synopsis [ ] * * <p>keep tracing back to child until find one with logics defined assume it has either 1 or 2 * children this method is recursive Note: Recursion is not necessary and does not occur if we * sort the gates by distance to input, then simulate logic in that order. * * <p>logic is computed according to Gate type and input logics * * <p>********************************************************************* */ public static void simulateLogic(Gate g) { if (g.is_unvisited()) { ArrayList<Gate> children = g.getChildren(); for (Gate child : children) { if (child.is_unvisited()) { simulateLogic(child); // recursive } } // if all children have been visited, visit the current gate 'g' g.set_unvisited(false); g.set_logics(GateUtil.computeGateLogics(g)); } }