From 6c8b23a6fccc3d534cd44663c3eea75e07f00356 Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Sun, 14 Jun 2020 18:08:23 +0100 Subject: [PATCH] unit tests showing byte-reverse works --- src/soc/fu/ldst/test/test_pipe_caller.py | 52 +++++++++++++++++++++--- 1 file changed, 47 insertions(+), 5 deletions(-) diff --git a/src/soc/fu/ldst/test/test_pipe_caller.py b/src/soc/fu/ldst/test/test_pipe_caller.py index 25e72c02..247b0e06 100644 --- a/src/soc/fu/ldst/test/test_pipe_caller.py +++ b/src/soc/fu/ldst/test/test_pipe_caller.py @@ -94,12 +94,54 @@ class LDSTTestCase(FHDLTestCase): lst = ["sth 4, 0(2)", "lhz 4, 0(2)"] initial_regs = [0] * 32 - initial_regs[1] = 0x1004 - initial_regs[2] = 0x1002 + initial_regs[1] = 0x0004 + initial_regs[2] = 0x0002 initial_regs[3] = 0x15eb - initial_mem = {0x1000: (0x5432123412345678, 8), - 0x1008: (0xabcdef0187654321, 8), - 0x1020: (0x1828384822324252, 8), + initial_mem = {0x0000: (0x5432123412345678, 8), + 0x0008: (0xabcdef0187654321, 8), + 0x0020: (0x1828384822324252, 8), + } + self.run_tst_program(Program(lst), initial_regs, + initial_mem=initial_mem) + + def test_4_load_store_rev_ext(self): + lst = ["stwx 1, 4, 2", + "lwbrx 3, 4, 2"] + initial_regs = [0] * 32 + initial_regs[1] = 0x5678 + initial_regs[2] = 0x001c + initial_regs[4] = 0x0008 + initial_mem = {0x0000: (0x5432123412345678, 8), + 0x0008: (0xabcdef0187654321, 8), + 0x0020: (0x1828384822324252, 8), + } + self.run_tst_program(Program(lst), initial_regs, + initial_mem=initial_mem) + + def test_5_load_store_rev_ext(self): + lst = ["stwbrx 1, 4, 2", + "lwzx 3, 4, 2"] + initial_regs = [0] * 32 + initial_regs[1] = 0x5678 + initial_regs[2] = 0x001c + initial_regs[4] = 0x0008 + initial_mem = {0x0000: (0x5432123412345678, 8), + 0x0008: (0xabcdef0187654321, 8), + 0x0020: (0x1828384822324252, 8), + } + self.run_tst_program(Program(lst), initial_regs, + initial_mem=initial_mem) + + def test_6_load_store_rev_ext(self): + lst = ["stwbrx 1, 4, 2", + "lwbrx 3, 4, 2"] + initial_regs = [0] * 32 + initial_regs[1] = 0x5678 + initial_regs[2] = 0x001c + initial_regs[4] = 0x0008 + initial_mem = {0x0000: (0x5432123412345678, 8), + 0x0008: (0xabcdef0187654321, 8), + 0x0020: (0x1828384822324252, 8), } self.run_tst_program(Program(lst), initial_regs, initial_mem=initial_mem) -- 2.30.2