From b1921038228b4e5104d5ff46aed64720e277ce11 Mon Sep 17 00:00:00 2001 From: Florent Kermarrec Date: Fri, 12 Apr 2024 16:06:26 +0200 Subject: [PATCH] cores/hyperbus: Fix bytes order on register writes. --- litex/soc/cores/hyperbus.py | 9 ++++++--- test/test_hyperbus.py | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/litex/soc/cores/hyperbus.py b/litex/soc/cores/hyperbus.py index ff24c56bf..528deade2 100644 --- a/litex/soc/cores/hyperbus.py +++ b/litex/soc/cores/hyperbus.py @@ -44,6 +44,9 @@ class HyperRAM(LiteXModule): self.reg_write_data = Signal(16) self.reg_read_data = Signal(16) + if with_csr: + self.add_csr() + self.reg_debug = CSRStatus(32) # # # @@ -211,7 +214,7 @@ class HyperRAM(LiteXModule): # Wait for 6*2 cycles... If(cycles == (6*2 - 1), If(reg_write_req, - NextValue(sr, Cat(Signal(40), self.reg_write_data[:8])), + NextValue(sr, Cat(Signal(40), self.reg_write_data[8:])), NextState("REG-WRITE-0") ).Else( NextState("WAIT-LATENCY") @@ -226,7 +229,7 @@ class HyperRAM(LiteXModule): dq.oe.eq(1), # Wait for 2 cycles... If(cycles == (2 - 1), - NextValue(sr, Cat(Signal(40), self.reg_write_data[8:])), + NextValue(sr, Cat(Signal(40), self.reg_write_data[:8])), NextState("REG-WRITE-1") ) ) @@ -315,7 +318,7 @@ class HyperRAM(LiteXModule): self.reg_control = CSRStorage(fields=[ CSRField("write", offset=0, size=1, pulse=True, description="Issue Register Write."), CSRField("read", offset=1, size=1, pulse=True, description="Issue Register Read."), - CSRField("reg", offset=8, size=4, values=[ + CSRField("addr", offset=8, size=4, values=[ ("``0``", "Identification Register 0 (Read Only)."), ("``1``", "Identification Register 1 (Read Only)."), ("``2``", "Configuration Register 0."), diff --git a/test/test_hyperbus.py b/test/test_hyperbus.py index 88822a4b2..922b4fc9e 100644 --- a/test/test_hyperbus.py +++ b/test/test_hyperbus.py @@ -103,7 +103,7 @@ class TestHyperBus(unittest.TestCase): clk = "___--__--__--__--___________" cs_n = "--________________----------" dq_oe = "__----------------__________" - dq_o = "0060000100000034120000000000" + dq_o = "0060000100000012340000000000" rwds_oe = "____________________________" rwds_o = "____________________________" for i in range(3):