Commit graph

1085 commits

Author SHA1 Message Date
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
whitequark d71e19e27c CI: replace Travis with GitHub Actions.
Fixes #445.
2020-07-22 09:28:35 +00:00
whitequark 0899ff366b compat.fhdl.bitcontainer: fix value_bits_sign().
This function was broken in commit 659b0e81; some downstream code
expects bits_sign to be e.g. indexable.
2020-07-21 02:53:29 +00:00
whitequark 5ccc2122ce CI: use WASM yosys instead of building our own.
Fixes #434.
2020-07-16 08:41:53 +00:00
whitequark d06add0aab back.rtlil: fix guard for division by zero.
Oops... that should be checking the divisor, not the dividend. This
was discovered by running the test suite on cxxsim.
2020-07-15 04:14:34 +00:00
Filipe Laíns d714d78de1 docs: add install instructions for arch
Signed-off-by: Filipe Laíns <lains@archlinux.org>
2020-07-14 00:28:24 +00:00
whitequark 127fce8f48 CI: run on pull requests as well, not just pushes. 2020-07-14 00:25:11 +00:00
whitequark ecb3a69d48 lib.cdc: fix typo.
Co-authored-by: @ECP5-PCIe
2020-07-13 23:53:15 +00:00
Jacob Lifshay 58f1d4bcb6
sim.pysim: write the next, not curr signal value to the VCD file
This is a temporary fix for #429.
2020-07-13 02:10:01 +00:00
whitequark 0a90aa1b17 sim.pysim: use VCD aliases to reduce space and time overhead.
On Minerva SoC, this reduces VCD file size by about 35%, and reduces
runtime overhead of writing VCDs by 10% or less.
2020-07-11 12:26:34 +00:00
whitequark 30e2f91176 sim: simplify. NFC. 2020-07-08 17:31:53 +00:00
whitequark d7a87fef42 back.pysim→sim.pysim; split into more manageable parts.
This is necessary to add cxxrtl as an alternate simulation engine.
2020-07-08 12:49:38 +00:00
whitequark 23da2fdda6 vendor.xilinx_{7series,ultrascale}: remove grade property.
This was added in commit bfd4538d based on a misunderstanding of how
Xilinx part numbers work.
 * non-ultrascale 7-series parts don't have temperature grades;
 * ultrascale parts have temperature grade as a part of speed grade.
2020-07-08 09:08:00 +00:00
whitequark 6d417568ad back.pysim: only extract signal names if VCD is requested.
This commit also fixes an issue introduced in 2606ee33 that regressed
simulator startup time and bloated VCD files. (It's actually about
10% faster now than *before* the regression was introduced.)
2020-07-08 08:33:45 +00:00
whitequark 3c3cfd48fb back.pysim: reset timeline as well.
This is a bug that was introduced in 94faf497b.
2020-07-08 08:19:29 +00:00
whitequark 90e2a991f0 back.pysim: simplify. NFC. 2020-07-08 06:31:04 +00:00
whitequark 94faf497ba back.pysim: extract timeline handling to class _Timeline. NFC. 2020-07-08 06:31:04 +00:00
whitequark d3d210eaee back.pysim: extract simulator commands to sim._cmds. NFC. 2020-07-08 05:42:33 +00:00
whitequark e435a21715 back.pysim: simplify. NFC. 2020-07-08 03:55:09 +00:00