def downloadFile(): inputfile = './tmp/myinput.txt' outputfile = './tmp/output.txt' benchfile = "./tmp/mybench.txt" t = False S = time.time() bench = parser.read_bench(filename=benchfile) c_input, c_logic, c_output = parser.parser_bench(bench) if t: print("parser bench time:", time.time() - S) x_input, x_logic, x_output = parser.build_bench(c_input, c_logic, c_output) if t: print("build bench time:", time.time() - S) _build_gate.build_logic(x_input, x_output, x_logic, str(inputfile), str(outputfile)) if t: print("run time:", time.time() - S) path = "./tmp/output.txt" return send_file(path, as_attachment=True)
def test_file_with_32_input(self): bench = parser.read_bench(filename="testcase/c17.bench.txt") c_input, c_logic, c_output = parser.parser_bench(bench) x_input, x_logic, x_output = parser.build_bench( c_input, c_logic, c_output) ans = [] for i in range(2): for j in range(2): for k in range(2): for y in range(2): for z in range(2): ans.append( str(i) + str(j) + str(k) + str(y) + str(z) + "\n") ans[-1] = ans[-1].strip("\n") with open("test_c17_ip32.txt", "w") as file: file.writelines(ans) _build_gate.build_logic(x_input, x_output, x_logic, str("test_c17_ip32.txt"), str("test_c17_op32.txt")) with open("test_c17_op32.txt", "r") as file: with open("testcase/test_c17_ans32.txt", "r") as ansfile: self.assertEqual(file.readlines(), ansfile.readlines())
def main(argv): inputfile = '' outputfile = '' benchfile = '' t = False try: opts, args = getopt.getopt(argv, "thi:o:b:", ["ifile=", "ofile="]) except getopt.GetoptError: print("file_aip.py -i <inputfile> -o <outputfile> -b <benchfile>") sys.exit(2) for opt, arg in opts: if opt == "-h": print("file_aip.py -i <inputfile> -o <outputfile> -b <benchfile>") sys.exit(2) elif opt == "-t": t = True elif opt in ("-i", "--ifile"): inputfile = arg elif opt in ("-o", "--ofile"): outputfile = arg elif opt in ("-b", "--bfile"): benchfile = arg else: pass #print(inputfile,outputfile,benchfile ) S = time.time() bench = parser.read_bench(filename=benchfile) c_input, c_logic, c_output = parser.parser_bench(bench) if t: print("parser bench time:", time.time() - S) x_input, x_logic, x_output = parser.build_bench(c_input, c_logic, c_output) if t: print("build bench time:", time.time() - S) _build_gate.build_logic(x_input, x_output, x_logic, str(inputfile), str(outputfile)) if t: print("run time:", time.time() - S)
import parser import _build_gate import time S = time.time() bench = parser.read_bench(filename="testcase/c432.bench.txt") c_input, c_logic, c_output = parser.parser_bench(bench) print(time.time() - S) x_input, x_logic, x_output = parser.build_bench(c_input, c_logic, c_output) print(time.time() - S) _build_gate.build_logic(x_input, x_output, x_logic, str("testcase/c432_1m_ip.txt"), str("test_c432_op32.txt")) print(time.time() - S)
def run_with_file_name(filename_bench,filename_input,filename_output): pass # print(x_input) # print(len(x_logic)) # print(x_output) if __name__ == "__main__": bench = read_bench() c_input, c_logic, c_output = parser_bench(bench) x_input, x_logic, x_output = build_bench(c_input, c_logic, c_output) #z = [i for i in x_input] #print(x_input,x_logic,x_output) _build_gate.build_logic(x_input, x_output, x_logic) ''' t1=["1111","11110","10111","11011","11101"] for j,i in enumerate(x_input.values()): set_value(i,t1[j]) # i.output() for i in x_output.values(): i.no_run() for i in c_output: print(i) #x_output[i].output() print(x_output[i].__str__()) print(x_output) '''