Commit graph

1003 commits

Author SHA1 Message Date
whitequark df70aae887 sim._pyrtl: sign extend RHS of assignment.
Fixes #502.
2020-10-22 16:08:38 +00:00
whitequark 9d62cbefa5 hdl.dsl: error on Elif immediately nested in an If.
I.e. on this code, which is currently not only wrongly accepted but
also results in completely unexpected RTL:

    with m.If(...):
        with m.Elif(...):
            ...

Fixes #500.
2020-10-22 13:23:06 +00:00
Jan Kowalewski 2c505deacc vendor.quicklogic: fix syntax
Signed-off-by: Jan Kowalewski <jkowalewski@antmicro.com>
2020-10-19 23:02:47 +00:00
Xiretza 12327aedf8 setup.py: Exclude "tests" package
67b957d moved the tests from nmigen/test/ to tests/, and removed the
exclude= parameter from find_packages() in setup.py. However, even if
the new location is not inside the module tree, it is still found by
find_packages(), resulting in a stray "tests" module on the system.
2020-10-19 22:59:33 +00:00
Xiretza eb152da59b hdl.ir: Update error message for Instance arguments
48d4ee4 added the option to specify attributes using Instance arguments,
but the error message wasn't updated accordingly.
2020-10-18 23:55:46 +00:00
whitequark a6db99b05e README: Quicklogic EOS S3 is now supported. 2020-10-15 18:10:39 +00:00
whitequark 80194e1a7e CI: fix code coverage collection.
This has been broken since commit d71e19e2 (2020-07-22).
2020-10-15 18:09:04 +00:00
Jan Kowalewski 9746138e55
vendor.quicklogic: new platform.
Signed-off-by: Kamil Rakoczy <krakoczy@antmicro.com>
Signed-off-by: Jan Kowalewski <jkowalewski@antmicro.com>

Co-authored-by: Kamil Rakoczy <krakoczy@antmicro.com>
2020-10-15 18:02:25 +00:00
whitequark e58233b441 tests: keep comments up to date. NFC. 2020-10-15 17:02:50 +00:00
whitequark d22b2c5604 build.plat: avoid type confusion in _check_feature.
Before this commit, `_check_feature(valid_xdrs=0)` would mean that
XDR buffers are not supported. Only `_check_feature(valid_xdrs=())`
was intended to be an indicator of that.
2020-10-15 08:56:09 +00:00
Jean-François Nguyen 69ed4918b8 hdl.mem: document ReadPort and WritePort.
Fixes #496.
2020-09-17 15:47:46 +00:00
William D. Jones 47ecc16283
vendor.lattice_{ecp5,machxo_2_3l}: explain how to set up NMIGEN_ENV_Diamond on Windows. 2020-08-29 19:34:57 +00:00
whitequark d12c7827a0 setup: synchronize builtin-yosys dependency. 2020-08-27 13:46:55 +00:00
whitequark 955f3f6dcc back.verilog: use proc -nomux if it is available.
Yosys offers no stability guarantees for individual `proc_*` passes,
though so far it worked out fine. This commit changes the Verilog
backend to use `proc -nomux` instead, which is guaranteed to have
backwards-compatible behavior.

Fixes #479.
2020-08-27 13:03:15 +00:00
whitequark b65e11f38f sim: split into base, core, and engines.
Before this commit, each simulation engine (which is only pysim at
the moment, but also cxxsim soon) was a subclass of SimulatorCore,
and every simulation engine module would essentially duplicate
the complete structure of a simulator, with code partially shared.

This was a really bad idea: it was inconvenient to use, with
downstream code having to branch between e.g. PySettle and CxxSettle;
it had no well-defined external interface; it had multiple virtually
identical entry points; and it had no separation between simulation
algorithms and glue code.

This commit completely rearranges simulation code.
  1. sim._base defines internal simulation interfaces. The clarity of
     these internal interfaces is important because simulation
     engines mix and match components to provide a consistent API
     regardless of the chosen engine.
  2. sim.core defines the external simulation interface: the commands
     and the simulator facade. The facade provides a single entry
     point and, when possible, validates or lowers user input.
     It also imports built-in simulation engines by their symbolic
     name, avoiding eager imports of pyvcd or ctypes.
  3. sim.xxxsim (currently, only sim.pysim) defines the simulator
     implementation: time and state management, process scheduling,
     and waveform dumping.

The new simulator structure has none of the downsides of the old one.

See #324.
2020-08-27 11:52:31 +00:00
whitequark 9bdb7accc8 sim.pysim: in write_vcd(), close files if an exception is raised.
This also avoids leaving the waveform writer list in an inconsistent
state after an exception.
2020-08-27 08:34:18 +00:00
whitequark 9bc42cb8c5 sim._pyclock: new type of process.
The overhead of coroutine processes is fairly high. A clock driver
implemented through a coroutine process is mostly overhead. This was
partially addressed in commit 2398b792 by microoptimizing yielding.

This commit eliminates the coroutine process overhead completely by
introducing dedicated clock processes. It also simplifies the logic
to a simple toggle.

This change improves runtime by about 12% on Minerva SRAM SoC.
2020-08-27 07:56:47 +00:00
whitequark c00219d9f3 sim._pycoro: make src_loc() more robust.
* Guard for finished coroutines.
  * Guard for coroutines yielding from iterators and not generators.
2020-08-27 07:11:14 +00:00
whitequark 141eaf0e40 _toolchain.cxx: work around PyPy missing LDCXXSHARED sysconfig variable. 2020-08-27 06:53:14 +00:00
whitequark 4180cc537b _toolchain.cxx: new toolchain. 2020-08-27 06:39:00 +00:00
whitequark fde242aa47 hdl.ast: clarify exception message for out of bounds indexing.
Fixes #488.
2020-08-27 01:14:05 +00:00
whitequark 5b01499901 nmigen.test.utils: restore FHDLTestCase to gracefully deprecate it.
Fixes #484.
2020-08-27 00:46:50 +00:00
whitequark 67b957d4f4 tests: move out of the main package.
Compared to tests in the repository root, tests in the package have
many downsides:
  * Unless explicitly excluded in find_packages(), tests and their
    support code effectively become a part of public API.
    This, unfortunately, happened with FHDLTestCase, which was never
    intended for downstream use.
  * Even if explicitly excluded from the setuptools package, using
    an editable install, or setting PYTHONPATH still allows accessing
    the tests.
  * Having a sub-package that is present in the source tree but not
    exported (or, worse, exported only sometimes) is confusing.
  * The name `nmigen.test` cannot be used for anything else, such as
    testing utilities that *are* intended for downstream use.
2020-08-27 00:33:31 +00:00
William D. Jones ef7a3bcfb1
build.run: implement SSH remote builds using Paramiko. 2020-08-26 22:49:49 +00:00
whitequark 07a3685da8 back.rtlil: do not squash empty modules.
In commit 9faa1d37, the RTLIL backend was changed to ignore modules
without ports completely, since Yosys would recognize empty modules
as black boxes without explicit `write_verilog -noblackbox` and break
the design. That change had many flaws:
  * It removed instances without ports, which are used in e.g. SoC
    FPGAs to instantiate a dummy CPU.
  * It removed fragments without ports, which can appear in e.g. SoC
    FPGAs in case the fabric is not connected to any I/O ports.
  * Finally, it was just conceptually unjustified.

This commit changes the logic to actually check for empty fragments,
and instead of removing them, it adds a dummy wire inside. It would
be possible to use the Yosys-specific (*noblackbox*) attribute.
However, it would be necessary to strip it for most targets right
away, and also the wire doubles as documentation.

Fixes #441.
2020-08-26 22:45:19 +00:00
whitequark 12beda6e5b back.verilog: omit Verilog initial trigger only if Yosys adds it.
Verilog has an edge case where an `always @*` process, which is used
to describe a combinatorial function procedurally, may not execute
at time zero because none of the signals in its implicit sensitivity
list change, i.e. when the process doesn't read any signals. This
causes the wires driven by the process to stay undefined.

The workaround to this problem (assuming SystemVerilog `always_comb`
is not available) is to introduce a dummy signal that changes only
at time zero and is optimized out during synthesis. nMigen has had
its own workaround, `$verilog_initial_trigger`, for a while. However,
`proc_prune`, while increasing readability, pulls references to this
signal out of the process. Because of this, a similar workaround was
implemented in Yosys' `write_verilog` itself.

This commit ensures we use our workaround on versions of Yosys
without the updated `write_verilog`, and Yosys' workaround on later
versions.

Fixes #418.
2020-08-26 16:51:12 +00:00
whitequark 6d9852506f vendor.xilinx_{7series,ultrascale}: set BUFG* SIM_DEVICE as appropriate.
Fixes #438 (again).
2020-08-26 15:45:58 +00:00
whitequark abaa9091f4 vendor.xilinx_7series: unbreak.
This commit fixes a series of typos introduced in commit 4e208b0a.
2020-08-26 14:57:31 +00:00
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
whitequark 38b75ba4bc back.cxxrtl: actualize Yosys version requirement. 2020-08-26 09:16:46 +00:00
whitequark 00026c6e4a hdl.ast: avoid unnecessary sign padding in ArrayProxy.
Before this commit, ArrayProxy would add sign padding (an extra bit)
a homogeneous array of signed values, or an array where all unsigned
values are smaller than the largest signed one. After this commit,
ArrayProxy would only add padding in arrays with mixed signedness
where all signed values are smaller or equal in size to the largest
unsigned value.

Fixes #476.

Co-authored-by: Pepijn de Vos <pepijndevos@gmail.com>
2020-08-26 07:07:48 +00:00
whitequark cb81618c28 sim._pyrtl: fix miscompilation of -(Const(0b11, 2).as_signed()).
Fixes #473.
2020-08-26 04:15:54 +00:00
whitequark 0802f943ba lib.cdc: in AsyncFFSynchronizer(), rename domain= to o_domain=.
This is for consistency with other synchronizers.

Fixes #467.
2020-08-26 03:19:13 +00:00
Robin Ole Heinemann 630c0fd99a vendor.lattice_machxo_2_3l: add SRAM svf generation 2020-08-24 14:41:14 +00:00
Mariusz Glebocki 4e208b0ac1 vendor: Add initial support for Symbiflow for Xilinx 7-series 2020-08-24 14:39:10 +00:00
Mariusz Glebocki 77616837e8 vendor.xilinx_7series: add _part property getter 2020-08-24 14:39:10 +00:00
Xiretza 15f150337f cli: Improve help texts
545e49c2 added the option to export as CXXRTL, but the help texts for
the CLI options don't reflect this yet.
2020-08-22 14:41:37 +00:00
whitequark e46118dac0 docs/lang: use less confusing placeholder variable names.
Fixes #474.
2020-08-15 13:01:09 +00:00
awygle 73f672f57c
lib.fifo: add r_level and w_level to all FIFOs 2020-08-15 08:40:56 +00:00
whitequark f6f9d68f24 Add Linguist tags to .gitattributes.
This should make it possible to navigate to nmigen/vendor/*.py using
GitHub's file finder.
2020-08-13 03:12:39 +00:00
Robin Ole Heinemann b86acdc601 vendor.lattice_{ecp5,machxo_2_3l}: specify impl-dir correctly 2020-08-10 17:52:47 +00:00
whitequark d964ba9cc4 build,vendor: never carry around parts of differential signals.
When a port component is skipped, it should appear neither in the RTL
nor in the constraint file. However, passing around components of
differential ports explicitly makes that harder.

Fixes #456.
Supersedes #457.

Co-authored-by: Jean THOMAS <git0@pub.jeanthomas.me>
2020-07-31 18:41:59 +00:00
whitequark c9662c5ff8 vendor.xilinx_{7series,ultrascale}: use BUFGCTRL rather than BUFGCE.
Fixes #438 (again).
2020-07-31 17:48:22 +00:00
Adam Greig 07dc163105
hdl.mem: cast reset value for transparent read ports to integer. 2020-07-30 07:05:18 +00:00
Jean THOMAS 20f9ab9d7a
nmigen.lib.scheduler: add RoundRobin. 2020-07-28 21:02:01 +00:00
Jacob Graves 8117ef6692
tests: fix remove unnecessary workaround for some unittest assertions. 2020-07-28 19:35:25 +00:00
whitequark c75fa45fd8 vendor.xilinx_{7series,ultrascale}: add SIM_DEVICE parameter.
The parameter defaults to "ULTRASCALE", even when synthesizing for
7-series devices. This could lead to a simulation/synthesis mismatch,
and causes a warning.

Fixes #438.
2020-07-23 16:38:28 +00:00
Jean THOMAS f7a8fcc94c
vendor.lattice_ecp5: add missing differential IO types. 2020-07-23 12:24:31 +00:00
whitequark 7aedb3e770 back.rtlil: lower maximum accepted wire size.
In practice wires of just 100000 bits sometimes have unacceptable
performance with Yosys, so stick to Verilog's minimum limit of 65536
bits.
2020-07-22 14:43:44 +00:00
whitequark 1321c4591d sim._pycoro: avoid spurious wakeups.
This bug was introduced in commit e435a217.
2020-07-22 14:32:45 +00:00