def testProcessLoadBoolRAA(self): self.simulator.decoder.next_instruction_index = LOADBOOL_INDEX self.simulator.current_instruction = self.simulator.decoder.decode_next() self.simulator.memory = Memory(40, 0xeeeeee01ee) self.simulator.registers[1].value = 8 # address self.simulator.process_load() self.assertEqual(1, self.simulator.registers[3].value)
def testProcessOneInstructionStoreBoolRAA(self): self.simulator.decoder.next_instruction_index = STOREBOOL_INDEX self.simulator.memory = Memory(40, 0xeeeeeeeeee) self.simulator.registers[1].value = 8 # address self.simulator.registers[3].value = 0x01 # value self.simulator.process_one_instruction() self.assertEqual(0xeeeeee01ee, self.simulator.memory.raw_memory)
def testProcessOneInstructionStoreIntRAA(self): self.simulator.decoder.next_instruction_index = STOREINT_INDEX self.simulator.memory = Memory(48, 0xeeeeeeeeeeee) self.simulator.registers[1].value = 8 # address self.simulator.registers[3].value = 0x12341234 # value self.simulator.process_one_instruction() self.assertEqual(0xee12341234ee, self.simulator.memory.raw_memory)
def testProcessLoadStateRAA(self): self.simulator.decoder.next_instruction_index = LOADSTATE_INDEX self.simulator.current_instruction = self.simulator.decoder.decode_next() self.simulator.memory = Memory(40, 0xeeee1234ee) self.simulator.registers[1].value = 8 # address self.simulator.process_load() self.assertEqual(0x1234, self.simulator.registers[3].value)
def testProcessStoreBoolADR(self): self.simulator.decoder.next_instruction_index = STOREBOOL_INDEX + 1 self.simulator.current_instruction = self.simulator.decoder.decode_next() self.simulator.memory = Memory(40, 0xeeeeeeeeee) self.simulator.registers[3].value = 0x01 # value self.simulator.process_store() self.assertEqual(0xeeeeee01ee, self.simulator.memory.raw_memory)
def testProcessStoreIntADR(self): self.simulator.decoder.next_instruction_index = STOREINT_INDEX + 1 self.simulator.current_instruction = self.simulator.decoder.decode_next() self.simulator.memory = Memory(48, 0xeeeeeeeeeeee) self.simulator.registers[3].value = 0x12341234 # value self.simulator.process_store() self.assertEqual(0xee12341234ee, self.simulator.memory.raw_memory)
def testProcessStoreStateRAA(self): self.simulator.decoder.next_instruction_index = STORESTATE_INDEX self.simulator.current_instruction = self.simulator.decoder.decode_next() self.simulator.memory = Memory(40, 0xeeeeeeeeee) self.simulator.registers[1].value = 8 # address self.simulator.registers[3].value = 0x1234 # value self.simulator.process_store() self.assertEqual(0xeeee1234ee, self.simulator.memory.raw_memory)
def process_config(self, config): max_exec_time = 0 new_configs = [] for core in self.cores: core.reset_execution() core.setup_cfg_memory(Memory(self.cfg_size, config)) # core.setup_cfg_memory(config) core.process_instructions() new_configs += core.new_configs max_exec_time = max(core.executed_cycles, max_exec_time) return max_exec_time, new_configs
def setUpSimOnInstruction(self, instruction): asm = ASM() bit_instructions = [asm.process_line(instruction)] decoder = Decoder(bit_instructions) memory = Memory(0, 0) self.simulator = Core(decoder, memory)
def testProcessOneInstructionLoadStateADR(self): self.simulator.decoder.next_instruction_index = LOADSTATE_INDEX + 1 self.simulator.memory = Memory(40, 0xeeee1234ee) self.simulator.process_one_instruction() self.assertEqual(0x1234, self.simulator.registers[3].value)
def testProcessOneInstructionLoadIntRAA(self): self.simulator.decoder.next_instruction_index = LOADINT_INDEX self.simulator.memory = Memory(48, 0xee12341234ee) self.simulator.registers[1].value = 8 # address self.simulator.process_one_instruction() self.assertEqual(0x12341234, self.simulator.registers[3].value)
def testProcessLoadIntADR(self): self.simulator.decoder.next_instruction_index = LOADINT_INDEX + 1 self.simulator.current_instruction = self.simulator.decoder.decode_next() self.simulator.memory = Memory(48, 0xee12341234ee) self.simulator.process_load() self.assertEqual(0x12341234, self.simulator.registers[3].value)
def testProcessOneInstructionLoadByteRAA(self): self.simulator.decoder.next_instruction_index = LOADBYTE_INDEX self.simulator.memory = Memory(40, 0xeeeeee24ee) self.simulator.registers[1].value = 8 # address self.simulator.process_one_instruction() self.assertEqual(0x24, self.simulator.registers[3].value)
def testProcessLoadByteADR(self): self.simulator.decoder.next_instruction_index = LOADBYTE_INDEX + 1 self.simulator.current_instruction = self.simulator.decoder.decode_next() self.simulator.memory = Memory(40, 0xeeeeee24ee) self.simulator.process_load() self.assertEqual(0x24, self.simulator.registers[3].value)
def __init__(self, parent, mem_file=None, bin_file=None): self.parent = parent parent.title("SDVS") bin_instructions = [] memory = Memory(0, 0) if bin_file and os.path.exists(bin_file): bin_instructions = BinaryReader.read_instructions(bin_file) if mem_file and os.path.exists(mem_file): raw_memory = BinaryReader.read_memory(mem_file) memory = Memory(raw_memory.bit_length(), raw_memory) self.simulator = Core(Decoder(bin_instructions), memory) # Frame definitions self.left_frame = tk.Frame(parent, width=100) # top left self.instruction_title_frame = tk.Frame(self.left_frame) self.instruction_data_frame = tk.Frame(self.left_frame) self.right_frame = tk.Frame(parent, width=200) # top right self.memory_frame = tk.Frame(self.right_frame) # top memory self.memory_title_frame = tk.Frame(self.memory_frame) self.memory_data_frame = tk.Frame(self.memory_frame) self.registers_frame = tk.Frame(self.right_frame) # top registers self.registers_title_frame = tk.Frame(self.registers_frame) self.registers_data_frame = tk.Frame(self.registers_frame) self.buttons_frame = tk.Frame(self.right_frame) # Instruction Variables self.pc = tk.StringVar() self.op_code = tk.StringVar() self.cfg_mask = tk.StringVar() self.rd = tk.StringVar() self.ra = tk.StringVar() self.rb = tk.StringVar() self.imma = tk.StringVar() self.immb = tk.StringVar() self.address = tk.StringVar() self.type = tk.StringVar() self.clear_instruction() # Instruction Values self.label_pc_value = tk.Label(self.instruction_data_frame, textvariable=self.pc) self.label_op_code_value = tk.Label(self.instruction_data_frame, textvariable=self.op_code) self.label_cfg_mask_value = tk.Label(self.instruction_data_frame, textvariable=self.cfg_mask) self.label_type_value = tk.Label(self.instruction_data_frame, textvariable=self.type) self.label_rd_value = tk.Label(self.instruction_data_frame, textvariable=self.rd) self.label_ra_value = tk.Label(self.instruction_data_frame, textvariable=self.ra) self.label_rb_value = tk.Label(self.instruction_data_frame, textvariable=self.rb) self.label_imma_value = tk.Label(self.instruction_data_frame, textvariable=self.imma) self.label_immb_value = tk.Label(self.instruction_data_frame, textvariable=self.immb) self.label_address_value = tk.Label(self.instruction_data_frame, textvariable=self.address) # Memory variables self.memory = tk.StringVar() self.memory.set("0") self.label_memory_value = tk.Label(self.memory_frame, textvariable=self.memory) # Registers variables self.registers = [ tk.StringVar(), tk.StringVar(), tk.StringVar(), tk.StringVar(), tk.StringVar(), tk.StringVar(), tk.StringVar(), tk.StringVar(), tk.StringVar(), tk.StringVar(), tk.StringVar(), tk.StringVar(), tk.StringVar(), tk.StringVar(), tk.StringVar(), tk.StringVar() ] self.clear_registers() self.label_r0_value = tk.Label(self.registers_data_frame, textvariable=self.registers[0]) self.label_r1_value = tk.Label(self.registers_data_frame, textvariable=self.registers[1]) self.label_r2_value = tk.Label(self.registers_data_frame, textvariable=self.registers[2]) self.label_r3_value = tk.Label(self.registers_data_frame, textvariable=self.registers[3]) self.label_r4_value = tk.Label(self.registers_data_frame, textvariable=self.registers[4]) self.label_r5_value = tk.Label(self.registers_data_frame, textvariable=self.registers[5]) self.label_r6_value = tk.Label(self.registers_data_frame, textvariable=self.registers[6]) self.label_r7_value = tk.Label(self.registers_data_frame, textvariable=self.registers[7]) self.label_r8_value = tk.Label(self.registers_data_frame, textvariable=self.registers[8]) self.label_r9_value = tk.Label(self.registers_data_frame, textvariable=self.registers[9]) self.label_r10_value = tk.Label(self.registers_data_frame, textvariable=self.registers[10]) self.label_r11_value = tk.Label(self.registers_data_frame, textvariable=self.registers[11]) self.label_r12_value = tk.Label(self.registers_data_frame, textvariable=self.registers[12]) self.label_r13_value = tk.Label(self.registers_data_frame, textvariable=self.registers[13]) self.label_r14_value = tk.Label(self.registers_data_frame, textvariable=self.registers[14]) self.label_r15_value = tk.Label(self.registers_data_frame, textvariable=self.registers[15]) self.register_labels = [ self.label_r0_value, self.label_r1_value, self.label_r2_value, self.label_r3_value, self.label_r4_value, self.label_r5_value, self.label_r6_value, self.label_r7_value, self.label_r8_value, self.label_r9_value, self.label_r10_value, self.label_r11_value, self.label_r12_value, self.label_r13_value, self.label_r14_value, self.label_r15_value ] # Buttons self.step_button = ttk.Button(self.buttons_frame, text="Step", command=self.process_one_instruction) self.step_button.pack() self.close_button = ttk.Button(self.buttons_frame, text="Quit", command=parent.quit) self.close_button.pack() # Widgets and layout - Instruction self.left_frame.grid(row=0, column=0, sticky=tk.W) self.instruction_title_frame.grid(row=0, column=0) self.instruction_data_frame.grid(row=1, column=0) self.fill_instruction_frame() # Widgets and layout - Memory / Registers self.right_frame.grid(row=0, column=1, sticky=tk.N) # Memory self.memory_frame.grid(row=0, column=0, sticky=tk.N) self.memory_title_frame.grid(row=0) self.memory_data_frame.grid(row=1) self.fill_memory_frame() # Registers self.registers_frame.grid(row=1, column=0, sticky=tk.N) self.registers_title_frame.grid(row=0) self.registers_data_frame.grid(row=1) self.fill_registers_frame() # Buttons self.buttons_frame.grid(row=2, column=0, sticky=tk.S)
def testProcessOneInstructionStoreStateADR(self): self.simulator.decoder.next_instruction_index = STORESTATE_INDEX + 1 self.simulator.memory = Memory(40, 0xeeeeeeeeee) self.simulator.registers[3].value = 0x1234 # value self.simulator.process_one_instruction() self.assertEqual(0xeeee1234ee, self.simulator.memory.raw_memory)
def setUp(self): asm = ASM() bit_instructions = asm.process_file("path/to/mock/file") decoder = Decoder(bit_instructions) memory = Memory(0, 0) self.simulator = Core(decoder, memory)
def testProcessOneInstructionLoadBoolADR(self): self.simulator.decoder.next_instruction_index = LOADBOOL_INDEX + 1 self.simulator.memory = Memory(40, 0xeeeeee01ee) self.simulator.process_one_instruction() self.assertEqual(1, self.simulator.registers[3].value)
self.label_imma_value.config(fg="green") elif cfg_mask == LOAD_ADR: self.label_address_value.config(fg="green") elif op_code == OP_NOT: self.color_rd("red") self.color_ra("green") else: if cfg_mask == CFG_RR: self.color_ra("green") self.color_rb("green") elif cfg_mask == CFG_RI: self.color_ra("green") self.label_immb_value.config(fg="green") elif cfg_mask == CFG_IR: self.label_imma_value.config(fg="green") self.color_rb("green") elif cfg_mask == CFG_II: self.label_imma_value.config(fg="green") self.label_immb_value.config(fg="green") self.color_rd("red") if __name__ == "__main__": root = tk.Tk() my_gui = GUI(root, bin_file="../sdve-beem-benchmark/bin/adding.6.out") print([hex(elt) for elt in my_gui.simulator.decoder.bit_instructions]) my_gui.simulator.memory = Memory( 256, 0x0000000000000000000000000000000000010001000000050000000400000003) root.mainloop()