An attempt at a formal model of the Risc-V ISA in Clash Haskell.
Find a file
Artturin d8e6e6daa2 Add flake
`haskell.nix` is quite different from normal nix infra but seems to be
working fine here.
2025-02-22 22:13:14 +02:00
bin getting closer... 2025-02-19 09:06:40 -05:00
c first commit 2025-02-12 23:54:15 -05:00
hs works even better now 2025-02-19 18:28:08 -05:00
rv_tests/hello_world After make clean and make, this file changes 2025-02-22 22:02:52 +02:00
tables first commit 2025-02-12 23:54:15 -05:00
tests first commit 2025-02-12 23:54:15 -05:00
.gitignore first commit 2025-02-12 23:54:15 -05:00
cabal.project Rename rv_formal.cabal to rvFormal 2025-02-21 23:13:45 +02:00
flake.lock Add flake 2025-02-22 22:13:14 +02:00
flake.nix Add flake 2025-02-22 22:13:14 +02:00
gen.sh first commit 2025-02-12 23:54:15 -05:00
LICENSE first commit 2025-02-12 23:54:15 -05:00
README.md first commit 2025-02-12 23:54:15 -05:00
rvFormal.cabal Rename rv_formal.cabal to rvFormal 2025-02-21 23:13:45 +02:00
Setup.hs first commit 2025-02-12 23:54:15 -05:00
shell.nix Fix shell.nix 2025-02-21 17:04:56 +02:00
stack.yaml first commit 2025-02-12 23:54:15 -05:00

About

An attempt at a formal reference model for the RISC-V ISA written in Clash Haskell.

Getting Started

This works with ghc 9.4.8

The clash compiler is basically a modified version of ghc designed to allow for first class support of haskell code as circuits.

Note that this repository is currently very much W.I.P. That being said, this is how you would currently run a simulation:

cabal run main --ghc-options="-D_RAM_DEPTH=2048" -- --firmware=./rv_tests/hello_world/hello.bin

Notes

All the context that we pick up as we execute an instruction in essence forms the context of our micro-op machinery.

Installing GCC-RISC-V Toolchain on [Insert Platform Here]

Change instructions to support Nix

TODO

  • fetch should invoke mem read function

Organization Thoughts

  • Potential functions
    1. BitPat -> Opcode
    2. Opcode -> Fields
    3. Fields -> Field Vals
    4. Field Vals -> Reg Vals

Thoroughness

  • Check that all forms get used!! Remove unused forms!!

Grant Notes

  • Some forms may be redundant(may need to remove some)

Quality of Life Enhancements

  • turn off derive generics
  • update commands to use flags that prevent ghc intermediate outputs from littering source tree
  • enable Phoityne debug
  • learn to use trace and jupyter
  • draw conclusions on feasibility of debugging without VCD viewer