fnoeding / fpga-experiments

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

FPGA Experiments

This repository contains my experiment to understand How a CPU works: bare metal C on my RISC-V CPU. My blog post explains it in more detail and also with cleaner code than in this repo.

I've written this code as a learning experiment with limited time. I hope it is useful, but it does not match my usual quality standard.

Usage

git clone $repo
cd $repo

# build the docker image
docker build -t myeda .

# run
docker run --rm -it -v $(PWD):/data myeda

######
# all following commands are run in the docker container
######

cd /data
make clean && make

# 1) run Conway's game of life on host
./bin/life

# 2) run Conway's game of life on emulator
#     resize console to make the output fit the screen, otherwise the output will look broken
#     if the console is broken after running the program, use `reset`
#
# emulator commands:
#     r         run
#     b $hex    sets breakpoint at hex address $hex (use readelf / objdump to figure out where to break)
#     s         steps the program
#     r4 $hex   reads 4 bytes from memory at hex address $hex
./bin/rv32emu --bin bin/life.rv32.bin

# 3) test CPU
python3 -m pytest rtl/cpu.py

About

License:MIT License


Languages

Language:Python 49.5%Language:C++ 41.0%Language:C 7.7%Language:Makefile 1.6%Language:Dockerfile 0.2%