Commit graph

782 commits

Author SHA1 Message Date
whitequark 687d3a3df7 hdl.dsl: add missing case width check for Enum values.
Fixes #305.
2020-01-31 23:14:16 +00:00
whitequark a9da9efe5b README: clarify relationship to Migen. 2020-01-31 21:10:59 +00:00
whitequark 9964fc6b57 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.
2020-01-31 06:37:45 +00:00
whitequark 3ac13eb8f9 back.rtlil: don't emit wires for empty signals.
Fixes #312.
2020-01-31 03:38:58 +00:00
Mike Walters b72c3fc7f6 vendor.lattice_ecp5: support internal oscillator (OSCG). 2020-01-31 03:18:36 +00:00
Jaro Habiger ec3a21939e build.dsl: allow strings to be used as connector numbers.
Fixes #311.
2020-01-31 03:11:34 +00:00
Sylvain Munaut 7792a6cd9f vendor.lattice_{ice40,ecp5}: Support .il (RTLIL) files in extra_files 2020-01-31 02:56:19 +00:00
whitequark c280c7c2af
Update README. 2020-01-27 18:13:11 +00:00
whitequark a7be3b480a 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).
2020-01-18 10:30:36 +00:00
whitequark 7cb3095334 hdl.xfrm: transform drivers as well in DomainRenamer.
This is necessary because drivers may be late bound.

Fixes #304.
2020-01-17 02:13:46 +00:00
whitequark e18385b613 Remove everything deprecated in nmigen 0.1.
Closes #275.
2020-01-12 13:59:26 +00:00
Staf Verhaegen e4e26717be Signal: allow to use integral Enum for reset value. 2020-01-11 09:03:20 +00:00
schwigi 8184efd612 vendor.intel: fix output enable width for XDR=0 case.
Fixes #297.
2020-01-09 10:09:35 +00:00
Alain Péteut 63902dddb7 build.run: fix indentation. 2020-01-07 12:57:49 +00:00
whitequark 476ce15f04 back.rtlil: do not consider unreachable array elements when legalizing.
Otherwise we produce invalid RTLIL.
2020-01-01 15:26:05 +00:00
whitequark 318274d5a0 hdl.mem: fix src_loc_at in ReadPort, WritePort. 2019-12-15 11:46:26 +00:00
Marcin Kościelnicki 67650214b7 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.
2019-12-04 06:55:35 +00:00
whitequark 7650431996 back.pysim: fix miscompilation of Signal(unsigned) - Signal(signed). 2019-12-02 18:52:55 +00:00
whitequark d048f069f8 hdl.ast: actually remove simulator commands.
These were supposed to be removed in 7df70059, but I forgot.
2019-12-02 02:24:24 +00:00
Dan Ravensloft 72cfdb0c93 vendor.intel: silence meaningless warnings in nMigen files 2019-12-01 00:07:48 +00:00
whitequark 7df70059d1 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.
2019-11-28 21:05:34 +00:00
whitequark f8428ff505 back.rtlil: infer bit width for instance parameters.
Otherwise, Yosys assumes it is always 32, which is often
inappropriate.
2019-11-27 17:58:42 +00:00
whitequark 56bb42aff2 hdl.ir: for instance ports, prioritize defs over uses.
Fixes #274.
2019-11-26 21:19:03 +00:00
Jean-François Nguyen f207f3f620 vendor.xilinx_*: Set IOB attribute on cels instead of nets. 2019-11-18 15:04:03 +00:00
whitequark 7c322e562a 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.
2019-11-18 10:39:55 +00:00
whitequark 834fe3c700 build.plat: in Platform.add_file(), allow adding exact duplicates. 2019-11-15 23:40:44 +00:00
whitequark fe400b5dbc test: add tests for build.plat.Platform.add_file. 2019-11-15 23:39:13 +00:00
whitequark f8f7d83127 hdl.rec: fix Record.like() being called through a subclass.
The subclass does not necessarily take layout as the first argument.
2019-11-09 17:45:07 +00:00
Staf Verhaegen dc2a09b8b9 hdl.rec: make Record(name=) keyword-only.
Everywhere else, the name argument is already keyword-only, so
change it here too for consistency.
2019-11-09 16:10:36 +00:00
whitequark 9749c70730 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.
2019-11-07 08:20:27 +00:00
whitequark e9887780af Improve .gitignore.
Fixes #264.
2019-11-02 02:03:14 +00:00
whitequark 4d6ad28f59 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.
2019-10-28 10:11:41 +00:00
whitequark 75d0fcd639 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.
2019-10-26 06:37:08 +00:00
whitequark 9786d0c0e3 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.
2019-10-26 06:17:14 +00:00
whitequark 8b05b28f5a back.rtlil: avoid exponential behavior when legalizing Part().
Fixes #259.
2019-10-26 02:01:53 +00:00
whitequark ffd10e3042 back.rtlil: fix lowering of Part() on LHS to account for stride. 2019-10-26 01:52:34 +00:00
whitequark 51269ad4a0 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.
2019-10-26 00:09:53 +00:00
whitequark 61e6267daf 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.
2019-10-21 10:39:21 +00:00
whitequark 9fba5ccb51 compat.fhdl.specials: fix argument parsing compatibility. 2019-10-17 07:54:36 +00:00
whitequark fb90043460 lib.io: use keyword-only arguments in Pin(). 2019-10-16 19:50:04 +00:00
whitequark 045f5e19a2 setup: fix commit 5198d99b. 2019-10-16 14:57:40 +00:00
Sebastien Bourdeauducq 07b3510218 verilog: fix yosys version error message 2019-10-16 13:10:19 +08:00
whitequark 58300d8eb6 back.verilog: fix Yosys version check. 2019-10-16 02:25:35 +00:00
whitequark 5198d99b5e setup: don't append local version for tags.
PyPI rejects any archives with local version.
2019-10-15 04:05:13 +00:00
whitequark 1bb3fa861c vendor.lattice_ice40: fix commit 88649def. 2019-10-14 15:55:11 +00:00
whitequark b3a8a43152 vendor.lattice_{ice40,ecp5}: fix typo. 2019-10-13 22:17:46 +00:00
whitequark 88649defda 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@8c0610e84f or newer.
2019-10-13 21:56:40 +00:00
whitequark be6c16d0a2 build.plat: batch files use EQU, not EQ. 2019-10-13 21:45:56 +00:00
whitequark 2f9dab361f {,_}tools→{,_}utils
In context of nMigen, "tools" means "parts of toolchain", so it is
confusing to have a completely unrelated module also called "tools".
2019-10-13 18:53:38 +00:00
whitequark ccd28b40c2 vendor.lattice_{ice40,ecp5}: emit Verilog as well, for debugging. 2019-10-13 18:04:33 +00:00