soc/interconnect/csr: Fix CSRConstant read method (And add test_csr_constant to test_csr).

This commit is contained in:
Florent Kermarrec 2022-03-21 15:21:08 +01:00
parent f5d4977dde
commit 6ef96b17bc
2 changed files with 12 additions and 3 deletions

View File

@ -68,6 +68,7 @@ class CSRConstant(DUID):
def read(self): def read(self):
"""Read method for simulation.""" """Read method for simulation."""
yield
return self.value.value return self.value.value
# CSR ---------------------------------------------------------------------------------------------- # CSR ----------------------------------------------------------------------------------------------

View File

@ -26,9 +26,10 @@ def csr32_read(dut, adr):
class CSRModule(Module, csr.AutoCSR): class CSRModule(Module, csr.AutoCSR):
def __init__(self): def __init__(self):
self._csr = csr.CSR() self._csr = csr.CSR()
self._storage = csr.CSRStorage(32, reset=0x12345678, write_from_dev=True) self._constant = csr.CSRConstant(0x12345678)
self._status = csr.CSRStatus(32, reset=0x12345678) self._storage = csr.CSRStorage(32, reset=0x12345678, write_from_dev=True)
self._status = csr.CSRStatus(32, reset=0x12345678)
# # # # # #
@ -61,6 +62,13 @@ class CSRDUT(Module):
self.csr, self.csrbankarray.get_buses()) self.csr, self.csrbankarray.get_buses())
class TestCSR(unittest.TestCase): class TestCSR(unittest.TestCase):
def test_csr_constant(self):
def generator(dut):
self.assertEqual(hex((yield from dut.csrmodule._constant.read())), hex(0x12345678))
dut = CSRDUT()
run_simulation(dut, generator(dut))
def test_csr_storage(self): def test_csr_storage(self):
def generator(dut): def generator(dut):
# check init value # check init value