/** * The function evaluateCircuit calls other evaluate functions based on the circuit_score chose by * user. * * <p>-circuit_score onoff_ratio score = log(ON/OFF), where ON is the lowest ON in the truthtable, * and OFF is the highest off in the truthtable * * <p>-circuit_score noise_margin noise margin is computed from input REU distance from low margin * (if low) or high margin (if high) score = average noise margin of all logic gates used for * NOR/NOT only, and cannot be used if there are input gates and no logic gates * * <p>-circuit_score histogram score = 1 - overlap penalty, where overlap is from the worst pair * among ONs and OFFs in the truthtable * * <p>Circuit is evaluated by evaluating each gate, so the same function calls appear but with a * Gate parameter instead of LogicCircuit parameter */ public static void evaluateCircuit(LogicCircuit lc, GateLibrary gate_library, Args options) { refreshGateAttributes(lc, gate_library); // if sequential if (options.get_circuit_type() == DNACompiler.CircuitType.sequential) { SequentialHelper.setInitialREUs(lc, gate_library); HashMap<String, ArrayList<ArrayList<Double>>> track_reus = new HashMap<>(); for (Gate g : lc.get_Gates()) { track_reus.put(g.Name, new ArrayList<ArrayList<Double>>()); ArrayList<Double> copy_reus = new ArrayList<Double>(g.get_outreus()); track_reus.get(g.Name).add(copy_reus); track_reus.get(g.Name).add(copy_reus); } boolean converges = SequentialHelper.convergeREUs(lc, gate_library, options, track_reus); if (!converges) { lc.get_scores().set_onoff_ratio(0.0); lc.get_scores().set_noise_margin_contract(false); return; } } // if combinational else if (options.get_circuit_type() == DNACompiler.CircuitType.combinational) { simulateREU(lc, gate_library, options); } evaluateCircuitONOFFRatio(lc); if (options.is_noise_margin()) { evaluateCircuitNoiseMargin(lc, options); } if (options.is_snr()) { evaluateCircuitSNR(lc, options); } }
/** * histogram * * <p>Histogram overlap score worst-case = 0.0 and best-case = 1.0 */ public static void evaluateCircuitHistogramOverlap( LogicCircuit lc, GateLibrary gate_library, Args options) { // output gate _score (average) refreshGateAttributes(lc, gate_library); // if sequential if (options.get_circuit_type() == DNACompiler.CircuitType.sequential) { // set initial SequentialHelper.setInitialHistogramREUs(lc, gate_library); // track HashMap<String, ArrayList<ArrayList<double[]>>> track_reus = new HashMap<>(); for (Gate g : lc.get_Gates()) { track_reus.put(g.Name, new ArrayList<ArrayList<double[]>>()); ArrayList<double[]> copy_hist_reus = new ArrayList<double[]>(g.get_histogram_reus()); track_reus.get(g.Name).add(copy_hist_reus); track_reus.get(g.Name).add(copy_hist_reus); // looks for i-1 } // converge SequentialHelper.convergeHistogramREUs(lc, gate_library, options, track_reus); } // if combinational else if (options.get_circuit_type() == DNACompiler.CircuitType.combinational) { Evaluate.simulateHistogramREU(lc, gate_library, options); } double worst_out = Double.MAX_VALUE; for (int out = 0; out < lc.get_output_gates().size(); ++out) { Gate output = lc.get_output_gates().get(out); evaluateGateHistogramOverlap(output); if (output.get_scores().get_conv_overlap() < worst_out) { worst_out = output.get_scores().get_conv_overlap(); } } lc.get_scores().set_conv_overlap(worst_out); }
@Override public boolean hasNextProtocols() { return seqh.hasNextProtocols(); }
@Override public int getNextProtocols(NativeProtocol[] nativeProtocols, int pos) { return seqh.getNextProtocols(nativeProtocols, pos); }