Commit graph

99 commits

Author SHA1 Message Date
Robin Ole Heinemann 25caf4045b *: remove unused imports 2021-05-18 20:18:55 +00:00
dx-mon f7c2b9419f compat.genlib.roundrobin: fix missing imports 2021-02-04 11:02:27 +00:00
whitequark b65e11f38f sim: split into base, core, and engines.
Before this commit, each simulation engine (which is only pysim at
the moment, but also cxxsim soon) was a subclass of SimulatorCore,
and every simulation engine module would essentially duplicate
the complete structure of a simulator, with code partially shared.

This was a really bad idea: it was inconvenient to use, with
downstream code having to branch between e.g. PySettle and CxxSettle;
it had no well-defined external interface; it had multiple virtually
identical entry points; and it had no separation between simulation
algorithms and glue code.

This commit completely rearranges simulation code.
  1. sim._base defines internal simulation interfaces. The clarity of
     these internal interfaces is important because simulation
     engines mix and match components to provide a consistent API
     regardless of the chosen engine.
  2. sim.core defines the external simulation interface: the commands
     and the simulator facade. The facade provides a single entry
     point and, when possible, validates or lowers user input.
     It also imports built-in simulation engines by their symbolic
     name, avoiding eager imports of pyvcd or ctypes.
  3. sim.xxxsim (currently, only sim.pysim) defines the simulator
     implementation: time and state management, process scheduling,
     and waveform dumping.

The new simulator structure has none of the downsides of the old one.

See #324.
2020-08-27 11:52:31 +00:00
Jean THOMAS 20f9ab9d7a
nmigen.lib.scheduler: add RoundRobin. 2020-07-28 21:02:01 +00:00
whitequark 0899ff366b compat.fhdl.bitcontainer: fix value_bits_sign().
This function was broken in commit 659b0e81; some downstream code
expects bits_sign to be e.g. indexable.
2020-07-21 02:53:29 +00:00
whitequark 8dd28fecc6 compat.fhdl.specials: fix handling of tristate (i=None) pins.
Fixes #406.
2020-07-02 22:22:44 +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
awygle 5ae87916ec
nmigen.compat.genlib.cdc: add PulseSynchronizer. 2020-02-16 07:01:44 +00:00
whitequark 9fb4a4f09e _unused: extract must-use logic from hdl.ir. 2020-02-01 01:35:05 +00:00
whitequark e18385b613 Remove everything deprecated in nmigen 0.1.
Closes #275.
2020-01-12 13:59:26 +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 9fba5ccb51 compat.fhdl.specials: fix argument parsing compatibility. 2019-10-17 07:54:36 +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 13650acbbc compat.fhdl.decorators: improve backwards compatibility. 2019-10-13 01:38:09 +00:00
whitequark d2c4c7c060 compat.fhdl.bitcontainer: update Value.wrap call. 2019-10-13 01:37:11 +00:00
whitequark 1387e2f9df compat.genlib.fsm: add migration warning. 2019-10-12 22:48:08 +00:00
whitequark dbddddff17 compat.fhdl.decorators: add migration warnings. 2019-10-12 22:45:03 +00:00
whitequark a7e3b80409 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.
2019-10-12 22:40:48 +00:00
whitequark 77118fb9c9 compat.fhdl.structure: remove SPECIAL_* constants.
They cannot be used with nMigen designs since nMigen does not have
specials.
2019-10-12 22:40:48 +00:00
whitequark da48c05bdf _tools: extract most utility methods to a private package.
We don't want to guarantee backwards compatibility for most of them.
2019-10-12 22:40:48 +00:00
whitequark d72d4a55fd hdl.ast: Value.{wrap→cast}
Preparation for #225.
2019-10-11 10:49:34 +00:00
whitequark 8deb13cea3 lib.cdc: MultiReg→FFSynchronizer.
Fixes #229.
2019-09-23 14:18:45 +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 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 2d2ab6e09d lib.cdc: make domain properties private.
It is not correct to access domain properties from user code, because
it will not match the reality if DomainRenamer has been applied to
the module.
2019-09-12 13:54:48 +00:00
whitequark 9893e3c044 lib.cdc: adjust ResetSynchronizer for new CDC primitive conventions.
Refs #97.
2019-09-12 13:48:45 +00:00
whitequark 8f659b6cd6 lib.cdc: adjust MultiReg for new CDC primitive conventions.
Refs #97.
2019-09-12 13:48:24 +00:00
whitequark a2241fcfdb back.{rtlil,verilog}: split convert_fragment() off convert().
Because Fragment.prepare is not (currently) idempotent, it is useful
to be able to avoid calling it when converting. Even if it is made
idempotent, it can be slow on large designs, so it is advantageous
regardless of that.
2019-08-19 19:49:51 +00:00
whitequark 84f2c3df2b compat.fhdl.decorators: avoid using deprecated NativeCEInserter. 2019-08-18 16:27:11 +00:00
whitequark e6b1e3de1a compat.fhdl.decorators: port from oMigen. 2019-08-08 08:09:28 +00:00
whitequark 5c626e33bf compat.fhdl.module: fix finalization of transformed compat submodules.
Before this commit, the TransformedElaboratable of a CompatModule
would be ignored, and .get_fragment() would be used to retrieve
the CompatModule within.

After this commit, the finalization process is reworked to match
oMigen's finalization closely, and all submodules, native and compat,
are added in the same way that preserves applied transforms.
2019-08-08 07:45:34 +00:00
whitequark 0fe05188e8 compat.fhdl.specials: track changes in build.plat. 2019-08-03 22:52:34 +00:00
whitequark fdb0c5a6bc hdl.ir: call back from Fragment.prepare if a clock domain is missing.
See #57.
2019-08-03 14:54:20 +00:00
whitequark 447bfa6ad5 compat.genlib.fsm: fix after commit dac62754. 2019-07-08 10:12:26 +00:00
whitequark 668ff40a75 compat.fhdl.specials: mark CompatMemory as Elaboratable.
This suppresses a warning that is not useful in the compat context.
2019-07-03 13:28:57 +00:00
whitequark eeb6aca93d compat.fhdl.specials: use "sync" as default domain, not "sys".
In compat.fhdl.module, we already default to "sync" as the default
clocked domain. Using "sys" in memories only would be inconsistent
and result in more bugs.
2019-07-03 13:25:12 +00:00
whitequark c98b8f7c07 compat.fhdl.specials: fix Memory.get_port() after 94e8f479.
This also makes sure the native ports are instantiated for correct
clock domain.
2019-07-03 13:24:00 +00:00
whitequark 9eb81609d6 compat.fhdl.structure: fix If/Elif/Else after 32446831. 2019-07-03 13:19:15 +00:00
whitequark 32446831b4 hdl.{ast,dsl}, back.{pysim,rtlil}: allow multiple case values.
This means that instead of:

    with m.Case(0b00):
        <body>
    with m.Case(0b01):
        <body>

it is legal to write:

    with m.Case(0b00, 0b01):
        <body>

with no change in semantics, and slightly nicer RTLIL or Verilog
output.

Fixes #103.
2019-06-28 04:37:08 +00:00
whitequark 2f7e52369c compat.fhdl.structure: fix typo. 2019-06-25 22:01:14 +00:00
whitequark b1af0601fa compat.fhdl.structure: simplify handling of default case. 2019-06-25 22:01:14 +00:00
whitequark 2566747061 compat.fhdl.structure: fix Case().makedefault().
Fixes #100.
2019-06-13 03:56:57 +00:00
whitequark f689b777b4 compat.fhdl.structure: always order default case as the very last. 2019-06-13 03:56:57 +00:00
whitequark 537d91851d compat.fhdl.module: silence "unused elaboratable" warnings. 2019-06-04 13:09:36 +00:00
whitequark 38917e4523 compat.fhdl.specials: fix platform lowering for TSTriple again. 2019-06-04 13:03:56 +00:00
whitequark 79a3710255 compat.fhdl.specials: fix platform lowering.
get_tristate only has O/OE; the triple is created by get_input_output.
2019-06-04 12:26:09 +00:00
whitequark 0cbb743df9 compat.fhdl.module: implement some TODO'd deprecation warnings. 2019-06-04 12:00:02 +00:00
whitequark 39ca0e6fa6 compat.fhdl.module: CompatModule should be elaboratable.
Fixes #83.
2019-06-04 11:11:31 +00:00
whitequark 4c443a7ef5 compat.fhdl.specials: TSTriple is not an elaboratable. 2019-06-03 09:39:38 +00:00
Chris Osterwood 699fe5a675 Add import so that Tristate.elaborate builds 2019-05-20 16:34:31 +00:00