amaranth icon indicating copy to clipboard operation
amaranth copied to clipboard

nmigen.sim._pyrtl: Add support for Assert/Assume

Open jeanthom opened this issue 5 years ago • 3 comments

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

jeanthom avatar Aug 04 '20 15:08 jeanthom

Should we have a separate exception type for simulation asserts?

jeanthom avatar Aug 04 '20 15:08 jeanthom

This looks generally reasonable, let's discuss the UI aspects on the next meeting.

whitequark avatar Aug 05 '20 03:08 whitequark

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.

jeanthom avatar Aug 05 '20 10:08 jeanthom

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.

whitequark avatar Mar 04 '24 23:03 whitequark