amaranth/nmigen/sim
whitequark 8c6c3643cd sim._pyrtl: optimize uses of reflexive operators.
When a literal is used on the left-hand side of a numeric operator,
Python is able to constant-fold some expressions:

    >>> dis.dis(lambda x: 0 + 0 + x)
      1           0 LOAD_CONST               1 (0)
                  2 LOAD_FAST                0 (x)
                  4 BINARY_ADD
                  6 RETURN_VALUE

If a literal is used on the right-hand side such that the left-hand
side is variable, this doesn't happen:

    >>> dis.dis(lambda x: x + 0 + 0)
      1           0 LOAD_FAST                0 (x)
                  2 LOAD_CONST               1 (0)
                  4 BINARY_ADD
                  6 LOAD_CONST               1 (0)
                  8 BINARY_ADD
                 10 RETURN_VALUE

PyRTL generates fairly redundant code due to the pervasive masking,
and because of that, transforming expressions into the former form,
where possible, improves runtime by about 10% on Minerva SRAM SoC.
2020-08-26 13:26:58 +00:00
..
__init__.py back.pysim: extract simulator commands to sim._cmds. NFC. 2020-07-08 05:42:33 +00:00
_cmds.py back.pysim: extract simulator commands to sim._cmds. NFC. 2020-07-08 05:42:33 +00:00
_core.py sim: simplify. NFC. 2020-07-08 17:31:53 +00:00
_pycoro.py sim._pycoro: avoid spurious wakeups. 2020-07-22 14:32:45 +00:00
_pyrtl.py sim._pyrtl: optimize uses of reflexive operators. 2020-08-26 13:26:58 +00:00
pysim.py sim.pysim: write the next, not curr signal value to the VCD file 2020-07-13 02:10:01 +00:00