nmigen.git
4 years agohdl.dsl: don't allow inheriting from Module.
whitequark [Sat, 1 Feb 2020 02:15:45 +0000 (02:15 +0000)]
hdl.dsl: don't allow inheriting from Module.

`Module` is an object with a lot of complex and sometimes fragile
behavior that overrides Python attribute accessors and so on.
To prevent user designs from breaking when it is changed, it is not
supposed to be inherited from (unlike in Migen), but rather returned
from the elaborate() method. This commit makes sure it will not be
inherited from by accident (most likely by users familiar with
Migen).

Fixes #286.

4 years agohdl.ast: warn on unused property statements (Assert, Assume, etc).
whitequark [Sat, 1 Feb 2020 01:55:23 +0000 (01:55 +0000)]
hdl.ast: warn on unused property statements (Assert, Assume, etc).

A property statement that is created but not added to a module is
virtually always a serious bug, since it can make formal verification
pass when it should not. Therefore, add a warning to it, similar to
UnusedElaboratable.

Doing this to all statements is possible, but many temporary ones are
created internally by nMigen, and the extensive changes required to
remove false positives are likely not worth the true positives.
We can revisit this in the future.

Fixes #303.

4 years ago_unused: extract must-use logic from hdl.ir.
whitequark [Sat, 1 Feb 2020 01:35:05 +0000 (01:35 +0000)]
_unused: extract must-use logic from hdl.ir.

4 years agohdl.dsl: add missing case width check for Enum values.
whitequark [Fri, 31 Jan 2020 23:14:16 +0000 (23:14 +0000)]
hdl.dsl: add missing case width check for Enum values.

Fixes #305.

4 years agoREADME: clarify relationship to Migen.
whitequark [Fri, 31 Jan 2020 21:10:59 +0000 (21:10 +0000)]
README: clarify relationship to Migen.

4 years agohdl.dsl: make `if m.{If,Elif,Else}(...)` a syntax error.
whitequark [Fri, 31 Jan 2020 06:37:45 +0000 (06:37 +0000)]
hdl.dsl: make `if m.{If,Elif,Else}(...)` a syntax error.

A common typo, and hard to notice when it's silently ignored.

Fixes #284.

4 years agoback.rtlil: don't emit wires for empty signals.
whitequark [Fri, 31 Jan 2020 03:38:58 +0000 (03:38 +0000)]
back.rtlil: don't emit wires for empty signals.

Fixes #312.

4 years agovendor.lattice_ecp5: support internal oscillator (OSCG).
Mike Walters [Fri, 17 Jan 2020 16:10:33 +0000 (16:10 +0000)]
vendor.lattice_ecp5: support internal oscillator (OSCG).

4 years agobuild.dsl: allow strings to be used as connector numbers.
Jaro Habiger [Sun, 26 Jan 2020 17:35:41 +0000 (18:35 +0100)]
build.dsl: allow strings to be used as connector numbers.

Fixes #311.

4 years agovendor.lattice_{ice40,ecp5}: Support .il (RTLIL) files in extra_files
Sylvain Munaut [Mon, 20 Jan 2020 08:30:49 +0000 (09:30 +0100)]
vendor.lattice_{ice40,ecp5}: Support .il (RTLIL) files in extra_files

4 years agoUpdate README.
whitequark [Mon, 27 Jan 2020 18:13:11 +0000 (18:13 +0000)]
Update README.

4 years agohdl.ir: resolve hierarchy conflicts before creating missing domains.
whitequark [Sat, 18 Jan 2020 10:30:36 +0000 (10:30 +0000)]
hdl.ir: resolve hierarchy conflicts before creating missing domains.

Otherwise, code such as:

    m.submodules.a = (something with cd_sync)
    m.submodules.b = (something with cd_sync)
    m.d.b_sync += x.eq(y)

causes an assertion failure.

Fixes #304 (again).

4 years agohdl.xfrm: transform drivers as well in DomainRenamer.
whitequark [Fri, 17 Jan 2020 02:13:46 +0000 (02:13 +0000)]
hdl.xfrm: transform drivers as well in DomainRenamer.

This is necessary because drivers may be late bound.

Fixes #304.

4 years agoRemove everything deprecated in nmigen 0.1.
whitequark [Sun, 12 Jan 2020 13:59:26 +0000 (13:59 +0000)]
Remove everything deprecated in nmigen 0.1.

Closes #275.

4 years agoSignal: allow to use integral Enum for reset value.
Staf Verhaegen [Fri, 10 Jan 2020 12:28:19 +0000 (13:28 +0100)]
Signal: allow to use integral Enum for reset value.

4 years agovendor.intel: fix output enable width for XDR=0 case.
schwigi [Thu, 9 Jan 2020 10:09:35 +0000 (11:09 +0100)]
vendor.intel: fix output enable width for XDR=0 case.

Fixes #297.

4 years agobuild.run: fix indentation.
Alain Péteut [Tue, 7 Jan 2020 12:39:49 +0000 (13:39 +0100)]
build.run: fix indentation.

4 years agoback.rtlil: do not consider unreachable array elements when legalizing.
whitequark [Wed, 1 Jan 2020 15:26:05 +0000 (15:26 +0000)]
back.rtlil: do not consider unreachable array elements when legalizing.

Otherwise we produce invalid RTLIL.

4 years agohdl.mem: fix src_loc_at in ReadPort, WritePort.
whitequark [Sun, 15 Dec 2019 11:46:14 +0000 (11:46 +0000)]
hdl.mem: fix src_loc_at in ReadPort, WritePort.

4 years agohdl.ast: Fix width for unary minus operator on signed argument.
Marcin Kościelnicki [Tue, 3 Dec 2019 17:33:26 +0000 (18:33 +0100)]
hdl.ast: Fix width for unary minus operator on signed argument.

To properly represent a negation of a signed X-bit quantity we may, in
general, need a signed (X+1)-bit signal — for example, negation of
3-bit -4 is 4, which is not representable in signed 3 bits.

4 years agoback.pysim: fix miscompilation of Signal(unsigned) - Signal(signed).
whitequark [Mon, 2 Dec 2019 18:52:55 +0000 (18:52 +0000)]
back.pysim: fix miscompilation of Signal(unsigned) - Signal(signed).

4 years agohdl.ast: actually remove simulator commands.
whitequark [Mon, 2 Dec 2019 02:23:36 +0000 (02:23 +0000)]
hdl.ast: actually remove simulator commands.

These were supposed to be removed in 7df70059, but I forgot.

4 years agovendor.intel: silence meaningless warnings in nMigen files
Dan Ravensloft [Sun, 1 Dec 2019 00:07:48 +0000 (00:07 +0000)]
vendor.intel: silence meaningless warnings in nMigen files

4 years agoback.pysim: redesign the simulator.
whitequark [Fri, 22 Nov 2019 08:32:41 +0000 (08:32 +0000)]
back.pysim: redesign the simulator.

The redesign introduces no fundamental incompatibilities, but it does
involve minor breaking changes:
  * The simulator commands were moved from hdl.ast to back.pysim
    (instead of only being reexported from back.pysim).
  * back.pysim.DeadlineError was removed.

Summary of changes:
  * The new simulator compiles HDL to Python code and is >6x faster.
    (The old one compiled HDL to lots of Python lambdas.)
  * The new simulator is a straightforward, rigorous implementation
    of the Synchronous Reactive Programming paradigm, instead of
    a pile of ad-hoc code with no particular design driving it.
  * The new simulator never raises DeadlineError, and there is no
    limit on the amount of delta cycles.
  * The new simulator robustly handles multiclock designs.
  * The new simulator can be reset, such that the compiled design
    can be reused, which can save significant runtime with large
    designs.
  * Generators can no longer be added as processes, since that would
    break reset(); only generator functions may be. If necessary,
    they may be added by wrapping them into a generator function;
    a deprecated fallback does just that. This workaround will raise
    an exception if the simulator is reset and restarted.
  * The new simulator does not depend on Python extensions.
    (The old one required bitarray, which did not provide wheels.)

Fixes #28.
Fixes #34.
Fixes #160.
Fixes #161.
Fixes #215.
Fixes #242.
Fixes #262.

4 years agoback.rtlil: infer bit width for instance parameters.
whitequark [Wed, 27 Nov 2019 17:58:42 +0000 (17:58 +0000)]
back.rtlil: infer bit width for instance parameters.

Otherwise, Yosys assumes it is always 32, which is often
inappropriate.

4 years agohdl.ir: for instance ports, prioritize defs over uses.
whitequark [Tue, 26 Nov 2019 21:17:12 +0000 (21:17 +0000)]
hdl.ir: for instance ports, prioritize defs over uses.

Fixes #274.

4 years agovendor.xilinx_*: Set IOB attribute on cels instead of nets.
Jean-François Nguyen [Mon, 18 Nov 2019 14:58:39 +0000 (15:58 +0100)]
vendor.xilinx_*: Set IOB attribute on cels instead of nets.

4 years agoback.rtlil: extend shorter operand of a binop when matching sign.
whitequark [Mon, 18 Nov 2019 10:39:55 +0000 (10:39 +0000)]
back.rtlil: extend shorter operand of a binop when matching sign.

This is necessary because converting a large unsigned value to
a signed value of the same width may change its sign.

Fixes #271.

4 years agobuild.plat: in Platform.add_file(), allow adding exact duplicates.
whitequark [Fri, 15 Nov 2019 23:40:44 +0000 (23:40 +0000)]
build.plat: in Platform.add_file(), allow adding exact duplicates.

4 years agotest: add tests for build.plat.Platform.add_file.
whitequark [Fri, 15 Nov 2019 23:35:55 +0000 (23:35 +0000)]
test: add tests for build.plat.Platform.add_file.

4 years agohdl.rec: fix Record.like() being called through a subclass. v0.1
whitequark [Sat, 9 Nov 2019 16:44:01 +0000 (16:44 +0000)]
hdl.rec: fix Record.like() being called through a subclass.

The subclass does not necessarily take layout as the first argument.

4 years agohdl.rec: make Record(name=) keyword-only.
Staf Verhaegen [Sat, 9 Nov 2019 16:10:36 +0000 (17:10 +0100)]
hdl.rec: make Record(name=) keyword-only.

Everywhere else, the name argument is already keyword-only, so
change it here too for consistency.

4 years agohdl.ir: lower domains before resolving hierarchy conflicts.
whitequark [Thu, 7 Nov 2019 08:20:27 +0000 (08:20 +0000)]
hdl.ir: lower domains before resolving hierarchy conflicts.

Otherwise, two subfragments with the same local clock domain would
not be able to drive its clock or reset signals. This can be easily
hit if using two ResetSynchronizers in one module.

Fixes #265.

4 years agoImprove .gitignore.
whitequark [Sat, 2 Nov 2019 02:03:14 +0000 (02:03 +0000)]
Improve .gitignore.

Fixes #264.

4 years agoback.verilog: remove $verilog_initial_trigger after proc_prune.
whitequark [Mon, 28 Oct 2019 10:11:41 +0000 (10:11 +0000)]
back.verilog: remove $verilog_initial_trigger after proc_prune.

$verilog_initial_trigger was introduced to work around Verilog
simulation semantics issues with `always @*` statements that only
have constants on RHS and in conditions. Unfortunately, it breaks
Verilator. Since the combination of proc_prune and proc_clean passes
eliminates all such statements, it can be simply removed when both
of these passes are available, currently on Yosys master. After
Yosys 0.10 is released, we can get rid of $verilog_initial_trigger
entirely.

4 years agotest: use `#nmigen:` magic comment instead of monkey patch.
whitequark [Sat, 26 Oct 2019 06:36:54 +0000 (06:36 +0000)]
test: use `#nmigen:` magic comment instead of monkey patch.

Also, fix missing and incorrect src_loc_at arguments where
appropriate so the testsuite passes without warnings.

4 years agohdl.ir: allow disabling UnusedElaboratable warning in file scope.
whitequark [Sat, 26 Oct 2019 05:34:00 +0000 (05:34 +0000)]
hdl.ir: allow disabling UnusedElaboratable warning in file scope.

This warning is usually quite handy, but is problematic in tests:
although it can be suppressed by using Fragment.get on elaboratable,
that is not always possible, in particular when writing tests for
exceptions raised by __init__, e.g.:

    def test_wrong_csr_bus(self):
        with self.assertRaisesRegex(ValueError, r"blah blah"):
            WishboneCSRBridge(csr_bus=object())

In theory, it should be possible to suppress warnings per-module
and even per-line using code such as:

    import re, warnings
    from nmigen.hdl.ir import UnusedElaboratable
    warnings.filterwarnings("ignore", category=UnusedElaboratable,
                            module=re.escape(__name__))

Unfortunately, not only is this code quite convoluted, but it also
does not actually work; we are using warnings.warn_explicit() because
we collect source locations on our own, but it requires the caller
to extract the __warningregistry__ dictionary from module globals,
or warning suppression would not work. Not only is this not feasible
in most diagnostic sites in nMigen, but also I never got it to work
anyway, even when passing all of module, registry, and module_globals
to warn_explicit().

Instead, use a magic comment at the start of a file to do this job,
which might not be elegant but is simple and practical. For now,
only UnusedElaboratable can be suppressed with it, but in future,
other linter parameters may become tweakable this way.

4 years agoback.rtlil: avoid exponential behavior when legalizing Part().
whitequark [Sat, 26 Oct 2019 02:01:53 +0000 (02:01 +0000)]
back.rtlil: avoid exponential behavior when legalizing Part().

Fixes #259.

4 years agoback.rtlil: fix lowering of Part() on LHS to account for stride.
whitequark [Sat, 26 Oct 2019 01:52:34 +0000 (01:52 +0000)]
back.rtlil: fix lowering of Part() on LHS to account for stride.

4 years agohdl.ast: simplify {bit,word}_select with constant offset.
whitequark [Sat, 26 Oct 2019 00:09:53 +0000 (00:09 +0000)]
hdl.ast: simplify {bit,word}_select with constant offset.

We don't have any other convenient shortcut for x[off*w:(off+1)*w],
but using word_select to extract a single static range would result
in severe bloat of emitted code through expansion to dead branches.
Recognize and simplify this pattern.

4 years agoExplicitly restrict prelude imports.
whitequark [Mon, 21 Oct 2019 10:39:21 +0000 (10:39 +0000)]
Explicitly restrict prelude imports.

It turns out that while Python does not import _private identifiers
when using * imports, it does nevertheless import all submodules.

Avoid polluting the namespace in the prelude by explicitly listing
all exported identifiers.

4 years agocompat.fhdl.specials: fix argument parsing compatibility.
whitequark [Thu, 17 Oct 2019 07:54:36 +0000 (07:54 +0000)]
compat.fhdl.specials: fix argument parsing compatibility.

4 years agolib.io: use keyword-only arguments in Pin().
whitequark [Wed, 16 Oct 2019 19:50:04 +0000 (19:50 +0000)]
lib.io: use keyword-only arguments in Pin().

4 years agosetup: fix commit 5198d99b.
whitequark [Wed, 16 Oct 2019 14:24:13 +0000 (14:24 +0000)]
setup: fix commit 5198d99b.

4 years agoverilog: fix yosys version error message
Sebastien Bourdeauducq [Wed, 16 Oct 2019 05:10:19 +0000 (13:10 +0800)]
verilog: fix yosys version error message

4 years agoback.verilog: fix Yosys version check.
whitequark [Wed, 16 Oct 2019 02:25:35 +0000 (02:25 +0000)]
back.verilog: fix Yosys version check.

4 years agosetup: don't append local version for tags. v0.1rc1
whitequark [Tue, 15 Oct 2019 04:04:18 +0000 (04:04 +0000)]
setup: don't append local version for tags.

PyPI rejects any archives with local version.

4 years agovendor.lattice_ice40: fix commit 88649def.
whitequark [Mon, 14 Oct 2019 15:55:11 +0000 (15:55 +0000)]
vendor.lattice_ice40: fix commit 88649def.

4 years agovendor.lattice_{ice40,ecp5}: fix typo.
whitequark [Sun, 13 Oct 2019 22:17:46 +0000 (22:17 +0000)]
vendor.lattice_{ice40,ecp5}: fix typo.

4 years agovendor.lattice_ice40: use pcf files instead of pre-pack Python scripts.
whitequark [Sun, 13 Oct 2019 21:56:40 +0000 (21:56 +0000)]
vendor.lattice_ice40: use pcf files instead of pre-pack Python scripts.

This allows to use nextpnr-ice40 built without Python with nMigen.
Requires nextpnr revision
YosysHQ/nextpnr@8c0610e84fa6a38d3f351774bd81a32c96a91242 or newer.

4 years agobuild.plat: batch files use EQU, not EQ.
whitequark [Sun, 13 Oct 2019 21:45:56 +0000 (21:45 +0000)]
build.plat: batch files use EQU, not EQ.

4 years ago{,_}tools→{,_}utils
whitequark [Sun, 13 Oct 2019 18:53:38 +0000 (18:53 +0000)]
{,_}tools→{,_}utils

In context of nMigen, "tools" means "parts of toolchain", so it is
confusing to have a completely unrelated module also called "tools".

4 years agovendor.lattice_{ice40,ecp5}: emit Verilog as well, for debugging.
whitequark [Sun, 13 Oct 2019 18:04:33 +0000 (18:04 +0000)]
vendor.lattice_{ice40,ecp5}: emit Verilog as well, for debugging.

4 years agobuild.plat: fold emit_prelude() into emit_commands().
whitequark [Sun, 13 Oct 2019 13:57:48 +0000 (13:57 +0000)]
build.plat: fold emit_prelude() into emit_commands().

Commit a783e464 broke all toolchains using bash.

4 years agoRefactor build script toolchain lookups.
Emily [Sun, 13 Oct 2019 13:53:24 +0000 (14:53 +0100)]
Refactor build script toolchain lookups.

Now environment variable overrides no longer infect the build scripts.

_toolchain.overrides is dropped as probably misguided in the first place.

Fixes #251.

4 years agohdl.ir: allow ClockSignal and ResetSignal in ports.
whitequark [Sun, 13 Oct 2019 03:39:56 +0000 (03:39 +0000)]
hdl.ir: allow ClockSignal and ResetSignal in ports.

Fixes #248.

4 years agohdl.ir: cast instance port connections to Values.
whitequark [Sun, 13 Oct 2019 03:19:17 +0000 (03:19 +0000)]
hdl.ir: cast instance port connections to Values.

Fixes #249.

4 years agocompat.fhdl.decorators: improve backwards compatibility.
whitequark [Sun, 13 Oct 2019 01:38:09 +0000 (01:38 +0000)]
compat.fhdl.decorators: improve backwards compatibility.

4 years agocompat.fhdl.bitcontainer: update Value.wrap call.
whitequark [Sun, 13 Oct 2019 01:37:11 +0000 (01:37 +0000)]
compat.fhdl.bitcontainer: update Value.wrap call.

4 years agodoc: bring COMPAT_SUMMARY up to date.
whitequark [Sat, 12 Oct 2019 23:15:09 +0000 (23:15 +0000)]
doc: bring COMPAT_SUMMARY up to date.

Fixes #112.

4 years agocompat.genlib.fsm: add migration warning.
whitequark [Sat, 12 Oct 2019 22:48:08 +0000 (22:48 +0000)]
compat.genlib.fsm: add migration warning.

4 years agocompat.fhdl.decorators: add migration warnings.
whitequark [Sat, 12 Oct 2019 22:44:12 +0000 (22:44 +0000)]
compat.fhdl.decorators: add migration warnings.

4 years agohdl.ast: rename Slice.end back to Slice.stop.
whitequark [Sat, 12 Oct 2019 22:40:30 +0000 (22:40 +0000)]
hdl.ast: rename Slice.end back to Slice.stop.

It used to be called .stop in oMigen, and it's also called .stop in
Python range and slice objects, so keep that.

4 years agocompat.fhdl.structure: remove SPECIAL_* constants.
whitequark [Sat, 12 Oct 2019 22:35:43 +0000 (22:35 +0000)]
compat.fhdl.structure: remove SPECIAL_* constants.

They cannot be used with nMigen designs since nMigen does not have
specials.

4 years ago_tools: extract most utility methods to a private package.
whitequark [Sat, 12 Oct 2019 22:27:43 +0000 (22:27 +0000)]
_tools: extract most utility methods to a private package.

We don't want to guarantee backwards compatibility for most of them.

4 years agoback.rtlil: fix DeprecationWarning. NFC.
Jean-François Nguyen [Sat, 12 Oct 2019 21:44:39 +0000 (23:44 +0200)]
back.rtlil: fix DeprecationWarning. NFC.

4 years agoRename remaining `wrap` methods to `cast`.
whitequark [Fri, 11 Oct 2019 13:28:26 +0000 (13:28 +0000)]
Rename remaining `wrap` methods to `cast`.

Following commit d72d4a55.

4 years agohdl.ast: deprecate shapes like `(1, True)` in favor of `signed(1)`.
whitequark [Fri, 11 Oct 2019 13:22:08 +0000 (13:22 +0000)]
hdl.ast: deprecate shapes like `(1, True)` in favor of `signed(1)`.

This is a great improvement in clarity.

4 years agohdl.ast: deprecate Signal.{range,enum}.
whitequark [Fri, 11 Oct 2019 13:07:42 +0000 (13:07 +0000)]
hdl.ast: deprecate Signal.{range,enum}.

Although constructor methods can improve clarity, there are many
contexts in which it is useful to use range() as a shape: notably
Layout, but also Const and AnyConst/AnyValue. Instead of duplicating
these constructor methods everywhere (which is not even easily
possible for Layout), use casting to Shape, introduced in 6aabdc0a.

Fixes #225.

4 years agohdl.ast: add an explicit Shape class, included in prelude.
whitequark [Fri, 11 Oct 2019 12:52:41 +0000 (12:52 +0000)]
hdl.ast: add an explicit Shape class, included in prelude.

Shapes have long been a part of nMigen, but represented using tuples.
This commit adds a Shape class (using namedtuple for backwards
compatibility), and accepts anything castable to Shape (including
enums, ranges, etc) anywhere a tuple was accepted previously.

In addition, `signed(n)` and `unsigned(n)` are added as aliases for
`Shape(n, signed=True)` and `Shape(n, signed=False)`, transforming
code such as `Signal((8, True))` to `Signal(signed(8))`.
These aliases are also included in prelude.

Preparation for #225.

4 years agoConsistently use {!r}, not '{!r}' in diagnostics.
whitequark [Fri, 11 Oct 2019 11:47:42 +0000 (11:47 +0000)]
Consistently use {!r}, not '{!r}' in diagnostics.

This can cause confusion:
  * If the erroneous object is None, it is printed as 'None', which
    appears as a string (and could be the result of converting None
    to a string.)
  * If the erroneous object is a string, it is printed as ''<val>'',
    which is a rather strange combination of quotes.

4 years agohdl.ast: Operator.{op→operator}
whitequark [Fri, 11 Oct 2019 11:37:26 +0000 (11:37 +0000)]
hdl.ast: Operator.{op→operator}

Both "operator" and "operand" were shortened to "op" in different
places in code, which caused confusion.

4 years agohdl.ast: simplify enum handling.
whitequark [Fri, 11 Oct 2019 11:16:00 +0000 (11:16 +0000)]
hdl.ast: simplify enum handling.

4 years agohdl.ast: Value.{wrap→cast}
whitequark [Fri, 11 Oct 2019 10:49:34 +0000 (10:49 +0000)]
hdl.ast: Value.{wrap→cast}

Preparation for #225.

4 years agovendor.xilinx_ultrascale: new supported family.
whitequark [Thu, 10 Oct 2019 16:35:48 +0000 (16:35 +0000)]
vendor.xilinx_ultrascale: new supported family.

4 years agoxilinx_7series: add grade platform property.
whitequark [Thu, 10 Oct 2019 16:25:10 +0000 (16:25 +0000)]
xilinx_7series: add grade platform property.

For some devices grade has to be omitted, so it is optional.

4 years agovendor.lattice_machxo2: new supported family.
whitequark [Thu, 10 Oct 2019 15:33:01 +0000 (15:33 +0000)]
vendor.lattice_machxo2: new supported family.

4 years agovendor: yosys is a required tool for all Verilog-based flows.
whitequark [Thu, 10 Oct 2019 14:38:09 +0000 (14:38 +0000)]
vendor: yosys is a required tool for all Verilog-based flows.

4 years agoREADME: add device support matrix.
whitequark [Thu, 10 Oct 2019 00:50:01 +0000 (00:50 +0000)]
README: add device support matrix.

4 years agovendor.intel: add Quartus support.
whitequark [Wed, 21 Aug 2019 22:14:33 +0000 (22:14 +0000)]
vendor.intel: add Quartus support.

Co-authored-by: Dan Ravensloft <dan.ravensloft@gmail.com>
4 years agoexamples: update blinky, add some explanatory text about domains.
whitequark [Wed, 9 Oct 2019 23:19:19 +0000 (23:19 +0000)]
examples: update blinky, add some explanatory text about domains.

4 years agobuild.plat: elaborate result of create_missing_domain() against platform.
whitequark [Wed, 9 Oct 2019 21:16:14 +0000 (21:16 +0000)]
build.plat: elaborate result of create_missing_domain() against platform.

Before this commit, the result was elaborated without platform, which
caused generic implementation of e.g. ResetSynchronizer to be used.

4 years agobuild.plat: don't create default sync domain as reset-less.
whitequark [Wed, 9 Oct 2019 20:44:07 +0000 (20:44 +0000)]
build.plat: don't create default sync domain as reset-less.

4 years agobuild.plat,vendor: always synchronize reset in default sync domain.
whitequark [Wed, 9 Oct 2019 20:02:33 +0000 (20:02 +0000)]
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.

4 years agoback.rtlil: don't crash legalizing values with no branches.
whitequark [Sun, 6 Oct 2019 08:52:49 +0000 (08:52 +0000)]
back.rtlil: don't crash legalizing values with no branches.

Fixes #239.

4 years agoback.rtlil: avoid unsoundness for division by zero.
whitequark [Fri, 4 Oct 2019 07:56:06 +0000 (07:56 +0000)]
back.rtlil: avoid unsoundness for division by zero.

Fixes #238.

4 years agohdl.ast: prohibit signed divisors.
whitequark [Fri, 4 Oct 2019 07:49:24 +0000 (07:49 +0000)]
hdl.ast: prohibit signed divisors.

See #238.

4 years agobuild.dsl: accept Pins(invert=True).
whitequark [Thu, 3 Oct 2019 02:44:43 +0000 (02:44 +0000)]
build.dsl: accept Pins(invert=True).

The PinsN() form is still preferred, but Pins(invert=) form is useful
for code generic over pin polarity.

4 years agohdl.ast: don't crash on Mux(<bool>, ...).
whitequark [Wed, 2 Oct 2019 08:24:37 +0000 (08:24 +0000)]
hdl.ast: don't crash on Mux(<bool>, ...).

Fixes #240.

4 years agoback.rtlil: don't cache wires for legalized switch tests.
whitequark [Wed, 2 Oct 2019 07:51:49 +0000 (07:51 +0000)]
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

4 years agoback.rtlil: sign of rhs and lhs of ${sshr,sshl,pow} don't need to match.
whitequark [Wed, 2 Oct 2019 03:50:20 +0000 (03:50 +0000)]
back.rtlil: sign of rhs and lhs of ${sshr,sshl,pow} don't need to match.

4 years agoback.rtlil: it is not necessary to match binop operand width.
whitequark [Wed, 2 Oct 2019 03:38:58 +0000 (03:38 +0000)]
back.rtlil: it is not necessary to match binop operand width.

4 years agorpc: add public Records as module ports.
Jean-François Nguyen [Sun, 29 Sep 2019 22:12:17 +0000 (00:12 +0200)]
rpc: add public Records as module ports.

4 years agorpc: add support for Yosys RPC protocol.
whitequark [Fri, 27 Sep 2019 02:35:45 +0000 (02:35 +0000)]
rpc: add support for Yosys RPC protocol.

4 years agohdl.ast: actually implement the // operator.
whitequark [Sat, 28 Sep 2019 19:33:24 +0000 (19:33 +0000)]
hdl.ast: actually implement the // operator.

4 years agohdl.dsl: add a diagnostic for `m.d.submodules += ...`.
whitequark [Sat, 28 Sep 2019 17:50:24 +0000 (17:50 +0000)]
hdl.dsl: add a diagnostic for `m.d.submodules += ...`.

4 years agohdl.mem: remove WritePort(priority=) argument.
whitequark [Sat, 28 Sep 2019 01:29:56 +0000 (01:29 +0000)]
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.

4 years agoback.rtlil: fix handling of certain nested arrays.
whitequark [Tue, 24 Sep 2019 18:32:26 +0000 (18:32 +0000)]
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.

4 years agobuild.plat: strip internal attributes from Verilog output.
whitequark [Tue, 24 Sep 2019 14:54:22 +0000 (14:54 +0000)]
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.

4 years agobuild.plat,lib.cdc,vendor: unify platform related diagnostics. NFC.
whitequark [Tue, 24 Sep 2019 14:14:45 +0000 (14:14 +0000)]
build.plat,lib.cdc,vendor: unify platform related diagnostics. NFC.