How-To: LM32 Soft-CPU

Introduction

Soft-CPUs are a VDHL implementation of a CPU in a FPGA. With FAIR Timing Receivers, Soft-CPUs are directly embedded in the Wishbone SoC architecture inside the FPGA. This opens up the possibility to run OS-less cross-compiled software in hard real-time and have direct access to other Wishbone devices in the same FPGA. Software can't get harder in real-time and closer to the real hardware. On the downside, the developer must have in-depth knowledge of SoC architecture and resources in the FPGA are extremely limited. Using Soft-CPUs in Timing Receiver is reserved for singular border cases and must be agreed on with relevant stakeholders.

Each FPGA of a timing receiver hosts at least two Soft-CPUs. One devoted to White Rabbit and another one for specific applications. The FAIR Data Master even hosts a cluster of about 8 Soft-CPUs. For an overview on Soft-CPUs in Timing Receivers see proceeding article and talk.

This How-To aims at demonstrating first steps using example code: First clone the git repository as described here. Second, checkout the relevant branch. Third, cd to .../bel_projects/modules/lm32-example .

Setting up the Cross Compiler

A dedicated tool chain with cross compiler is available within the project.
  1. clone the git repository, see here.
  2. cd to the top folder of that repo: cd MYPATH/bel_projects
  3. download, built and install toolchain: lxpx123:/MYPATH/bel_projects> make toolchain
  4. include the absolute folder of toolchain binaries in your PATH MYPATH/bel_projects/toolchain/bin

Check: 'which lm32-elf-gcc' should show the correct path. Otherwise make will not work.

Hello World

Checkout the miniature example contained in .../bel_projects/modules/lm32-example/miniExample.c .

Inspect Code
lxpc1234:/opt/GITSCC/bel_projects/modules/lm32-example> emacs miniExample.c //use your favourite editor

Build the Firmware
lxpc1234:/opt/GITSCC/bel_projects/modules/lm32-example> make

Upload Firmware to a Soft-CPU

lxpc1234:/opt/GITSCC/bel_projects/modules/lm32-example> eb-fwload dev/wbm0 u 0x0 miniExample.bin

Remark: There is a dedicated how-to on eb-fwload.

Visualization and Debugging

Inspect printf() Statements of Firmware by using eb-console in a dedicated terminal session.
lxpc1234:/opt/GITSCC/bel_projects/modules/lm32-example> eb-console dev/wbm0
Connected to uart at address 4060500
wrc# 
Hello World!
boring...
boring...
boring...
...

Remark: For more details on eb-console have a look at the WR PTP Core User Manual. Once upon a time, there was a possibility to debug firmware in-situ using gdb. Sorry, I don't know how and if this still works.

Other Examples

Checkout the miniature example contained in .../bel_projects/modules/lm32-example/example.c .

How-To: Accessing another SoC Wishbone Device

How-To: Accessing a LM32 Soft-CPU via shared memory and Wishbone

How-To: Accessing a device on the MIL device bus from a LM32 Soft-Core

How-To: Linking a LM32 Soft-CPU to the ECA

How-To: Send a command to a LM32 Soft-CPU

How-To: Handle the ECA MSIs in a LM32 Soft-CPU

-- DietrichBeck - 08 Mar 2017
Topic revision: r13 - 23 Jan 2020, MartinSkorsky
This site is powered by FoswikiCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding Foswiki? Send feedback