litex: soc builder and library - workshop on open …enjoy-digital founded in 2011. fpga consulting...

42
LiteX: SoC builder and library OSDA Workshop (2019), Florence, March 29 Florent Kermarrec, fl[email protected] 1

Upload: others

Post on 04-Jun-2020

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: LiteX: SoC builder and library - Workshop on Open …Enjoy-Digital Founded in 2011. FPGA consulting / Full FPGA based systems design. Reuse and create open-source tools/cores to be

LiteX: SoC builder and libraryOSDA Workshop (2019), Florence, March 29

Florent Kermarrec, [email protected]

1

Page 2: LiteX: SoC builder and library - Workshop on Open …Enjoy-Digital Founded in 2011. FPGA consulting / Full FPGA based systems design. Reuse and create open-source tools/cores to be

Enjoy-DigitalFounded in 2011.

FPGA consulting / Full FPGA based systems design.Reuse and create open-source tools/cores to be more efficient.

LiteX: SoC builder and libraryOSDA Workshop (2019), Florence, March 29 2

Page 3: LiteX: SoC builder and library - Workshop on Open …Enjoy-Digital Founded in 2011. FPGA consulting / Full FPGA based systems design. Reuse and create open-source tools/cores to be

Presentation:1) Let’s design an FPGA SoC the traditional way...2) LiteX : Build your hardware, easily!3) Systems using Migen/LiteX and Future!

3LiteX: SoC builder and libraryOSDA Workshop (2019), Florence, March 29

Page 4: LiteX: SoC builder and library - Workshop on Open …Enjoy-Digital Founded in 2011. FPGA consulting / Full FPGA based systems design. Reuse and create open-source tools/cores to be

Let’s design an FPGA SoC the traditional way...

4LiteX: SoC builder and libraryOSDA Workshop (2019), Florence, March 29

Page 5: LiteX: SoC builder and library - Workshop on Open …Enjoy-Digital Founded in 2011. FPGA consulting / Full FPGA based systems design. Reuse and create open-source tools/cores to be

5LiteX: SoC builder and libraryOSDA Workshop (2019), Florence, March 29

- Choose a CPU.- Add cores around it.- Connect all that.- Write low-level software.

[...]

Create a simple SoC:

Page 6: LiteX: SoC builder and library - Workshop on Open …Enjoy-Digital Founded in 2011. FPGA consulting / Full FPGA based systems design. Reuse and create open-source tools/cores to be

6LiteX: SoC builder and libraryOSDA Workshop (2019), Florence, March 29

[One day later...]

Great we got it working by only using open-source cores!

~ 500 LOC for the wrapper.

Create a simple SoC:

Page 7: LiteX: SoC builder and library - Workshop on Open …Enjoy-Digital Founded in 2011. FPGA consulting / Full FPGA based systems design. Reuse and create open-source tools/cores to be

7LiteX: SoC builder and libraryOSDA Workshop (2019), Florence, March 29

Let’s add our own core:

Let’s create the new core, simulate it with an open-source simulator.

Everything is working fine, let’s integrate it!

Page 8: LiteX: SoC builder and library - Workshop on Open …Enjoy-Digital Founded in 2011. FPGA consulting / Full FPGA based systems design. Reuse and create open-source tools/cores to be

8LiteX: SoC builder and libraryOSDA Workshop (2019), Florence, March 29

Let’s add our own core:

It’s… almost working, but not behaving as expected, is it a bug in the core or something we miss-understood in the datasheet of the chip we are interfacing with??

We need to see what is going on…*(*signal is not observable with an external logic analyzer)

Page 9: LiteX: SoC builder and library - Workshop on Open …Enjoy-Digital Founded in 2011. FPGA consulting / Full FPGA based systems design. Reuse and create open-source tools/cores to be

9LiteX: SoC builder and libraryOSDA Workshop (2019), Florence, March 29

Let’s add our own core:No standard way to debug FPGA designs:

1) Create our own debug tools: ~a few days, limited functionalities/capabilities.

2) Use vendor’s free embedded logic analyzer...

Page 10: LiteX: SoC builder and library - Workshop on Open …Enjoy-Digital Founded in 2011. FPGA consulting / Full FPGA based systems design. Reuse and create open-source tools/cores to be

10LiteX: SoC builder and libraryOSDA Workshop (2019), Florence, March 29

Let’s add our own core:No standard way to debug FPGA designs:

1) Create our own debug tools: ~a few days, limited functionalities/capabilities.

2) Use vendor’s free embedded logic analyzer…** Just this time...

Page 11: LiteX: SoC builder and library - Workshop on Open …Enjoy-Digital Founded in 2011. FPGA consulting / Full FPGA based systems design. Reuse and create open-source tools/cores to be

11LiteX: SoC builder and libraryOSDA Workshop (2019), Florence, March 29

Let’s add our own core:

OK, issue is understood (was a bad interpretation of the spec), core is adapted and now working fine…

Page 12: LiteX: SoC builder and library - Workshop on Open …Enjoy-Digital Founded in 2011. FPGA consulting / Full FPGA based systems design. Reuse and create open-source tools/cores to be

12LiteX: SoC builder and libraryOSDA Workshop (2019), Florence, March 29

Let’s add some RAM:

* Just this time… (again)

We need RAM to run an OS, our board has DDR3.

Let’s look at open-source solutions… Nothing seems to exist except something called LiteDRAM written in ...Python, how can it be serious? :)

Let’s generate a controller with vendor’s tools…*

Page 13: LiteX: SoC builder and library - Workshop on Open …Enjoy-Digital Founded in 2011. FPGA consulting / Full FPGA based systems design. Reuse and create open-source tools/cores to be

13LiteX: SoC builder and libraryOSDA Workshop (2019), Florence, March 29

We could continue with several similar examples…:- How to support different vendors and reuse the same

methodology/cores?- How to build high performance systems at a

reasonable cost.- How to create complex SoCs and limit LOC- ....

Page 14: LiteX: SoC builder and library - Workshop on Open …Enjoy-Digital Founded in 2011. FPGA consulting / Full FPGA based systems design. Reuse and create open-source tools/cores to be

14LiteX: SoC builder and libraryOSDA Workshop (2019), Florence, March 29

In addition to open-source FPGA toolchains, there is a need to high level tools and high performance cores...

Page 15: LiteX: SoC builder and library - Workshop on Open …Enjoy-Digital Founded in 2011. FPGA consulting / Full FPGA based systems design. Reuse and create open-source tools/cores to be

15LiteX: SoC builder and libraryOSDA Workshop (2019), Florence, March 29

LiteX: Build your hardware easily!

Page 16: LiteX: SoC builder and library - Workshop on Open …Enjoy-Digital Founded in 2011. FPGA consulting / Full FPGA based systems design. Reuse and create open-source tools/cores to be

16LiteX: SoC builder and libraryOSDA Workshop (2019), Florence, March 29

Migen : A python HDL toolbox.

Page 17: LiteX: SoC builder and library - Workshop on Open …Enjoy-Digital Founded in 2011. FPGA consulting / Full FPGA based systems design. Reuse and create open-source tools/cores to be

Migen : A python HDL toolbox.

What is Migen?

An alternative HDL based on Python

17LiteX: SoC builder and libraryOSDA Workshop (2019), Florence, March 29

Page 18: LiteX: SoC builder and library - Workshop on Open …Enjoy-Digital Founded in 2011. FPGA consulting / Full FPGA based systems design. Reuse and create open-source tools/cores to be

Migen : A python HDL toolbox.

FHDL is a Python DSL (Domain Specific Language) defined by Migen and allow generating Verilog or instanciating Verilog/VHDL from Python code.

Principle: Use Python to create a list of combinatorial and synchronous assignments.

self.comb += [“...”]self.sync += [“...”]

And generate a verilog file from these assignments.

Led blinker

18LiteX: SoC builder and libraryOSDA Workshop (2019), Florence, March 29

Page 19: LiteX: SoC builder and library - Workshop on Open …Enjoy-Digital Founded in 2011. FPGA consulting / Full FPGA based systems design. Reuse and create open-source tools/cores to be

Migen : A python HDL toolbox.

Migen.FHDL DSL:

Led blinker

Python used for elaboration by

manipulating these objects to create the logic.

19LiteX: SoC builder and libraryOSDA Workshop (2019), Florence, March 29

Switch from hardware paradigm to software paradigm!

Page 20: LiteX: SoC builder and library - Workshop on Open …Enjoy-Digital Founded in 2011. FPGA consulting / Full FPGA based systems design. Reuse and create open-source tools/cores to be

Migen : A python HDL toolbox.

Migen.Genlib, a library with most of the base elements required to digital logic:- Record. (Group signals together with direction)- FSM. (Finite State Machine).- Clock Domain Crossing.- Memory.- Instance. (reuse Verilog/VHDL)- FIFO. (Synchronous, Asynchronous)- ...

20LiteX: SoC builder and libraryOSDA Workshop (2019), Florence, March 29

Page 21: LiteX: SoC builder and library - Workshop on Open …Enjoy-Digital Founded in 2011. FPGA consulting / Full FPGA based systems design. Reuse and create open-source tools/cores to be

Migen : A python HDL toolbox.

Migen.Sim, a simulator in native Python:

21LiteX: SoC builder and libraryOSDA Workshop (2019), Florence, March 29

Page 22: LiteX: SoC builder and library - Workshop on Open …Enjoy-Digital Founded in 2011. FPGA consulting / Full FPGA based systems design. Reuse and create open-source tools/cores to be

Migen : A python HDL toolbox.

Migen != HLS (High Level Synthesis)

but...

Could be seen as the lowest layer of an

HLS.

Could be reused in the future to create an

HLS but still full control on the

generated logic.

22LiteX: SoC builder and libraryOSDA Workshop (2019), Florence, March 29

Page 23: LiteX: SoC builder and library - Workshop on Open …Enjoy-Digital Founded in 2011. FPGA consulting / Full FPGA based systems design. Reuse and create open-source tools/cores to be

LiteX : Build your hardware, easily!Provide the infrastructure to create complex SoCs with Python/Migen:

23LiteX: SoC builder and libraryOSDA Workshop (2019), Florence, March 29

Page 24: LiteX: SoC builder and library - Workshop on Open …Enjoy-Digital Founded in 2011. FPGA consulting / Full FPGA based systems design. Reuse and create open-source tools/cores to be

LiteX : Build your hardware, easily!Originated from a collaboration on MiSoC with :

MiSoC still used successfully by M-Labs for physics equipment in

LiteX since 2015 focuses on embedded-systems and provides a wider collection of tools/cores.

24LiteX: SoC builder and libraryOSDA Workshop (2019), Florence, March 29

Page 25: LiteX: SoC builder and library - Workshop on Open …Enjoy-Digital Founded in 2011. FPGA consulting / Full FPGA based systems design. Reuse and create open-source tools/cores to be

LiteX : Build your hardware, easily!

25

LiteX’s key features to simplify development / integration / debug:

LiteX: SoC builder and libraryOSDA Workshop (2019), Florence, March 29

Page 26: LiteX: SoC builder and library - Workshop on Open …Enjoy-Digital Founded in 2011. FPGA consulting / Full FPGA based systems design. Reuse and create open-source tools/cores to be

LiteX : Build your hardware, easily!

Simple SoC target

Execution on hardware or with litex_sim 26

Reduce the amount of code to create a SoC.

LiteX: SoC builder and libraryOSDA Workshop (2019), Florence, March 29

Page 27: LiteX: SoC builder and library - Workshop on Open …Enjoy-Digital Founded in 2011. FPGA consulting / Full FPGA based systems design. Reuse and create open-source tools/cores to be

LiteX : Build your hardware, easily!

iCE40

ECP5

Spartan6

7-Series

Cyclone V Ultrascale

Stratix 10

Scale pretty well…

1 Kluts / ~few $

2 Mluts / 40k $

Used on very various FPGAs

27

With open-source toolchain: Yosys/Trellis/Icestorm/Nextpnr(Even DDR3 / 1Gbps Ethernet!)

With vendor toolchains… for now :)Scaling and portability

LiteX: SoC builder and libraryOSDA Workshop (2019), Florence, March 29

Page 28: LiteX: SoC builder and library - Workshop on Open …Enjoy-Digital Founded in 2011. FPGA consulting / Full FPGA based systems design. Reuse and create open-source tools/cores to be

LiteX : Build your hardware, easily!CPUs integration/support:

- LM32- OpenRisc (Mor1kx)- RISC-V (PicoRV32, Vexriscv, Minerva)- ARM (*through AXI on ZYNQ)- X86 (*through PCIe)

Switch CPU and in command line:./arty.py --cpu_type=vexriscv --cpu_variant=lite

28LiteX: SoC builder and libraryOSDA Workshop (2019), Florence, March 29

Page 29: LiteX: SoC builder and library - Workshop on Open …Enjoy-Digital Founded in 2011. FPGA consulting / Full FPGA based systems design. Reuse and create open-source tools/cores to be

LiteX : Build your hardware, easily!

Ecosystem of highly configurable and high performance cores:SDR/DDR/DDR2/DDR3/DDR4(Up to > 80 Gbps with DDR4 - 64 bit)

SATA I/II/III: 1.5/3.0/6.0Gbps(400MB/s writes / 500MB/s reads)

Ethernet MAC/IP/UDP up to 1Gbps SDCard up to 55MB/s

PCIe / DMA / Scatter-Gather(Up to Gen2 X4) Embedded Logic Analyzer

[...] and more at http://github.com/enjoy-digital 29LiteX: SoC builder and libraryOSDA Workshop (2019), Florence, March 29

Cores are designed to be used on various FPGAs, adding support for a new devices = just adding a new PHY.

Page 30: LiteX: SoC builder and library - Workshop on Open …Enjoy-Digital Founded in 2011. FPGA consulting / Full FPGA based systems design. Reuse and create open-source tools/cores to be

LiteX : Build your hardware, easily!

Constraint propagation / reduced duplication:

30

User defined constraints (specific to application) Board specific constraints (automatically derived from DRAM config)LiteX: SoC builder and libraryOSDA Workshop (2019), Florence, March 29

Page 31: LiteX: SoC builder and library - Workshop on Open …Enjoy-Digital Founded in 2011. FPGA consulting / Full FPGA based systems design. Reuse and create open-source tools/cores to be

LiteX : Build your hardware, easily!

Interactive simulation (emulation) with litex_sim/Verilator:

31

litex_sim --cpu-type=vexriscv litex_sim --cpu-type=or1k

<5s build time / ~1MHz execution speed, very useful for software dev.Easy to add additional C++ plugins (JTAG, VGA, Ethernet, etc…)

litex_sim --cpu-type=lm32

c

LiteX: SoC builder and libraryOSDA Workshop (2019), Florence, March 29

Page 32: LiteX: SoC builder and library - Workshop on Open …Enjoy-Digital Founded in 2011. FPGA consulting / Full FPGA based systems design. Reuse and create open-source tools/cores to be

LiteX : Build your hardware, easily!

Zephyr

Various OS support:

Micropython

32

Linux

From bare-metal to Linux OS, collaboration with others open-source enthusiasts.

LiteX: SoC builder and libraryOSDA Workshop (2019), Florence, March 29

Page 33: LiteX: SoC builder and library - Workshop on Open …Enjoy-Digital Founded in 2011. FPGA consulting / Full FPGA based systems design. Reuse and create open-source tools/cores to be

LiteX : Build your hardware, easily!Automatic CSR registers collection / software header generation:

C header or CSV file that can be use by scripts/software33

LiteX: SoC builder and libraryOSDA Workshop (2019), Florence, March 29

Page 34: LiteX: SoC builder and library - Workshop on Open …Enjoy-Digital Founded in 2011. FPGA consulting / Full FPGA based systems design. Reuse and create open-source tools/cores to be

LiteX : Build your hardware, easily!Debug infrastructure with LiteX Server / LiteScope and the bridges:

Python scripts to control/debug the hardware.

34

Speed up development, use the same tools for all devices!

LiteX: SoC builder and libraryOSDA Workshop (2019), Florence, March 29

Page 35: LiteX: SoC builder and library - Workshop on Open …Enjoy-Digital Founded in 2011. FPGA consulting / Full FPGA based systems design. Reuse and create open-source tools/cores to be

35

Systems using Migen/LiteX and Future!

LiteX: SoC builder and libraryOSDA Workshop (2019), Florence, March 29

Page 36: LiteX: SoC builder and library - Workshop on Open …Enjoy-Digital Founded in 2011. FPGA consulting / Full FPGA based systems design. Reuse and create open-source tools/cores to be

Used for our commercial projects:- Custom FPGA systems/designs for clients.- Customizations of cores for clients to replace commercial/vendor’s

cores: LiteSATA on a 100Mpix camera, LiteDRAM on Ultrascale/DDR4 boards, etc...

36

Systems using Migen/LiteX and Future!

LiteX: SoC builder and libraryOSDA Workshop (2019), Florence, March 29

Page 37: LiteX: SoC builder and library - Workshop on Open …Enjoy-Digital Founded in 2011. FPGA consulting / Full FPGA based systems design. Reuse and create open-source tools/cores to be

- Custom ASIC characterization equipment

- ...37

Systems using Migen/LiteX and Future!

LiteX: SoC builder and libraryOSDA Workshop (2019), Florence, March 29

Page 38: LiteX: SoC builder and library - Workshop on Open …Enjoy-Digital Founded in 2011. FPGA consulting / Full FPGA based systems design. Reuse and create open-source tools/cores to be

38

NeTV2Opsis Fomu

Systems using Migen/LiteX and Future!

But also by others to create FPGA based systems:

LiteX: SoC builder and libraryOSDA Workshop (2019), Florence, March 29

Page 39: LiteX: SoC builder and library - Workshop on Open …Enjoy-Digital Founded in 2011. FPGA consulting / Full FPGA based systems design. Reuse and create open-source tools/cores to be

But also by others to create FPGA based systems:

Ethernet

PCIe (X4)

DRAM

SDCard

HDMI In /Out

SPI Flash

NeTV239

Systems using Migen/LiteX and Future!

LiteX: SoC builder and libraryOSDA Workshop (2019), Florence, March 29

Page 40: LiteX: SoC builder and library - Workshop on Open …Enjoy-Digital Founded in 2011. FPGA consulting / Full FPGA based systems design. Reuse and create open-source tools/cores to be

40

Systems using Migen/LiteX and Future!

Future: continue collaboration with others open-source enthusiasts to:- Improve tools/cores/documentation/verification.- Ease cores generation and reuse as standalone cores. (FuseSoC?).- Add nMigen support (or switch to it) (almost 100% compatible, better

doc/tests, adds formal verification).- Improve current OS support/drivers and add drivers for others cores lite

LiteSATA, LiteSDCard, LiteScope, LiteICLink, etc…- Add others cores :)- ...

LiteX: SoC builder and libraryOSDA Workshop (2019), Florence, March 29

Page 41: LiteX: SoC builder and library - Workshop on Open …Enjoy-Digital Founded in 2011. FPGA consulting / Full FPGA based systems design. Reuse and create open-source tools/cores to be

You are a student and would like to work on this? (or know one)Applications are now open and TimVideos/Symbiflow organizations can acceptLiteX related projects.

41LiteX: SoC builder and libraryOSDA Workshop (2019), Florence, March 29

Page 42: LiteX: SoC builder and library - Workshop on Open …Enjoy-Digital Founded in 2011. FPGA consulting / Full FPGA based systems design. Reuse and create open-source tools/cores to be

Want to try it or to help :) ? : http://github.com/enjoy-digital/litex (BSD License)

Get in touch on IRC (Freenode): Migen: #m-labsLiteX: #litex

Questions ?42

Migen/LiteX is not magic… but very powerful and could help you to be more efficient/productive.Can be used to create full designs in Python or just as a tool for integration, core generation, simulation…

LiteX: SoC builder and libraryOSDA Workshop (2019), Florence, March 29