Comments (3)
The issue seems to be that CSRStorage
has a def do_finalize
method which is never called.
When you add the object as a submodule, the method fails because of a missing "busword" method. If you give the busword a default argument, simulation seems to start working.
from misoc.
I created the following test to demonstrate the issue;
#!/usr/bin/env python3
import unittest
from migen import *
from litex.soc.interconnect.csr import *
class CSRModule(Module, AutoCSR):
def __init__(self, *args, **kw):
self.csr = CSRStorage(*args, **kw)
class TestCSRStorage(unittest.TestCase):
def assert_csr(self, csr, expected):
actual = yield from csr.read()
self.assertEqual(expected, actual)
def stim_csr_write(self, dut, values, mask):
yield from self.assert_csr(dut.csr, 0)
for v in values:
yield from dut.csr.write(v)
yield from self.assert_csr(dut.csr, v & mask)
def test_readwrite_nibble(self):
dut = CSRModule(size=4)
stim = self.stim_csr_write(dut, [0, 0xff, 0x0b, 0xaa], 0x0f)
run_simulation(dut, stim, vcd_name="vcd/%s.vcd" % self.id())
def test_readwrite_byte(self):
dut = CSRModule(size=8)
stim = self.stim_csr_write(dut, [0, 0xff, 0x0b, 0xaa], 0xff)
run_simulation(dut, stim, vcd_name="vcd/%s.vcd" % self.id())
def test_readwrite_32bit(self):
dut = CSRModule(size=32)
stim = self.stim_csr_write(dut, [0, 0xffffffff, 0x0a0a0a0a, 0xa0a0a0a0], 0xffffffff),
run_simulation(dut, stim, vcd_name="vcd/%s.vcd" % self.id())
def test_readwrite_byte_alignment(self):
dut = CSRModule(size=16, alignment_bits=8)
stim = self.stim_csr_write(dut, [0, 0xffff, 0x0a0a, 0xa0a0], 0xff00),
run_simulation(dut, stim, vcd_name="vcd/%s.vcd" % self.id())
def test_readwrite_from_dev(self):
dut = CSRModule(size=8, write_from_dev=True)
def stim(glitch=-1):
yield from self.assert_csr(dut.csr, 0)
for v in [0, 0xff, 0x0a, 0xa0]:
# Write the value from the device
yield dut.csr.dat_w.eq(v)
yield dut.csr.we.eq(1)
yield
yield dut.csr.we.eq(0)
# Read the CSR value and check it
actual = yield from dut.csr.read()
self.assertEqual(actual, v)
run_simulation(dut, stim(), vcd_name="vcd/%s.vcd" % self.id())
if __name__ == '__main__':
import doctest
doctest.testmod()
unittest.main()
It currently fails with;
======================================================================
FAIL: test_readwrite_from_dev (__main__.TestCSRStorage)
----------------------------------------------------------------------
Traceback (most recent call last):
File "./test_csr.py", line 64, in test_readwrite_from_dev
run_simulation(dut, stim(), vcd_name="vcd/%s.vcd" % self.id())
File "/home/tansell/github/timvideos/litex-buildenv/third_party/migen/migen/sim/core.py", line 407, in run_simulation
s.run()
File "/home/tansell/github/timvideos/litex-buildenv/third_party/migen/migen/sim/core.py", line 396, in run
self._process_generators(cd)
File "/home/tansell/github/timvideos/litex-buildenv/third_party/migen/migen/sim/core.py", line 350, in _process_generators
request = generator.send(reply)
File "./test_csr.py", line 62, in stim
self.assertEqual(actual, v)
AssertionError: 0 != 255
----------------------------------------------------------------------
Ran 5 tests in 0.062s
FAILED (failures=1)
from misoc.
If I make the CSRStorage
object a submodule of CSRModule
and set busword=8
, then;
test_readwrite_32bit (__main__.TestCSRStorage) ... FAIL
test_readwrite_byte (__main__.TestCSRStorage) ... FAIL
test_readwrite_byte_alignment (__main__.TestCSRStorage) ... ok
test_readwrite_from_dev (__main__.TestCSRStorage) ... FAIL
test_readwrite_nibble (__main__.TestCSRStorage) ... FAIL
from misoc.
Related Issues (20)
- Wrong version in `setup.py`
- different clocking of differentiator and integrator HOT 3
- misoc@2022-04-07 fail with either latest migen built from source (2022-09-02) and with migen 0.9.2 HOT 1
- pip install of tag 0.12 fails HOT 5
- fix liteeth error counter atomicity problem HOT 2
- liteeth: remove dw parameterization HOT 2
- liteeth: rename dv to rx_dv
- liteeth: remove MII clock output
- clean up memory regions, names, offsets
- kasli/spi_flash: investigate and implement quad i/o read
- DDR3-related error in Vivado timing report for Ultrascale HOT 1
- spi: first half-cycle (setup period) of a chained, pure read uses the write divider instead of the read divider
- Record.connect return value not used HOT 3
- Binutils compilation
- Standard 1 bit SPI mode for spi_flash not available? HOT 2
- software not rebuilt after gateware change
- fix or remove Ultrascale SDRAM init HOT 4
- Wanted to Build a small SoC HOT 1
- register_rom weirdness HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from misoc.