From 884253f76482a4e306402d8d826197de8c30e401 Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Tue, 21 Dec 2021 15:47:39 +0000 Subject: [PATCH] for each unit test case in test_issuer_mmu_data_path.py initialise memory to empty --- .../fu/mmu/test/test_issuer_mmu_data_path.py | 24 +++++++++++++------ src/soc/simple/issuer.py | 6 ++++- src/soc/simple/test/test_runner.py | 2 +- 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/src/soc/fu/mmu/test/test_issuer_mmu_data_path.py b/src/soc/fu/mmu/test/test_issuer_mmu_data_path.py index 4742af0f..f5919b9a 100644 --- a/src/soc/fu/mmu/test/test_issuer_mmu_data_path.py +++ b/src/soc/fu/mmu/test/test_issuer_mmu_data_path.py @@ -13,12 +13,22 @@ class MMUTestCase(TestAccumulatorBase): # libre-soc has own SPR unit # other instructions here -> must be load/store + def cse_dcbz(self): + lst = [ + "dcbz 1,2", + ] + + initial_regs = [0] * 32 + initial_regs[1] = 0x2 + initial_regs[2] = 0x2020 + + self.add_case(Program(lst, bigendian), + initial_regs, initial_mem={}) + def case_mmu_dar(self): lst = [ - "mfspr 1, 720", # DAR to reg 1 - "addi 7, 0, 1", + "mfspr 1, 720", # DAR to reg 1 "mtspr 19, 3", # reg 3 to DAR - "mulli 7, 0, 1", ] initial_regs = [0] * 32 @@ -28,11 +38,11 @@ class MMUTestCase(TestAccumulatorBase): initial_sprs = {'DAR': 0x87654321, } self.add_case(Program(lst, bigendian), - initial_regs, initial_sprs) + initial_regs, initial_sprs, initial_mem={}) - def cse_mmu_ldst(self): + def case_mmu_ldst(self): lst = [ - "dcbz 1,2", + "dcbz 1,0", "tlbie 0,0,0,0,0", # RB,RS,RIC,PRS,R "mtspr 18, 1", # reg 1 to DSISR "mtspr 19, 2", # reg 2 to DAR @@ -53,7 +63,7 @@ class MMUTestCase(TestAccumulatorBase): initial_sprs = {'DSISR': 0x12345678, 'DAR': 0x87654321, 'PIDR': 0xabcd, 'PRTBL': 0x0def} self.add_case(Program(lst, bigendian), - initial_regs, initial_sprs) + initial_regs, initial_sprs, initial_mem={}) if __name__ == "__main__": diff --git a/src/soc/simple/issuer.py b/src/soc/simple/issuer.py index 4629c4ed..15642018 100644 --- a/src/soc/simple/issuer.py +++ b/src/soc/simple/issuer.py @@ -800,7 +800,11 @@ class FetchFSM(ControlBase): comb += self.imem.f_i_valid.eq(1) with m.Else(): # not busy: instruction fetched - insn = get_insn(self.imem.f_instr_o, cur_state.pc+4) + if hasattr(core, "icache"): + # blech, icache returns actual instruction + insn = self.imem.f_instr_o + else: + insn = get_insn(self.imem.f_instr_o, cur_state.pc+4) sync += dec_opcode_o.eq(insn) m.next = "INSN_READY" # TODO: probably can start looking at pdecode2.rm_dec diff --git a/src/soc/simple/test/test_runner.py b/src/soc/simple/test/test_runner.py index 56978f76..2daa86a5 100644 --- a/src/soc/simple/test/test_runner.py +++ b/src/soc/simple/test/test_runner.py @@ -246,7 +246,7 @@ class HDLRunner(StateRunner): yield from setup_i_memory(imem, pc, instructions, self.dut.rom) yield from setup_tst_memory(l0, self.test.mem) else: - insert_into_rom(pc, instructions, self.dut.rom) + insert_into_rom(pc, instructions, self.dut.default_mem) print("about to setup regs") yield from setup_regs(pdecode2, core, self.test) #print("setup mem and regs done") -- 2.30.2