From: Luke Kenneth Casson Leighton Date: Wed, 2 Sep 2020 16:48:17 +0000 (+0100) Subject: sign-extend lhax needs 16-64, separate from lwax which is 32-64 X-Git-Tag: semi_working_ecp5~212 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=63c8560011b75345a0fd49427b63cd4040cab89d;p=soc.git sign-extend lhax needs 16-64, separate from lwax which is 32-64 --- 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) +