def testPrintRegisters(self): pipeline = Pipeline('', False) pipeline.FPRegs['F25'] = 15 pipeline.FPRegs['F2'] = 15.89 pipeline.FPRegs['F7'] = 78.56 sys.stdout = open('test.1', 'w') pipeline.print_registers() sys.stdout.close() reg_file = open('test.1') file_contents = reg_file.read() self.assertEqual(file_contents, "F2 F7 F25 \n15.89 78.56 15 \n") reg_file.close() try: os.remove('test.1') except OSError: pass
import sys from pipeline import Pipeline file_name = 'input4.txt'#input('Enter the name of the input data file: ') pipeline = Pipeline(file_name) timing_file = 't.1'#input('Enter the name of the timing file: ') #sys.stdout = open(timing_file, 'w') pipeline.execute_instructions() pipeline.print_timing() #sys.stdout.close() register_file = 'r.1'#input('Enter the name of the register file: ') #sys.stdout = open(register_file, 'w') pipeline.print_registers() #sys.stdout.close()