• Stars
    star
    155
  • Rank 240,864 (Top 5 %)
  • Language
    Haskell
  • License
    BSD 3-Clause "New...
  • Created about 7 years 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

A formal semantics of the RISC-V ISA in Haskell

riscv-semantics

Here lies a formal specification of the RISC-V ISA, written in Haskell. It is meant to serve many audiences.

First, it should be readable as documentation of the ISA, for, say, hardware and compiler engineers with no background in formal verification or functional programming. The next section suggests how such readers should get started.

Second, it should be executable as an oracle for test cases and so on. See the later sections here for build-and-run instructions.

Finally, people with sufficient Haskell background should be able to understand subtleties of the semantics and even extend with new features. More documentation for that class of users may be forthcoming!

How to Read this Spec

  1. Read the reading guide.
  2. Read the first half of our explanation of exception handling in the semantics.
  3. Dive into the Spec directory.

Installation Guide

Install Stack

This project uses stack to manage the Haskell compiler and the project's dependencies. Even though there is a package for stack that can be installed using apt (in Ubuntu et al.), it won't work due to known bugs in the version in the repository. To install stack, follow its official directions or run the following code in a Unix-based machine:

$ curl -sSL https://get.haskellstack.org/ | sh

Compile the Project

There is a Makefile with recipes to compile the project, the elf2hex utility, and all the tests. Building the tests requires a recent version of riscv-none-embed-gcc in your path. To build everything, run:

$ ./install.sh
$ make

If you do not have the compiler in your path, this command will fail. To install the compiler and add it to your path:

$ ./install_riscv_gcc.sh
$ . setup.sh

Simulating an Example Program

To simulate an example program, run the command

$ stack exec riscv-semantics test/build/thuemorse64

This invocation should produce the output

01101001100101101001011001101001100101100110100101101001100101101001011001101001011010011001011001101001100101101001011001101001

Run riscv-tests

To run the default 64-bit executable simulator on riscv-tests:

$ stack exec riscv-semantics-tests

Generation of Verilog (work in progress)

$ ./make-circuit.sh

The output will be in src/verilog.

To get rid of intermediate files created in the src folder:

$ ./clean-circuit.sh

More Repositories

1

fiat-crypto

Cryptographic Primitive Code Generation by Fiat
Coq
704
star
2

bedrock2

A work-in-progress language and compiler for verified low-level programming
Coq
294
star
3

fiat

Mostly Automated Synthesis of Correct-by-Construction Programs
Coq
146
star
4

kami

A Platform for High-Level Parametric Hardware Specification and its Modular Verification
Coq
141
star
5

koika

A core language for rule-based hardware design 🦑
Coq
137
star
6

riscv-coq

RISC-V Specification in Coq
Coq
108
star
7

timl

TiML: A Functional Programming Language with Time Complexity
Standard ML
75
star
8

bedrock

Coq library for verified low-level programming
Coq
57
star
9

rupicola

Gallina to Bedrock2 compilation toolkit
Coq
51
star
10

coqutil

Coq library for tactics, basic definitions, sets, maps
Coq
42
star
11

bbv

Bedrock Bit Vector Library
Coq
27
star
12

rewriter

Reflective PHOAS rewriting/pattern-matching-compilation framework for simply-typed equalities and let-lifting
Coq
23
star
13

reification-by-parametricity

Fast Setup for Proof by Reflection, in Two Lines of Ltac.
Mathematica
11
star
14

hemiola

A Coq framework to support structural design and proof of hardware cache-coherence protocols
Coq
11
star
15

engine-bench

Benchmarks for various proof engines
Coq
5
star
16

stencils

A Coq library for verifying dependencies of stencil implementations
Coq
4
star
17

network-configurations

Using Coq to derive network configurations from declarative policies
Coq
4
star
18

certifying-derivation-of-state-machines-from-coroutines

Haskell
3
star
19

blog

A blog for PLV and friends of PLV
CSS
3
star
20

fiat2

A high level language that will compile to bedrock2 using database-style techniques
Coq
2
star
21

softmul

Proving that a system with software trap handlers for unimplemented instructions behaves as if they were implemented in hardware
Coq
2
star
22

Fiat_matrix

Coq
1
star