Close
0%
0%

jupyosys

..from Python Jupyter notebook to silicon

Similar projects worth following
MyHDL empowers Python to be used as a 'DSL' (domain specific language) for generating true hardware, such as as JPEG encoders, a RISC-V CPU, ...
The direct transfer to synthesizeable hardware occurs via the pyosys API interface of the well known yosys synthesis toolchain.

To reproduce easily (without installing software): the environment is supplied as a pre-cooked Jupyter Notebook powered virtual machine. If you're not familiar with that: It allows you to run Python code (and more) from the browser. So, after all, you can synthesize from the browser to an FPGA -- in a few seconds.

Full bit file synthesis to FPGA using nextpnr is enabled for Lattice ECP5 FPGAs.

Beware: Although some reference designs are verified to work, this is still considered 'experimental' and meant for documentation purposes.

The quick start: Launch the link below to start the virtual machine inside the mybinder.org service

[jupyosys binder]

The virtual machine contains:

  • A jupyter notebook installation (obviously)
  • A recent pyosys module build (including full yosys functionality)
  • An icarus verilog installation to verify and simulate verilog code
  • The MyHDL 'jupyosys' fork supporting synthesis
  • Various utilities to display waveforms and dot graphics

What you basically can play with in this binder:

  • Run code to describe and simulate a hardware element
  • Dump a waveform trace
  • Synthesize into yosys primitives and display
  • Verify the synthesis and technology mapping working correctly by Co-Simulation
  • Generate a bit file and download it to an Versa ECP5 Lattice development kit

There are examples/exercises being added every now and then in the 'dirty' hacker space which is checked out secondarely inside the running container. Some examples also contain german explanations that can be squelched using the [Language] menu dropdown (possibly not working in some browsers other than Firefox).

  • Blackboxes: Multi targets, vendor entities...

    Martin07/23/2020 at 14:52 0 comments

    To provide a monthly update at least, a short summary on the current development lane progress:

    • Blackbox API considered frozen for an upcoming 0.1(after summer break) release
    • Board supply package for ECP5 versa board 'in sync' with a frozen yosys .deb package
    • More real life designs tested:
      • pyrv32 (RISC-V core) elements post-map co-simulation
      • Memory inference scenarios verified

    The `@blackbox` interface had undergone some extensive experimenting. In short, there are several usage scenarios, not all of them completely elaborated:

    • Automated inference of a vendor blackbox primitive (hard PLL, Serdes block, etc.)
    • Integration with an external Verilog/VHDL module: Creating a black box stub
    • Implementing a top level design ('virtual board') in several ways and configurations:
      • Simulation, Co-Simulation with external models
      • ... for different target architectures and boards

    What is also going to not change for a while - so you can safely base on it for own development:

    • Co-Simulation setups
    • Hierarchy interface (although there are issues with the name mangling)
    • extension classes: BulkSignal, GeneratorClass

    Still under scrutiny:

    • Tri-State interface signals: These are not yet 100% nailed down, but chances will be that they are only allowed in top level modules for synthesis.
    • VHDL std_logic compatible signals that know also know 'U', 'X': They might possibly never make it into the official MyHDL tree and will be kept in a separate package.
    • Latch support: Likely to end up as an error when trying to infer one.
    • Memory inference: Likely to end up as Blackbox model library

    Finally, what requires some attention at this point is the underlying (p)yosys API, so it might be time to build a testing pipeline to make sure the supporting pillars don't break away with future revisions.

  • Status updates

    Martin06/27/2020 at 15:37 0 comments

    Close to summer break, where brains stop to function and the incentives tend to be ice cream rather than a successfully blinking but heat producing FPGA board. It's time to summarize what works and what doesn't, plus a small road map:

    Working:

    • Designs that stick to certain design rules (undocumented, but covered by a number of test cases under `test/conversion/toYosys`)
    • Integrating external Verilog/VHDL implementations (VHDL support yet subject to volatilities)
    • A few ECP5 primitives (blackbox wrappers)
    • Simple `$mem` block inference

    Missing:

    • Functional simulation models for most of the ECP5 blackbox primitives
    • Automated DSP element inference (must be explicit)
    • Support for negative and dual edge events inference and several I/O standards
    • Support for sequential programming (@instance style)

    Flaws:

    • Coverage for some corner cases with variable usage (some tests
      for it are marked to fail in the test suite)
    • Support for the fully fledged multi port memory inference (this is is also a yosys issue being worked on)
    • Handling of yosys exceptions: these terminate the python interpreter without error shown in the Notebook environment.

    As of now, a lot of complexity is introduced by legacy MyHDL behaviour and support of existing structures. To support inference of all kinds of constructs, the complexity would be very much increased (which is considered 'dangerous' at this time, as the underlying architecture might still receive a redesign).

    To be able to create working prototypes anyhow, the current strategy tries to follow the 'blackbox' approach:


    Instead of trying to make the synthesizer guess what it should create from a functional description, we pick things from a library that is known to work, then we wrap them such that they look like our functional description (that plays right in simulation). Even better, in MyHDL we can pack them into the same functional block. We just need to verify that the actual hardware implementation behaves exactly the same as the functional simulation. This functional block also provides the support for high level constructs, for example, a class object that supports multiplication and infers to the matching black box multiplier element underneath.

    For example, a PLL on an ECP5 FPGA is defined as @blackbox entity `EHXPLLL`, including a simple (currently imprecise) simulation model for its up to four clock outputs, however, for synthesis, this model is ignored and the explicit (yosys specific) inferral routine is called to reserve the matching primitive for the final wiring. For another implementation method (be that a different synthesizer or different silicon architecture), another implementation is added as python sub-function decorated with the @synthesis(method) decorator.


    This blackbox API is now considered 'set' and will only change marginally with respect to some argument/parameter handling. Now here comes the roadmap:

    • Creating a library of working modules that infer and verify against yosys synthesis output as correct, using Co-Simulation
    • Improve framework to swap easily between external blackbox V*-HDL implementations and MyHDL implementations
    • Get all memory inference scenarios completed (this is important to run a RISC-V design in pure MyHDL)
    • Support I/O standards up to the interface
    • gensoc integration (SoC generator for register maps, bus decoders, etc.)
    • Testing, testing, testing...

    The full goal: Running just everything out of a python shell

    • From browser to FPGA in five seconds

      Martin05/22/2020 at 08:27 0 comments

      Still far away from synthesizing just any design, but when following the design rules, things basically bake into a *.svf file that downloads to the corresponding target board.

      Last commits (inside the 'hacker space') add the mandatory blinky example for the Versa ECP5 development kit from Lattice Semi.


      Those who have been dealing with the Diamond toolchain for a while may remember some pain: The downloads to the target could take up to 30 seconds already.

      The current setup shortens the translate-synthesize-map-place'n'route iteration cycles significantly. So the newly added blinky example should download within five seconds (after installing all the necessary packages, setting permissions and running the container locally). Not that this should encourage trial&error coding, but it might stop you from having too many smoke breaks.

    • Going real

      Martin05/06/2020 at 16:21 0 comments

      Starting out as a documentation project with tiny steps and rather frequent updates, it's now moving towards:

      • Getting real world (existing) designs to spin
      • Augmenting the test benches with plenty of uncovered corner cases
      • Not breaking stuff (unit tests for Jupyter notebooks, too)


      Also, so far all has been 'virtual', i.e. running in the browser only. The next milestone is to get a complex CPU design running (still undecided which one it is going to be, but certainly one of the MaSoCist choices).

      The hard part (which needed a lot of playing and revamping) is to support a rather large number of corner cases that have to do with conditional code:

      if state == t_state.RESET:
          a.next = 0xff
      elif state == t_state.RUN:
          a.next = c
      else:
          a.next = 0xaa

      This snippet is just supposed to assert a signal, decided upon a state condition, let aside the context for now (whether behind a flip flop or combinatorial logic)

      In the silicon, this basically creates multiplexers. And it gets very interesting, when a case is omitted (like the 'else' clause), you might remember issues with combinatorial loops.

      Hopefully with the recent release, I've gotten the corner cases right.


      Here's where the testing comes in:

      • Testing against a working reference
      • Testing that the examples are correct

      And this is where Python performs exceptional: it provides probably the most convenient ecosystem to test stuff. This is now also found in the [ Binder based virtual machine ].

    View all 4 project logs

    Enjoy this project?

    Share

    Discussions

    Similar Projects

    Does this project spark your interest?

    Become a member to follow this project and never miss any updates