diff --git a/.gitmodules b/.gitmodules index 6cb8d44..46d843a 100644 --- a/.gitmodules +++ b/.gitmodules @@ -17,11 +17,11 @@ path = examples/hazard3/Hazard3 url = https://github.com/Wren6991/Hazard3.git [submodule "examples/picorv32_soc/picorv32"] - path = examples/picorv32_soc/picorv32 + path = examples/toy_SoC/picorv32 url = https://github.com/YosysHQ/picorv32 [submodule "examples/picorv32_soc/urv-core"] - path = examples/picorv32_soc/urv-core + path = examples/toy_SoC/urv-core url = https://ohwr.org/project/urv-core.git [submodule "examples/picorv32_soc/mdu"] - path = examples/picorv32_soc/mdu + path = examples/toy_SoC/mdu url = https://github.com/zeeshanrafique23/mdu.git diff --git a/README.md b/README.md index 97c0c52..79b2747 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ GVI generates glue code that allows to run Verilog modules inside of VHDL testbe - examples/serv: Run an instance of the serv risc-v cpu. - examples/ibex: Run an instance of a more performant risc-v cpu. - examples/hazard3: Run an instance of yet another risc-v cpu. - - examples/picorv32_soc: A slightly more complex example with yet another risc-v CPU. The CPU has a custom wishbone wrapper for data and instruction bus and runs a firmware stored in memory that calculates digits of PI and writes these digits onto a pseudo UART device that ends up in a text file in the simulation directory (`cpu_output.txt`). + - examples/toy_SoC: A slightly more complex example with a simple SoC. Three RISC-V CPUs (uRV, picorv32, serv with MDU) are available. They have a custom wishbone wrapper for data and instruction bus and all CPUs runs the exact same firmware stored in memory that calculates digits of PI and writes these digits onto a pseudo UART device that ends up in a text file in the simulation directory (`cpu_output.txt`). [more details are here](examples/toy_SoC/README.md) - examples/wr-cores: Run an instance of the WhiteRabbit core, [build instructions are here](examples/wr-cores/README.md) - examples/vhdl_verilog_mixed: Demonstrate a fully mixed language design. VHDL implementation, Verilog implementation, and Verilog instantiating VHDL entity running together in the same testbench. This is possible because GHDL can convert VHDL code into Verilog code using its synthesis capabilities (only tested with GHDL version 4). diff --git a/examples/toy_SoC/README.md b/examples/toy_SoC/README.md new file mode 100644 index 0000000..69983cb --- /dev/null +++ b/examples/toy_SoC/README.md @@ -0,0 +1,25 @@ +# Toy SoC with different drop-in compatible CPUs + +This is a small SoC to play around with firmware and different RISC-V CPUs. +The layout of the SoC looks like this. + +![SoC](soc.png) + +Before running the testbench (`make`) git submodules must be enabled (`git submodule init; git submodule update`). +All CPUs are wrapped with a [wishbone](https://cdn.opencores.org/downloads/wbspec_b4.pdf) interface to make the drop-in compatible. + +## CPU selection + + - [uRV](https://ohwr.org/project/urv-core): the most performant available CPU, bus also the largest + - [picorv32](https://github.com/YosysHQ/picorv32): smaller then uRV but also less performant, but has higher f_max + - [serv](https://github.com/olofk/serv) with MDU: even smaller but ~10x slower than picorv32 + + The CPU selection happens in `testbench.vhd` by selecting the type of the `cpu` instance. Just uncomment the one you want. + +## Firmware + + The firmware [based on this code](https://crypto.stanford.edu/pbc/notes/pi/code.html) calculates the first 800 digits of PI and writes the output into a file `cpu_output.txt`. + You can observe the output by calling `tail -f cpu_output.txt` while the simulation is running. + + The compiled `firmware/firmware.bin` is included in the repository so that no additional compiler is needed to run the testbench simulation. + On Arch Linux you can compile the binary from source code after installing the package `riscv64-elf-gcc`. diff --git a/examples/picorv32_soc/dpram_wbp.vhd b/examples/toy_SoC/dpram_wbp.vhd similarity index 100% rename from examples/picorv32_soc/dpram_wbp.vhd rename to examples/toy_SoC/dpram_wbp.vhd diff --git a/examples/picorv32_soc/firmware/bin2bitvector.c b/examples/toy_SoC/firmware/bin2bitvector.c similarity index 100% rename from examples/picorv32_soc/firmware/bin2bitvector.c rename to examples/toy_SoC/firmware/bin2bitvector.c diff --git a/examples/picorv32_soc/firmware/crt0.S b/examples/toy_SoC/firmware/crt0.S similarity index 100% rename from examples/picorv32_soc/firmware/crt0.S rename to examples/toy_SoC/firmware/crt0.S diff --git a/examples/toy_SoC/firmware/firmware.bin b/examples/toy_SoC/firmware/firmware.bin new file mode 100755 index 0000000..6cc2144 Binary files /dev/null and b/examples/toy_SoC/firmware/firmware.bin differ diff --git a/examples/picorv32_soc/firmware/firmware.c b/examples/toy_SoC/firmware/firmware.c similarity index 100% rename from examples/picorv32_soc/firmware/firmware.c rename to examples/toy_SoC/firmware/firmware.c diff --git a/examples/picorv32_soc/firmware/makefile b/examples/toy_SoC/firmware/makefile similarity index 100% rename from examples/picorv32_soc/firmware/makefile rename to examples/toy_SoC/firmware/makefile diff --git a/examples/picorv32_soc/firmware/riscv32.ld b/examples/toy_SoC/firmware/riscv32.ld similarity index 100% rename from examples/picorv32_soc/firmware/riscv32.ld rename to examples/toy_SoC/firmware/riscv32.ld diff --git a/examples/picorv32_soc/makefile b/examples/toy_SoC/makefile similarity index 100% rename from examples/picorv32_soc/makefile rename to examples/toy_SoC/makefile diff --git a/examples/picorv32_soc/mdu b/examples/toy_SoC/mdu similarity index 100% rename from examples/picorv32_soc/mdu rename to examples/toy_SoC/mdu diff --git a/examples/picorv32_soc/picorv32 b/examples/toy_SoC/picorv32 similarity index 100% rename from examples/picorv32_soc/picorv32 rename to examples/toy_SoC/picorv32 diff --git a/examples/picorv32_soc/picorv32_wbp.vhd b/examples/toy_SoC/picorv32_wbp.vhd similarity index 100% rename from examples/picorv32_soc/picorv32_wbp.vhd rename to examples/toy_SoC/picorv32_wbp.vhd diff --git a/examples/picorv32_soc/serv_rf_wbp.vhd b/examples/toy_SoC/serv_rf_wbp.vhd similarity index 100% rename from examples/picorv32_soc/serv_rf_wbp.vhd rename to examples/toy_SoC/serv_rf_wbp.vhd diff --git a/examples/picorv32_soc/testbench.vhd b/examples/toy_SoC/testbench.vhd similarity index 100% rename from examples/picorv32_soc/testbench.vhd rename to examples/toy_SoC/testbench.vhd diff --git a/examples/picorv32_soc/urv-core b/examples/toy_SoC/urv-core similarity index 100% rename from examples/picorv32_soc/urv-core rename to examples/toy_SoC/urv-core diff --git a/examples/picorv32_soc/urv_cpu_wbp.vhd b/examples/toy_SoC/urv_cpu_wbp.vhd similarity index 100% rename from examples/picorv32_soc/urv_cpu_wbp.vhd rename to examples/toy_SoC/urv_cpu_wbp.vhd diff --git a/examples/picorv32_soc/wbp_mux.vhd b/examples/toy_SoC/wbp_mux.vhd similarity index 100% rename from examples/picorv32_soc/wbp_mux.vhd rename to examples/toy_SoC/wbp_mux.vhd diff --git a/examples/picorv32_soc/wbp_pkg.vhd b/examples/toy_SoC/wbp_pkg.vhd similarity index 100% rename from examples/picorv32_soc/wbp_pkg.vhd rename to examples/toy_SoC/wbp_pkg.vhd