示例#1
0
def output_file(bench_file, num_cycles, fault, user_tv_str):
    from p3sim import netRead, printCkt
    from scan_chain_sim_result import outputComparator

    simulatorTxt = open("simulator.txt", "w+")
    circuit = netRead(bench_file)  # create original circuit
    clean_circuit = netRead(bench_file)
    Fault_bool = False

    # create circuit and update values
    good_circuit, goodList = getBasicSim(circuit, num_cycles, user_tv_str,
                                         Fault_bool, fault)
    simulatorTxt.write(
        "******************GOOD CIRCUIT SIM********************\n")
    simulatorTxt.write("Flip Flop & Primary Outputs @ n = " + str(num_cycles) +
                       "\n")
    simulatorTxt.write("User TV: " + user_tv_str + "\n")

    numFlipFlops = getNumFF(bench_file)

    printFFvalues(good_circuit,
                  simulatorTxt)  # call function that prints ff/value
    numPrimOutputs = getNumPrimaryOutputs(bench_file)

    printPOValues(good_circuit,
                  simulatorTxt)  # call function that prints PO value

    # make circuit with fault and update values
    Fault_bool = True
    badCircuit, badList = getBasicSim(clean_circuit, num_cycles, user_tv_str,
                                      Fault_bool, fault)

    simulatorTxt.write(
        "\n******************BAD CIRCUIT SIM********************\n")
    simulatorTxt.write("Fault: " + str(fault) + "\n")
    simulatorTxt.write("Flip Flop & Primary Outputs @ n = " + str(num_cycles) +
                       "\n")
    simulatorTxt.write(
        "\n******************FAULT DETECTION********************\n")
    if outputComparator(badList, goodList)[0]:
        compOut = "\n" + fault + " has been detected at cycle " + str(
            outputComparator(
                badList,
                goodList)[1]) + " with test vector " + user_tv_str + "\n"
        simulatorTxt.write(compOut)
    else:
        compOut = "\n" + fault + " has NOT been detected with test vector " + user_tv_str + "\n"
        simulatorTxt.write(compOut)
    # call function that prints ff/value
    printFFvalues(badCircuit, simulatorTxt)
    # function that prints output value
    printPOValues(badCircuit, simulatorTxt)
    print("\nCreated simulator.txt with results of simulation\n")
示例#2
0
def seq_data_analysis(bench_file, cycles):
    from p2sim import netRead
    from scan_chain_sim_result import LFSRtestGen, scanFaultDetector
    from genFaultList import getFaultListStudy

    first_line_csv = ['Initialization ->', 'FF=U', 'FF=1', 'FF=0']
    with open('seq_simulator_analysis.csv', 'w') as csvFile:
        writer = csv.writer(csvFile)
        writer.writerow(first_line_csv)

    # generating fault list for circuit
    fault_list = getFaultListStudy(bench_file)
    total_num_faults = len(fault_list)
    print("\ncircuit has: " + total_num_faults + " test vectors\n")

    # generating a Mersenne tv and return list with a tv for every fault we r testing
    _, input_TVs = LFSRtestGen(bench_file, total_num_faults)
    num_tvs = len(input_TVs)
    print("\njust generated: " + num_tvs + " test vectors\n")

    # creating csv file to plot data
    num_fault = 0

    circuit = netRead(bench_file)
    # doing initialization for corresponding circuits DFF
    circuit_u = netRead(bench_file)
    # circuit_one = ff_init_one(original_circuit)
    # circuit_zero = ff_init_zero(original_circuit)

    while num_fault < total_num_faults:
        column = 0
        while column < 3:
            print("column #:" + str(column) + "\n")

            Fault_bool = True
            # call getBasicSim for each circuit w/fault
            circuit_u_f = getBasicSim(circuit_u, cycles, input_TVs[num_fault],
                                      Fault_bool, fault_list[num_fault])
            # circuit_one_f = getBasicSim(circuit_one, cycles, input_TVs[num_fault], Fault_bool, fault_list[num_fault])
            # circuit_zero_f = getBasicSim(circuit_zero, cycles, input_TVs[num_fault], Fault_bool, fault_list[num_fault])

            Fault_bool = False
            # call getBasicSim for each circuit wout/fault
            circuit_u_nf = getBasicSim(circuit_u, cycles, input_TVs[num_fault],
                                       Fault_bool, fault_list[num_fault])
            # circuit_one_nf = getBasicSim(circuit_one, cycles, input_TVs[num_fault], Fault_bool, fault_list[num_fault])
            # circuit_zero_nf = getBasicSim(circuit_zero, cycles, input_TVs[num_fault], Fault_bool, fault_list[num_fault])

            # call function that gets cycle where fault was found
            scanFaultDetector(circuit)

        num_fault += 1
示例#3
0
def scan_output_file(bench_file, testApplyCycles, fault, scanType, inputTVs,
                     flipFlopTVs, faultsFound, cycleFaultFound):
    from p3sim import netRead

    # Create dictionary of circuit via benchmark file
    circuit = netRead(bench_file)

    # Run circuit simulation to generate the results of the good circuit
    goodScanData = getBasicSim(circuit, testApplyCycles, 0, scanType, False,
                               fault, flipFlopTVs, inputTVs)

    # Run circuit simulation to generate the results of the faulty circuit
    faultScanData = getBasicSim(circuit, testApplyCycles, 0, scanType, True,
                                fault, flipFlopTVs, inputTVs)

    # Detect the cycles at which faults are detected
    faultAnalysis = scanFaultDetector(goodScanData, faultScanData, faultsFound,
                                      cycleFaultFound, scanType)

    return faultAnalysis
def scan_output_file(bench_file, testApplyCycles, fault, scanType):
    from p3sim import netRead, printCkt

    goodScanData = {}
    faultScanData = {}


    scanInTV, PrimaryInputs = LFSRtestGen(bench_file, testApplyCycles)

    # Text file that will hold all the results
    simulatorTxt = open("scan_chain_results.txt", "w+")

    # Create dictionary of circuit via benchmark file
    circuit = netRead(bench_file)

    # Run circuit simulation to generate the results of the good circuit
    goodScanData = getBasicSim(circuit, testApplyCycles, 0, scanType, bench_file, False, fault, scanInTV, PrimaryInputs)

    
    # Print the final results of the golden circuit
    #printCkt(good_circuit)

    # Write into the text file that will hold all the results
    simulatorTxt.write("******************GOOD CIRCUIT SIM********************\n")
    
    simulatorTxt.write("Flip Flop & Primary Outputs @ n = " + str(testApplyCycles) + " test apply cycles\n")
    
    # Get the number of flip flops in the circuit
    numFlipFlops = getNumFF(bench_file)

    simulatorTxt.write("D-Type Flip Flops: " + numFlipFlops + "\n")
    printFFvalues(goodScanData["circuit"], simulatorTxt)

    # Get number of primary outputs and print them to file
    numPrimOutputs = getNumPrimaryOutputs(bench_file)

    simulatorTxt.write("\nPrimary Outputs: " + str(numPrimOutputs) + "\n")

    printPOValues(goodScanData["circuit"], simulatorTxt)

    faultScanData = getBasicSim(circuit, testApplyCycles, 0, scanType, bench_file, True, fault, scanInTV, PrimaryInputs)
    # badCircuit = getFaultCvgSeq(circuit, fault, num_cycles)  # make circuit with fault and update values - JAS TD
    simulatorTxt.write("\n\n******************BAD CIRCUIT SIM********************\n")
    simulatorTxt.write("Fault: " + str(fault) + "\n")
    simulatorTxt.write("Flip Flop & Primary Outputs @ n = " + str(testApplyCycles) + " test apply cycles\n")
    simulatorTxt.write("*****************************************************\n")
    simulatorTxt.write("D-Type Flip Flops: " + numFlipFlops + "\n")
    # call function that prints ff/value
    printFFvalues(faultScanData["circuit"], simulatorTxt)
    simulatorTxt.write("\nPrimary Outputs: " + str(numPrimOutputs) + "\n")
    printPOValues(faultScanData["circuit"], simulatorTxt)

    simulatorTxt.write("\n\n******************FAULT DETECTION********************")
    scanFaultDetector(goodScanData, faultScanData, fault, simulatorTxt, scanType)
    
    # if (outputComparator(faultScanData["PrimaryOutputs"], goodScanData["PrimaryOutputs"])[0]):
    #     compOut = "\n" + fault + " has been detected at cycle " + str(outputComparator(badList, goodList)[1]) + " with test vector " + user_tv_str + "\n"
    #     simulatorTxt.write(compOut)
    # else:
    #     compOut = "\n" + fault + " has NOT been detected with test vector " + user_tv_str + "\n"
    #     simulatorTxt.write(compOut)

    simulatorTxt.close()

    print("created scan_chain_results.txt")
        # Counter to keep track of the number of DFFs
        dffCounter = 0

        # For each gate in the circuit, find the ones that DFFs
        for gate in circuit:
            if circuit[gate][0] == 'DFF':
                dffCounter = dffCounter + 1

        scanOut = math.ceil(dffCounter / 2)

    if scanType == 'full':

        # For each gate in the circuit, find the ones that DFFs
        for gate in circuit:
            if circuit[gate][0] == 'DFF':
                scanOut = scanOut + 1

    return scanOut


# If this module is executed alone
if __name__ == "__main__":
    # let's read the name of bench file
    fileName = "s27.bench"
    testVector = [1, 0, 1]
    circuit = p3sim.netRead(fileName)
    #create own tuple testvestor
    #p3sim.printCkt(circuit)
    #print(circuit)
    #circuit = getBasicSim(circuit, 5, 0, "full", fileName)