amaranth
amaranth copied to clipboard
nmigen.sim._pyrtl: Add support for Assert/Assume
Fixes #427
TODO:
- [ ] Ensure that I'm generating gen_test the right way
- [ ] Improve the exception message?
- [ ] Add unit tests
- [ ] Fix VCD
- [ ] Use a different exception
Should we have a separate exception type for simulation asserts?
This looks generally reasonable, let's discuss the UI aspects on the next meeting.
Another issue I noticed:
/usr/lib64/python3.8/unittest/case.py:704: ResourceWarning: unclosed file <_io.TextIOWrapper name='test_soc_continuous_memtest.vcd' mode='wt' encoding='UTF-8'>
outcome.errors.clear()
ResourceWarning: Enable tracemalloc to get the object allocation traceback
======================================================================
FAIL: test_continuous_memtest (test_soc.SocTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/jeanthomas/Documents/gram/gram/test/test_soc.py", line 223, in test_continuous_memtest
runSimulation(soc, process, "test_soc_continuous_memtest.vcd")
File "/home/jeanthomas/Documents/gram/gram/test/utils.py", line 25, in runSimulation
sim.run()
File "/home/jeanthomas/Documents/nmigen/nmigen/sim/pysim.py", line 382, in run
while self.advance():
File "/home/jeanthomas/Documents/nmigen/nmigen/sim/pysim.py", line 371, in advance
self._real_step()
File "/home/jeanthomas/Documents/nmigen/nmigen/sim/pysim.py", line 347, in _real_step
process.run()
File "<string>", line 987, in run
AssertionError: Assertion failed at /home/jeanthomas/Documents/gram/gram/phy/fakephy.py:328
The VCD file isn't closed properly. Not sure how we could fix this though.
Thank you for submitting this pull request. We have iterated on the proposed design; as such, support for this feature has been accepted via RFC 50 and implementation is tracked in issue #1186.