From 63c8560011b75345a0fd49427b63cd4040cab89d Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Wed, 2 Sep 2020 17:48:17 +0100 Subject: [PATCH] sign-extend lhax needs 16-64, separate from lwax which is 32-64 --- src/soc/experiment/compldst_multi.py | 6 +++++- src/soc/fu/ldst/test/test_pipe_caller.py | 26 ++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/src/soc/experiment/compldst_multi.py b/src/soc/experiment/compldst_multi.py index ecb99e8d..8aa252f8 100644 --- a/src/soc/experiment/compldst_multi.py +++ b/src/soc/experiment/compldst_multi.py @@ -506,7 +506,11 @@ class LDSTCompUnit(RegSpecAPI, Elaboratable): # then check sign-extend with m.If(oper_r.sign_extend): - comb += ldd_o.eq(exts(revnorev, 32, 64)) # sign-extend + # okok really should "if data_len == 4" and so on here + with m.If(oper_r.data_len == 2): + comb += ldd_o.eq(exts(revnorev, 16, 64)) # sign-extend hword + with m.Else(): + comb += ldd_o.eq(exts(revnorev, 32, 64)) # sign-extend dword with m.Else(): comb += ldd_o.eq(revnorev) diff --git a/src/soc/fu/ldst/test/test_pipe_caller.py b/src/soc/fu/ldst/test/test_pipe_caller.py index 662b89d7..4e3627dd 100644 --- a/src/soc/fu/ldst/test/test_pipe_caller.py +++ b/src/soc/fu/ldst/test/test_pipe_caller.py @@ -218,3 +218,29 @@ class LDSTTestCase(TestAccumulatorBase): self.add_case(Program(lst, bigendian), initial_regs, initial_mem=initial_mem) + def case_10_load_algebraic_1(self): + lst = ["lhax 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: (0x0000f00f0000ffff, 8), + } + self.add_case(Program(lst, bigendian), initial_regs, + initial_mem=initial_mem) + + def case_10_load_algebraic_2(self): + lst = ["lhax 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: (0x0000700f0000ffff, 8), + } + self.add_case(Program(lst, bigendian), initial_regs, + initial_mem=initial_mem) + -- 2.30.2