Commit graph

803 commits

Author SHA1 Message Date
whitequark 27a32f0218 build.plat: don't create default sync domain as reset-less. 2019-10-09 20:44:07 +00:00
whitequark b9e57fd67b build.plat,vendor: always synchronize reset in default sync domain.
This change achieves two related goals.

First, default_rst is no longer assumed to be synchronous to
default_clk, which is  the safer option, since it can be connected to
e.g. buttons on some evaluation boards.

Second, since the power-on / configuration reset is inherently
asynchronous to any user clock, the default create_missing_domain()
behavior is to use a reset synchronizer with `0` as input. Since,
like all reset synchronizers, it uses Signal(reset=1) for its
synchronization stages, after power-on reset it keeps its subordinate
clock domain in reset, and releases it after fabric flops start
toggling.

The latter change is helpful to architectures that lack an end-of-
configuration signal, i.e. most of them. ECP5 was already using
a similar scheme (and is not changed here). Xilinx devices with EOS
use EOS to drive a BUFGMUX, which is more efficient than using
a global reset when the design does not need one; Xilinx devices
without EOS use the new scheme. iCE40 requires a post-configuration
timer because of BRAM silicon bug, and was changed to add a reset
synchronizer if user clock is provided.
2019-10-09 20:02:33 +00:00
whitequark 2512a9a12d back.rtlil: don't crash legalizing values with no branches.
Fixes #239.
2019-10-06 08:52:49 +00:00
whitequark 964c67453f back.rtlil: avoid unsoundness for division by zero.
Fixes #238.
2019-10-04 08:15:45 +00:00
whitequark de34728bf8 hdl.ast: prohibit signed divisors.
See #238.
2019-10-04 07:49:24 +00:00
whitequark 751ae33fe1 build.dsl: accept Pins(invert=True).
The PinsN() form is still preferred, but Pins(invert=) form is useful
for code generic over pin polarity.
2019-10-03 02:44:43 +00:00
whitequark 9458de2079 hdl.ast: don't crash on Mux(<bool>, ...).
Fixes #240.
2019-10-02 08:30:15 +00:00
whitequark d139f340b3 back.rtlil: don't cache wires for legalized switch tests.
This causes miscompilation of code such as:

  r = Array([self.a, self.b])
  m = Module()
  with m.If(r[self.s]):
      m.d.comb += self.o.eq(1)
  return m
2019-10-02 07:51:49 +00:00
whitequark d3f7cc8ed2 back.rtlil: sign of rhs and lhs of ${sshr,sshl,pow} don't need to match. 2019-10-02 03:50:20 +00:00
whitequark 3a1dae591b back.rtlil: it is not necessary to match binop operand width. 2019-10-02 03:38:58 +00:00
Jean-François Nguyen 905920aa76 rpc: add public Records as module ports. 2019-09-30 18:28:21 +00:00
whitequark 52f36025a9 rpc: add support for Yosys RPC protocol. 2019-09-30 17:38:54 +00:00
whitequark 1621ceb65a hdl.ast: actually implement the // operator. 2019-09-28 19:33:24 +00:00
whitequark 450d7efdf2 hdl.dsl: add a diagnostic for m.d.submodules += .... 2019-09-28 17:50:24 +00:00
whitequark a02e3750bf hdl.mem: remove WritePort(priority=) argument.
The write port priority in Yosys is derived directly from the order
in which the ports are declared in the Verilog frontend. It is being
removed for several reasons:
  1. It is not clear if it works correctly for all cases (FFRAM,
     LUTRAM, BRAM).
  2. Although it is roundtripped via Verilog with correct simulation
     semantics, the resulting code has a high chance of being
     interpreted incorrectly by Xilinx tools.
  3. It cannot be roundtripped via FIRRTL, which is an alternative
     backend that is an interesting future option. (FIRRTL leaves
     write collision completely undefined.)
  3. It is a niche feature that, if it is needed, can be completely
     replaced using an explicit comparator, priority encoder, and
     write enable gating circuit. (This is what Xilinx recommends
     for handling this case.)

In the future we should extend nMigen's formal verification to assert
that a write collision does not happen.
2019-09-28 01:29:56 +00:00
whitequark e3a1d05f23 back.rtlil: fix handling of certain nested arrays.
This triggers on code like:

c1 = Signal()
c2 = Signal()
c3 = Signal()
v1 = Array([Const(1, 8), Const(2, 8)])[c1]
v2 = Array([Const(3, 8), Const(4, 8)])[c2]
v3 = Array([v1, v2])[c3]

Fixes #226.
2019-09-24 18:32:26 +00:00
whitequark 53bb4300a3 build.plat: strip internal attributes from Verilog output.
Although useful for debugging, most external tools often complain
about such attributes (with notable exception of Vivado). As such,
it is better to emit Verilog with these attributes into a separate
file such as `design.debug.v` and only emit the attributes that were
explicitly placed by the user to `design.v`.

This still leaves the (*init*) attribute. See #220 for details.
2019-09-24 14:56:00 +00:00
whitequark f87c00e6c3 build.plat,lib.cdc,vendor: unify platform related diagnostics. NFC. 2019-09-24 14:14:45 +00:00
whitequark 0858b8bf6c lib.cdc: specify maximum input delay in seconds.
Since we use hertz elsewhere, this provides for easy conversions.

Also, cast the delay to string before applying it in xilinx_7series,
to avoid stripping the fractional digits.

Closes #234.
2019-09-24 12:30:10 +00:00
whitequark b43d2d36e8 vendor.xilinx_spartan_3_6: explain why ASYNC_REG is used. NFC. 2019-09-24 12:22:29 +00:00
Kate Temkin d14366450b vendor.lattice_ecp5: correct a typo in tristate buffer generation 2019-09-24 11:53:38 +00:00
Darrell Harmon f3a8880cb8 vendor.xilinx_7series: apply false path / max delay constraints. 2019-09-24 00:47:54 +00:00
whitequark da53048ad4 vendor.xilinx_7series: simplify. NFC. 2019-09-23 20:27:42 +00:00
whitequark 6d8590a391 vendor.xilinx_7series: override reset synchronizer. 2019-09-23 20:15:29 +00:00
whitequark 22da78ca28 lib.cdc: add diagnostic checks for synchronization stage count. 2019-09-23 19:38:21 +00:00
whitequark 52e761dc33 lib.cdc: expand ResetSynchronizer documentation.
Loosely based on work by @Wren6991.
2019-09-23 19:31:23 +00:00
whitequark 86f0f12b58 lib.cdc: avoid modifying synchronizers in their elaborate() method. 2019-09-23 16:42:44 +00:00
Darrell Harmon 51f03bb509 vendor.xilinx_spartan_3_6: override reset synchronizer. 2019-09-23 16:28:15 +00:00
whitequark c16f5ecf34 README: add a section on migrating from Migen. 2019-09-23 16:03:28 +00:00
whitequark 8deb13cea3 lib.cdc: MultiReg→FFSynchronizer.
Fixes #229.
2019-09-23 14:18:45 +00:00
whitequark b227352258 hdl.ast: cast Mux() selector to bool if it is not a 1-bit value.
Fixes #232.
2019-09-23 13:39:31 +00:00
whitequark 7777b7b98c back.rtlil: give predictable names to anonymous subfragments.
This is required for applying constraints to clocks in anonymous
subfragments in build.plat.
2019-09-23 12:48:02 +00:00
whitequark fd625619f1 lib.fifo: handle depth=0, elaborating to a dummy FIFO with no logic. 2019-09-23 12:27:59 +00:00
whitequark bc53bbf564 hdl.mem,lib.fifo: use keyword-only arguments for memory geometry.
Fixes #230.
2019-09-23 12:15:06 +00:00
whitequark 1aeb11d7e3 hdl.mem: simplify. NFC. 2019-09-23 11:16:29 +00:00
whitequark 649444449d hdl.ast: make Signal(name=) a keyword-only argument.
Almost no code would specify Signal(_, name) as a positional argument
on purpose, but forgetting parens and accidentally placing signedness
into the name position is so common that we had a test for it.
2019-09-23 11:08:43 +00:00
whitequark 2da0133d52 lib.fifo: change FIFOInterface() diagnostics to follow Memory(). 2019-09-23 11:03:50 +00:00
whitequark ca6b1f2f1c lib.fifo: round up AsyncFIFO{,Buffered} depth to lowest valid value.
Unless exact_depth=True is specified.

The logic introduced in this commit is idempotent: that is, if one
uses the depth of one AsyncFIFOBuffered in the constructor of another
AsyncFIFOBuffered, they will end up with the same depth. More naive
logic would result in an unbounded, quadratic growth with each such
step.

Fixes #219.
2019-09-23 10:58:20 +00:00
whitequark a57b76fb5d lib.fifo: make simulation read() and write() functions compat-only.
These functions were originally changed in 3ed51938, in an attempt
to make them take one cycle instead of two. However, this does not
actually work because of drawbacks of the simulator interface.

Avoid committing to any specific implementation for now, and instead
make them compat-only extensions.
2019-09-23 08:46:12 +00:00
whitequark 1976310bf0 hdl.rec: fix using Enum subclass as shape if direction is specified.
Also improves error messages.

Fixes #224.
2019-09-22 17:23:32 +00:00
whitequark 4c582ef609 hdl.rec: allow using Enum subclass as shape.
Fixes #223.
2019-09-22 15:17:40 +00:00
whitequark 6414c80b82 lib.fifo: add more compatibility shims.
Some downstream code was broken by renames in da4b810f.
2019-09-22 11:56:03 +00:00
whitequark 59acd5d5a5 vendor.lattice_ice40: fix required tool list for iCECube2. NFC. 2019-09-22 07:18:37 +00:00
whitequark 5f9b8ec1eb vendor.lattice_ecp5: simplify quoting. NFC.
See commit ee1ad2da.
2019-09-22 07:17:12 +00:00
whitequark ee1ad2daf1 build.plat: restrict design names to alphanumeric to avoid quoting issues. 2019-09-22 06:57:28 +00:00
whitequark 3d62dac1cb vendor.lattice_ice40: add iCECube support.
This also makes some iCE40 and ECP5 overrides more consistent.
2019-09-21 14:45:17 +00:00
whitequark 8050cfaa98 build.res: simplify clock constraints.
Before this commit, it was possible to set and get clock constraints
placed on Pin objects. This was not a very good implementation, since
it relied on matching the identity of the provided Pin object to
a previously requested one. The only reason it worked like that is
deficiencies in nextpnr.

Since then, nextpnr has been fixed to allow setting constraints on
arbitrary nets. Correspondingly, backends that are using Synplify
were changed to use [get_nets] instead of [get_ports] in SDC files.
However, in some situations, Synplify does not allow specifying
ports in [get_nets]. (In fact, nextpnr had a similar problem, but
it has also been fixed.)

The simplest way to address this is to refer to the interior net
(after the input buffer), which always works. The only downside
of this is that requesting a clock as a raw pin using
    platform.request("clk", dir="-")
and directly applying a constraint to it could fail in some cases.
This is not a significant issue.
2019-09-21 14:12:29 +00:00
whitequark 07a82ed70e build.plat: NMIGEN_<toolchain>_env→NMIGEN_ENV_<toolchain>
This is more consistent with other environment variables nMigen uses.
2019-09-21 12:23:53 +00:00
whitequark 2dc6ae4ac5 lib.fifo: update docs. NFC. 2019-09-21 06:53:57 +00:00
whitequark a13a21cbd6 hdl.ast: update docs. NFC. 2019-09-21 06:53:13 +00:00