Commit graph

757 commits

Author SHA1 Message Date
whitequark 3b6727152e test_build_res: fix after commit 3e2ecdf2. 2020-02-07 00:07:19 +00:00
whitequark 3e2ecdf2fb build.res,vendor: place clock constraint on port, not net, if possible.
For most toolchains, these are functionally identical, although ports
tend to work a bit better, being the common case. For Vivado, though,
it is necessary to place them on the port because its timing analyzer
considers input buffer delay.

Fixes #301.
2020-02-06 23:37:15 +00:00
whitequark 5888f29c1f xilinx_{7series,ultrascale}: run report_methodology.
This can expose important timing issues, such as #301.
2020-02-06 19:38:21 +00:00
whitequark 27b47faf16 hdl.ast: add Value.{as_signed,as_unsigned}.
Before this commit, there was no way to do so besides creating and
assigning an intermediate signal, which could not be extracted into
a helper function due to Module statefulness.

Fixes #292.
2020-02-06 18:27:55 +00:00
whitequark 9301e31b69 test_lib_fifo: define all referenced FSM states.
Broken in commit a1c58633.
2020-02-06 18:10:15 +00:00
whitequark a1c58633e6 hdl.dsl: make referencing undefined FSM states an error.
Before this commit, doing something like:

    with m.FSM():
        with m.State("FOO"):
            m.next = "bAR"
        with m.State("BAR"):
            m.next = "FOO"

would silently create an empty state `bAR` and get stuck in it until
the module is reset. This was done intentionally (in Migen, this code
would in fact miscompile), but in retrospect was clearly a bad idea;
it turns typos into bugs, while in the rare case that branching to
a completely empty state is desired, it is trivial to define one.

Fixes #315.
2020-02-06 17:47:46 +00:00
whitequark 97cc78a3db hdl.ir: type check ports.
Fixes #290.
2020-02-06 17:33:41 +00:00
whitequark 882fddfa96 back.pysim: emit toplevel inputs in VCD files as well.
Before this commit, only signals driven from fragments (in practice,
everything except toplevel inputs) would get written to a VCD file.
Not having toplevel inputs in the dump made debugging ~impossible.

After this commit, all signals the fragment refers to get written to
a VCD file. (More specifically, all signals the compiler assigns
an index to, i.e. signals the generated code reads or writes.)

Fixes #280.
2020-02-06 17:19:47 +00:00
whitequark d3775eedd7 back.pysim: make write_vcd(traces=) actually use those traces.
Reported in #280.
2020-02-06 17:07:48 +00:00
whitequark 3df429703c hdl.dsl: reject name mismatch in m.domains.<name> +=.
This would violate invariants later in the elaboration process.

Fixes #282.
2020-02-06 16:13:59 +00:00
whitequark 86b57fe6b6 hdl.dsl: type check when adding to m.domains. 2020-02-06 15:19:16 +00:00
whitequark 31cd72c0b6 hdl.mem: add synthesis attribute support.
Fixes #291.
2020-02-06 14:53:16 +00:00
whitequark f7abe368a9 hdl.mem: document Memory. 2020-02-06 13:47:13 +00:00
whitequark dfcf7938ea hdl.{ast,dsl}: allow whitespace in bit patterns.
Fixes #316.
2020-02-04 07:54:54 +00:00
whitequark a295e3599c hdl.ast: update documentation for Signal.
Fixes #288.
2020-02-01 23:15:18 +00:00
whitequark 49758a3a0c hdl.ast: prohibit shifts by signed value.
These are not desirable in a HDL, and currently elaborate to broken
RTLIL (after YosysHQ/yosys#1551); prohibit them completely, like
we already do for division and modulo.

Fixes #302.
2020-02-01 23:04:25 +00:00
whitequark cce6b8687b build.plat: align pipeline with Fragment.prepare().
Since commit 7257c20a, platform code calls create_missing_domains()
before _propagate_domains_up() (as a part of prepare() call). Since
commit a7be3b48, without a platform, create_missing_domains() is
calle after _propagate_domains_up(); because of that, it adds
the missing domain to the fragment. When platform code then calls
prepare() again, this causes an assertion failure.

The true intent behind the platform code being written this way is
that it *overrides* a part of prepare()'s mechanism. Because it was
not changed when prepare() was modified in 7257c20a, the override,
which happened to work by coincidence, stopped working. This is
now fixed by inlining the relevant parts of Fragment.prepare() into
Platform.prepare().

This is not a great solution, but given the amount of breakage this
causes (no platform-using code works), it is acceptable for now.

Fixes #307.
2020-02-01 03:26:04 +00:00
whitequark 6fd7cbad0d 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.
2020-02-01 02:15:45 +00:00
whitequark afece15001 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.
2020-02-01 02:03:23 +00:00
whitequark 9fb4a4f09e _unused: extract must-use logic from hdl.ir. 2020-02-01 01:35:05 +00:00
whitequark 687d3a3df7 hdl.dsl: add missing case width check for Enum values.
Fixes #305.
2020-01-31 23:14:16 +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 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 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