Commit graph

1085 commits

Author SHA1 Message Date
Alan Green 303ea18cb6
_yosys: handle unparseable versions
Do not use yosys binaries with unparseable version numbers. This ensures
that nmigen always knows what version of yosys it is generating RTLIL
for.

The effect of this change is that if the version number of the system
yosys is unparsable, nmigen will attempt to fallback to the builtin
Yosys.

Fixes #409.
2020-06-23 12:12:02 +00:00
whitequark 706eb03e6b vendor.lattice_machxo2: add back as a compatibility shim. 2020-06-21 17:28:01 +00:00
Gwenhael Goavec-Merou 0aef5f4d48
vendor.lattice_machxo*: add MachXO3L support. 2020-06-21 17:24:47 +00:00
whitequark 868d49eccd back.verilog: refactor Yosys script generation. NFCI.
In commit 5f30bcbb, back.cxxsim gained a nicer way to generate
a script; this commit brings it to back.verilog too.
2020-06-14 09:38:32 +00:00
whitequark 5f30bcbb14 back.cxxrtl: allow injecting black boxes. 2020-06-14 09:25:54 +00:00
whitequark eddc397509 _yosys: add a way to retrieve Yosys data directory.
This is important for CXXRTL, since that's where its include files
are located.
2020-06-14 00:31:34 +00:00
whitequark 45c61969fc _yosys: fix typo in error message. 2020-06-14 00:03:36 +00:00
whitequark ca360917ba test: fix example test after commit a7b8ced9. 2020-06-11 16:36:08 +00:00
whitequark 545e49c2ca back.cxxrtl: new backend. 2020-06-11 16:19:40 +00:00
whitequark bddec3741e _yosys: translate Yosys warnings to Python warnings.
This isn't used yet (the only Yosys warning we can get is useless),
but will be handy for CXXRTL.
2020-06-11 16:12:52 +00:00
whitequark a7b8ced92c nmigen.cli: fix file type autodetection code. 2020-06-11 15:36:43 +00:00
whitequark 133d4f47d1 back.verilog: remove unused imports. NFC. 2020-06-11 15:17:49 +00:00
Adam Greig 02e30b53cc
hdl.xfrm: preserve allow_reset_less when transforming ResetSignal.
Fixes #400.
2020-06-06 11:43:25 +00:00
Shawn Anastasio 2f7c3bf443
hdl.rec: preserve shapes when constructing a layout.
Preserve the original user-provided shape, while still checking 
its validity. This allows Enum decoders to work when specifying
record fields with Enums.

Fixes #393.
2020-06-05 03:19:46 +00:00
whitequark 9c80c32c30 setup: exclude tests.
The inclusion of tests in the package was completely unintentional
and a result of my lack of knowledge of setuptools. If you are using
nmigen.test.utils, please copy the parts you need to your own code
because the nmigen.test code can and will change without notice.
2020-05-31 14:14:27 +00:00
whitequark afa4345903 vendor.lattice_ice40: reword confusing comment. NFC. 2020-05-31 10:21:45 +00:00
Robin Ole Heinemann 26a15b31f7 hdl.ast: fix typo 2020-05-24 16:56:15 +00:00
whitequark b9799b4c4a back.verilog: fall back to nmigen_yosys package.
The nmigen-yosys PyPI package provides a custom, minimal build of
Yosys that uses (at the moment) wasmtime-py to deliver a single
WASM binary that can run on many platforms, and eliminates the need
to build Yosys from source.

Not only does this lower barrier to entry for new nMigen developers,
but also decouples nMigen from Yosys' yearly release cycle, which
lets us use new features and drop workarounds for Yosys bugs earlier.

The source for the nmigen-yosys package is provided at:
  https://github.com/nmigen/nmigen-yosys
The package is built from upstream source and released automatically
with no manual steps.

Fixes #371.
2020-05-22 16:51:00 +00:00
whitequark eaf33fb6b5 Update .gitignore. 2020-05-21 10:41:23 +00:00
whitequark 43b1ed1bf6 vendor.intel: don't use write_verilog -decimal.
See commit 702e41ba for details.
2020-05-21 09:49:42 +00:00
whitequark 7238e58224 vendor.intel: double-quote Tcl values rather than brace-quoting.
For unknown reasons, Quartus treats {foo} and "foo" in completely
different ways, which is not true for normal Tcl code; specifically,
it preserves the braces if they are used. Because of this, since
commit 6cee2804, the vendor.intel package was completely broken.
2020-05-21 09:48:42 +00:00
whitequark 702e41ba3c vendor.xilinx_{7series,ultrascale}: don't use write_verilog -decimal.
In commit 892cff05, `-decimal` was used when writing Verilog for
Vivado targets because it treats (* keep=32'd1 *) and (* keep=1 *)
differently in violation of Verilog LRM. However, it is possible
to avoid that workaround by using (* keep="TRUE" *). Do that,
and remove `-decimal` to avoid special-casing 32-bit constants.

Refs #373.
2020-05-21 08:57:43 +00:00
whitequark 3420b683a3 build.plat: skip clock constraints on unused signals.
It's not very nice to add more internal mutable state to Platform
related classes, but our whole approach for Platform is inherently
stateful, and other solutions (like changing every individual vendor
platform to check for unused signals) are even worse.

Fixes #374.
2020-05-20 05:35:47 +00:00
whitequark 892cff059b vendor.xilinx_{7series,ultrascale}: add (*keep*) on constrained clocks.
If the clock signal is not a top-level port and has aliases, it can
be optimized out, and then the constraint will no longer apply.
To prevent this, make sure the constrained signal is preferred over
any aliases by using the `keep` attribute.

Vivado does not parse attributes like (* keep = 32'd1 *) as valid
even though, AFAICT, they are equivalent to (* keep = 1 *) or simply
(* keep *) per IEEE 1364. To work around this, use the solution we
currently use for Quartus, which is `write_verilog -decimal`.

Fixes #373.
2020-05-20 04:58:03 +00:00
whitequark 7ea81f5f06 hdl.ast: add const-shift operations.
Also, clean up the rotate code a bit.

Fixes #378.
2020-05-20 03:18:33 +00:00
whitequark 72ef4303a9 hdl.ast: clarify docs for Value.rotate_{left,right}.
"Rotate modulo 2**len(self)" is redundant because that's just how
rotates work.
2020-05-19 23:43:25 +00:00
whitequark 404b2e07e4 hdl.dsl: check for unique domain name.
Fixes #385.
2020-05-19 23:40:49 +00:00
whitequark fbf9e1f339 back.rtlil: handle signed and large Instance parameters correctly.
Fixes #388.
2020-05-19 23:33:14 +00:00
whitequark 393c27ac8e tracer: fix get_var_name() to work on toplevel attributes.
E.g. this now works:

    >>> class dummy: pass
    >>> self = dummy()
    >>> self.foo = Signal()
    >>> self.foo.name
    'foo'
2020-05-17 19:51:58 +00:00
Gwenhael Goavec-Merou e301798cee
vendor.lattice_machxo2: generate binary bitstreams. 2020-05-08 04:42:21 +00:00
whitequark 6cee280407 plat, vendor: systematically escape net and file names in Tcl.
Before this commit, there was only occasional quoting of some names
used in any Tcl files. (I'm not sure what I was thinking.)

After this commit, any substs that may include Tcl special characters
are escaped. This does not include build names (which are explicitly
restricted to ASCII to avoid this problem), or attribute names (which
are chosen from a predefined set). Ideally we'd use a more principled
approach but Jinja2 does not support custom escaping mechanisms.

Note that Vivado restricts clock names to a more restrictive set that
forbids using Tcl special characters even when escaped.

Fixes #375.
2020-05-02 10:41:18 +00:00
whitequark 6e29fbcc61 back.rtlil: fix incorrect escaping of signed parameters.
Also, improve escaping code in general.
2020-04-28 02:18:45 +00:00
whitequark 35f3f7d630 hdl.ast: use SignalSet, not ValueSet, for _[lr]hs_signals().
The implementation of these functions likely predates support for
{Clock,Reset}Signal() in SignalKey.
2020-04-27 18:43:36 +00:00
whitequark da76ffa781 lib.cdc: add missing documentation for AsyncFFSynchronizer. NFC. 2020-04-27 02:20:29 +00:00
awygle ba79b0cdc6
lib.fifo: add r_rst output for AsyncFIFO{,Buffered}.
Fixes #181.
2020-04-24 22:27:04 +00:00
awygle f2b4584b34
hdl.ir: typecheck convert(ports=) more carefully.
The `ports` argument to the `convert` functions is a frequent hotspot of
beginner issues. Check to make sure it is either a list or a tuple, and
give an appropriately helpful error message if not.

Fixes #362.
2020-04-24 21:15:00 +00:00
whitequark fd7f69f7a5 README: link directly to Yosys build instructions. 2020-04-24 21:09:58 +00:00
Teguh Hofstee ed0f508e8a
back.verilog: add workaround for evaluation Verific behavior.
The evaluation version of Verific prints its license information to stdout,
and since it is against the EULA to change that in any way, this behavior
is not possible to fix in Yosys. Add a workaround in nMigen instead.
2020-04-23 21:46:10 +00:00
Teguh Hofstee 875579ea50
back.verilog: make Yosys version check compatible with Verific. 2020-04-22 12:23:14 +00:00
Kate Temkin 0e18429fb7 vendor: use nextpnr -12k for -12F devices; remove theoretical devices
nextpnr now supports -12k; which replaces the use of -25k and --idcode
together to build bitstreams compatible with -12F devices. Use this.

This also removes the LFEUM-12K and its 5G counterpart; as per Dave Shah
they're currently only theoretical FPGAs.
2020-04-21 01:25:28 +00:00
anuejn ff6c0327a7
hdl.rec: make Record inherit from UserValue.
Closes #354.
2020-04-16 16:46:55 +00:00
whitequark b4af217ed0 back.rtlil: translate enum decoders to Yosys enum attributes.
Fixes #254.
2020-04-15 14:45:59 +00:00
whitequark 3346f2c505 buil.plat: enable strict undefined behavior in Jinja2.
By default, if an operation produces an undefined value (a Jinja2
concept that corresponds to Python's KeyError, AttributeError, etc)
then this value may be printed in a template, which is a nop. This
behavior can hide bugs.

This commit changes the Jinja2 behavior to raise an error instead of
producing an undefined value in all cases. (We produce undefined
values deliberately in a few places. Those are unaffected; it is OK
to use several kinds of undefined values in one Jinja2 environment.)

Fixes #337.
2020-04-14 06:17:16 +00:00
whitequark ee73d39b8d back.rtlil: don't emit connections to zero width ports.
Fixes #335.
2020-04-13 17:04:13 +00:00
whitequark 792f35ac8f back.rtlil: refuse to create extremely large wires.
Such wires are likely to trigger pathological behavior in Yosys and,
if applicable, other toolchains that consume Verilog converted from
RTLIL.

Fixes #341.
2020-04-13 16:38:36 +00:00
whitequark 814ffde6fb back.rtlil: fix expansion of Part() for partial dummy writes.
Before this commit, selecting a part that was fully out of bounds of
a value was correctly implemented as a write to a dummy wire, but
selecting a part that was only partially out of bounds resulted in
a crash.

Fixes #351.
2020-04-13 15:56:39 +00:00
whitequark edd2bb2c49 back.rtlil: fix legalization of Part() with stride.
Also known as word_select().
2020-04-13 14:43:43 +00:00
whitequark b44870e779 Clarify a few comments. NFC. 2020-04-13 13:55:23 +00:00
Dan Ravensloft 06c45c9ff0
hdl.ast: add Value.{rotate_left,rotate_right}. 2020-04-13 13:40:39 +00:00
whitequark 8b137438d0 Travis: require tests to pass on pypy3.
Fixes #147.
2020-04-13 11:04:25 +00:00