• Stars
    star
    157
  • Rank 231,110 (Top 5 %)
  • Language CMake
  • License
    GNU General Publi...
  • Created over 1 year ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Simulating Verilog designs on a microcontroller

FakePGA

Simulating Verilog designs on a microcontroller

What does it do?

This project aims to simulate Verilog HDL designs on a Raspberry Pi Pico (or any other RP2040-based board). It achieves this by using Verilator to compile the RTL into a cycle-accurate C++ model of your design which can then be executed on the microcontroller. This allows you to access the signals of the simulated design through the GPIO pins of the board, which gives a more hands-on experience than simulating on a computer. It is many orders of magnitude slower than a real FPGA (max clock speed is 5kHz, and it goes down as the complexity of your design increases), but it can still be used as an educational tool. In terms of user experience, it feels like using a slower FPGA (at least for simpler designs), hence the name of the project: FakePGA.

What do I need in order to use it?

Hardware-wise, you're going to need an RP2040-based dev board. The included Verilog example makes use of the on-board LED and two pushbuttons. This example blinks the LED, stopping and starting the blinking when the buttons are pressed.

Software-wise, you're going to need a Linux system to compile on. This could work on Windows, but I only tested it with Ubuntu (running in WSL). You need to have the pico-sdk installed and working, as well as Verilator.

After cloning this repository, you'll need to set the path of the Verilator library sources in the CMakeLists.txt file, on the 12th line. Out of the box, it is set to the default path for the Ubuntu install of Verilator.

How do I use it?

The Verilog design files reside in the verilog folder. The top module resides in the top.v file and it must be named top. It must have an input port named i_clk, which coresponds to the clock source for the design, no matter if it's used or not.

The simulation is configured in the config.txt file. Just like when using an actual FPGA, you'll need to map the ports of your design to real pins on the device. You can also set the clock freqency here. The config file used for the included example is presented below:

// Clock frequency in Hz
CLOCK_FREQ 5000;

// Input mapping
INPUTS
{
    ADD_IN{TOP i_s, 14, PULLUP}; // Maps port i_s to GPIO14 and pulls it up
    ADD_IN{TOP i_r, 15, PULLUP}; // Maps port i_r to GPIO15 and pulls it up
}

// Output mapping
OUTPUTS
{
    ADD_OUT{TOP o_led, PICO_DEFAULT_LED_PIN}; // Maps port o_led to the default LED pin
}

Before building the project for the first time, or after deleting the build folder, you must run the preBuild.sh script, in order to create some dummy files that the build system expects to exist. Afterwards, you can simply build it with CMake:

cd build
cmake ..
make

More Repositories

1

pico-rv32ima

Running Linux on RP2040 with the help of RISC-V emulation
C
203
star
2

linux-ch32v003

Linux on a $0.15 RISC-V microcontroller
C
186
star
3

pillScopePlus

Oscilloscope based around the STM32F401 Black Pill and a color LCD screen
C
104
star
4

Pico-10BASE-T-Library

Library which allows the Pi Pico to send UDP packets over 10BASE-T Ethernet
C
48
star
5

pillScope

Oscilloscope based around the STM32F103 Blue Pill and an OLED screen
C
12
star
6

Pico-10BASE-Thermometer

Thermometer which outputs data over 10BASE-T Ethernet
CMake
11
star
7

pico-displayDrivs

Display drivers for pico-sdk
C
10
star
8

pico-window

Multitasking text-based windowing system for Raspberry Pi Pico, using a PS/2 keyboard, VGA monitor and FreeRTOS
C
6
star
9

tekscopeIngest

Companion app for the pillScope Plus
C#
4
star
10

pico-vgaDisplay

VGA display driver library for RP2040 pico-sdk
C
4
star
11

pico-lvglBMP085

Thermometer demo using LVGL and FreeRTOS running on Pi Pico
C
4
star
12

pico-crude64

Very basic C64 emulator for the Pi Pico
C
3
star
13

pico-displayExamples

ST7735 example for Pi Pico, using pico-sdk
CMake
3
star
14

rv32adventure

Becoming acquainted with the RISC-V ISA by writing an emulator
C
3
star
15

pico-bmp085Driv

BMP085 library for pico-sdk
C
2
star
16

i2cThingTemplate

Small STM32G0 board, with OLED display and I2C
C
2
star
17

pico-ps2Driv

PS2 keyboard library for pico-sdk
C
2
star
18

Pico-VBAN-Transmitter

Network audio (VBAN protocol) transmitter using Raspberry Pi Pico
C
1
star
19

SSD1306-Cube

I2C SSD1306 Library for STM32Cube
C
1
star
20

ADXL345-Cube

ADXL345 Library for STM32Cube
C
1
star
21

pico-window-example

Example project using the pico-window multitasking environment
CMake
1
star