A logical model of a minimal RISC-V CPU written in Haskell.
This is an exercise to learn Nix, Haskell, and RISC-V. It is not intended to be useful, fast, or even complete.
The goal is to understand the inner workings of the RISC-V architecture from the bottom-up and learn Haskell concepts on the way. A possible outcome would be an emulator that can run RV32I assembly.
- Install Nix
- follow instructions on https://nixos.org/download
- Enable flakes
- follow instructions on https://nixos.wiki/wiki/Flakes#Enable_flakes
- (Optional) install
direnv
- The structure of the project is dictated by the tools we are using, namely Nix and Cabal. This repository is both a Nix flake and a Cabal package and as such contains the following folders/files:
app/
: Haskell source code for an executable that can be built and run bycabal run
.src/
: Haskell library folder, each file inside is a Haskell module.test/
: Haskell source code for an executable that is built and run bycabal test
, used to test the functions defined insrc/
.CHANGELOG.md
: This file will only become relevant in case of a release.flake.nix
: This is a Nix flake providing dependencies for the project.flake.lock
: File specifying the exact versions of dependencies, created by thenix flake lock
command.LICENSE
: The Apache 2.0 license.riscvs-hs.cabal
: Cabal package description.shell.nix
: For compatibility with Nix without flakes as well as other tools.
- If you're using VSCode, you can use Nix environment selector to connect it with the Nix shell.