Beispiel #1
0
 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)
Beispiel #2
0
 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)
Beispiel #3
0
 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)
Beispiel #4
0
 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)
Beispiel #5
0
 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)
Beispiel #6
0
 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)
Beispiel #7
0
 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)
Beispiel #8
0
 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
Beispiel #9
0
 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)
Beispiel #10
0
 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)
Beispiel #11
0
 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)
Beispiel #12
0
 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)
Beispiel #13
0
 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)
Beispiel #14
0
 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)
Beispiel #15
0
    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)
Beispiel #16
0
 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)
Beispiel #17
0
 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)
Beispiel #18
0
 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)
Beispiel #19
0
                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()