Commit graph

1072 commits

Author SHA1 Message Date
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
whitequark 7ba362a8d8 Travis: upgrade to bionic. 2020-04-13 09:40:00 +00:00
whitequark 91d6e4b22a build.run: fix BuildProducts.extract to work with subdirectories.
Fixes #353.
2020-04-12 04:56:15 +00:00
whitequark 7a08901117 hdl.rec: improve repr() for Layout.
Fixes #326.
2020-04-12 04:47:40 +00:00
whitequark e9c75f7ca1 hdl.ast: improve repr() for Shape.
The default __repr__() from typing.NamedTuple does not include
the module name, so the replacement (which uses the preferred syntax
for specifying these shapes) doesn't either.
2020-04-12 03:59:56 +00:00
whitequark 9055090f65 build.plat: don't check for toolchain presence if do_build=False. 2020-04-12 03:28:29 +00:00
Stuart Olsen 0e40dc0a2d back.pysim: Clear pending updates after they are effected 2020-04-08 14:08:35 +00:00
Stuart Olsen 1e744097ab back.pysim: Eliminate duplicate dict lookup in VCD update 2020-04-07 09:23:24 +00:00
Stuart Olsen 2398b7922e back.pysim: Reuse clock simulation commands 2020-04-07 09:23:17 +00:00
whitequark bb1bbcc51a hdl.mem: fix source location of ReadPort.en. 2020-04-05 02:00:06 +00:00
whitequark ec8386a797 back.pysim: fix emission of undriven traces to VCD files.
This has been originally implemented in commit d3775eed (which fixed
`write_vcd(traces=)` to do something at all), but had a flaw where
undriven traces would not be correctly placed in hierarchy. This
used to produce incorrect results on pyvcd 0.1, but started causing
assertion failures on pyvcd 0.2.

Fixes #345.
2020-04-03 05:20:42 +00:00
whitequark c79caead33 setup: bump pyvcd to ~=0.2.
We don't use any of the deprecated functionality, and the added
requirement of Python 3.6+ matches ours.

Having a requirement for pyvcd ~=0.1.4 was actually the cause of
the error I tried to fix in commit 6e1145e2. It had nothing to do
with Jinja2 (though it is definitely still good to have the tighter
requirement on Jinja2); the cause of the error was that pip would
install Jinja2, schedule installing markupsafe, install pyvcd 0.2.0
and then choke on the pyvcd 0.1.4 requirement, which would prevent
it from installing markupsafe &c. Why it does that is beyond me.
2020-04-02 11:23:49 +00:00
Jacob Lifshay 995f3a147b Add support for using non-compat Elaboratable instances with compat.fhdl.verilog.convert and compat.run_simulation
Fixes #344
2020-04-02 02:46:44 +00:00
whitequark 6e1145e2e7 setup: tighten version constraint on Jinja2.
I remember thinking that not constraining it properly might bite us
someday, but assumed that Jinja2 will always stay version 2. Now it
looks like Jinja2 3.0.0a1 got released, pip picks it by default, and
it's currently broken (something about markupsafe missing).

Do what needed to be done in the first place.
2020-04-02 01:35:39 +00:00