• Stars
    star
    279
  • Rank 147,967 (Top 3 %)
  • Language
    F#
  • License
    MIT License
  • Created about 5 years ago
  • Updated 10 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

F# RISC-V Instruction Set formal specification

RISC-V formal ISA Specification

Build Status

Copyright © Evgeny Ukhanov

This is a formal (and executable) specification for the RISC-V ISA (Instruction Set Architecture), written in F# purely functional style. We deliberately choose an "extremely elementary" implementation of F# to make it readable and usable by wide audience who do not know F# and who do not plan to learn F#.

F# RISC-V ISA Formal Specification

This is a work-in-progress, one of several similar concurrent efforts within the ISA Formal Specification Technical Group constituted by The RISC-V Foundation (https://riscv.org). We welcome your feedback, comments and suggestions.

Content

Features & Current status

  • Supports the following features (or in active development state)
    • Base instruction set: RV32I
    • Tests RV32I
    • Base instruction set: RV64I
    • Tests RV64I
    • Standard extension M (integer multiply/divide)
    • Tests for Standard extension M RV32/RV64
    • Standard extension A (atomic memory ops)
    • Tests for Standard extension A RV32/RV64
  • Features under development
    • Standard extension C (Compressed 16-bit instructions)
    • Standard extension F (Single-precision floating point)
    • Standard extension D (Double-precision floating point)
    • Privilege Level M (Machine)
    • Privilege Level U (User)
    • Privilege Level S (Supervisor)
      • Virtual Memory schemes SV32, SV39 and SV48
  • Application can be executed as a F# program flexible with CLI (command line interface) support, which in turn executes RISC-V ELF binaries. This is a sequential interpretation: one-instruction-at-a-time, sequential memory model.
  • Tests passing for RISC-V under development:
    • Basic instruction flow
    • rv32ui-p-*, rv64ui-p-* (Base instruction set)
    • rv32um-p-*, rv64um-p-* (M extension)
    • rv32ua-p-*, rv64ua-p-* (A extension)
    • rv32uc-p-*, rv64uc-p-* (C extension)

Reading the code

We expect that many people might use this as a reading reference (whether or not they build and execute it) to clarify their understanding of RISC-V ISA semantics.

Main part for reading Specification:

  • Decode*.fs

    Decodes contain decoders for specific instructions set and notified with instruction/extension set symbol. For example DecodeI.fs

  • Execute*.fs

    Executes contain executions for specific instructions set and notified with instruction/extension set symbol. For example ExecuteI.fs

  • Utilities:

    • CLI.fs

      Contain helper function and types for building effective CLI commands and options.

    • Bits.fs

      Basic type specific functions for manipulations with bits.

    • Run.fs

      Basic Run flow - fetch, decode, execute, logging execution flow.

  • Architecture

    • Arch.fs

      Basic architecture types for RISC-V specification.

    • MachineState.fs

      Basic type and functions described RISC-V machine state.

  • Main app

    • Program.fs

    Main application to execute RISC-V simulator/emulator.

  • Test

    • Test/*.fs

      Contain unit-tests for instructions set and extensions

    • Test/asm/

      Contain Assembler test programs for manual testing RISC-V CPI implementation. It depend on risc-v toolchain and it has special auto-build Makefile.

How to build and run it on RISC-V binaries

Application can be executed as a sequential RISC-V simulator (sequential, one-instruction-at-a-time semantics), by building and executing it as a standard F# program.

Supported OS:

  • Linux
  • Windows
  • MacOS

Supported .NET SDK:

  • .NET SDK 2.2
  • .NET SDK 3.0

Install .NET SDK

For Windows preferred way to use Visual Studio.

Other examples will be for Linux. Please follow to instruction https://dotnet.microsoft.com/download

For Ubuntu:

$ wget -q https://packages.microsoft.com/config/ubuntu/16.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
$ sudo dpkg -i packages-microsoft-prod.deb
$ sudo apt-get update
$ sudo apt-get install apt-transport-https
$ sudo apt-get update
$ sudo apt-get install dotnet-sdk-3.0

To check installation:

$ dotnet --version

will tell you what version of dotnet you have.

Make the application executable

You can build the application executable with:

$ dotnet build

Run the application executable

Most simple way to run immediately run (without additional build command) to see command-line options on the executable:

$ dotnet run -- --help

If you run the application without option:

$ dotnet run

you'll receive error message:

Wrong parameters put --help to get more information

Example to run specific ISA with extensions, verbosity output and ELF file for execution in RISC-V CPI simulator:

$ dotnet run -- -A rv32i -v myapp.elf

How to Contribute

Please read file CONTRIBUTING.md

References

Licence

MIT License

More Repositories

1

iron-cms

CMS based on Iron Framework for Rust lang
Rust
46
star
2

semantic-analyzer-rs

Semantic analyzer library for compilers written in Rust for semantic analysis of programming languages AST
Rust
34
star
3

go-benchmark-app

Application for HTTP benchmarking via different rules and configs
Go
27
star
4

nickel-cms

The research project on the development of CMS based on Nickel framework
Rust
14
star
5

amq

Message queue distributed framework based on Actix
Rust
12
star
6

iLang

iLang - a functional programming language and compiler
Rust
9
star
7

riscv-cpu

RISC-V five stage pipline CPU
SystemVerilog
5
star
8

fpga

Research & Development FPGA projects for different boards
GLSL
4
star
9

echo-cms

CMS based on Echo golang framework
HTML
4
star
10

reqrep-events

Golang sample app for REQ/REP message queue events based on go-mangos
Go
3
star
11

rcp

Fast copy files based on Rust lang
Rust
3
star
12

rocket-rs

Rust Rocket app
Rust
3
star
13

useful-rust

Rust useful tools & tutorials based on https://doc.rust-lang.org/book/ Chapters and Rust By Examples
Rust
2
star
14

llvm-api-swift

Swift LLVM API is a library and utils set fully compatible with LLVM-C API. The library can be used to create compilers backend based on LLVM
Swift
2
star
15

llvm-sample

Rust
2
star
16

DAG-chain

DAG chain platform
F#
2
star
17

llvm-ir-tutor

LLVM IR Tutorial
LLVM
2
star
18

riscv-gcc-source-tests

C
2
star
19

avr-timers

AVR timers solutions
Assembly
2
star
20

reqrep-rs

Rust
2
star
21

simple-employees-task

Go
1
star
22

hsb

Haskell
1
star
23

gpg-test

1
star
24

auth-kit

Golang Authentication Kit
Go
1
star
25

status-check

Status Check system based on Yii Framework
PHP
1
star
26

mrLSD

Let's change the world... My favorite languages: Rust, F#, Go, Haskell
1
star
27

tokenomics

JavaScript
1
star
28

nodemcu-v3

NodeMCU v3 devboard projects
1
star
29

go-tutorial

Go Tutorials
Go
1
star
30

toy-codegen

Toy Codegen as example for `semantic-analyzer-rs` library.
Rust
1
star
31

mips-one-stage-cpu

MIPS 32 one stage CPU with limited ISA
Verilog
1
star
32

HaskellTutorials

Haskell
1
star
33

swift-async-toy

Toy async queue implemented on Swift
Swift
1
star
34

hashmap-copy

Rustlang concurent copy and change hashmap
Rust
1
star
35

dandelion

Semantic parser
F#
1
star
36

arduino

Arduino projects based on Atmel chips
C++
1
star
37

julia-dockerhub

DockerHub files for https://hub.docker.com/r/mrlsd/julia/
Makefile
1
star
38

exonum-blockchain

Exomun framework Blockchaind samples
1
star
39

yogaGo

Yoga CMS based on Golang
HTML
1
star
40

simple-http-files

Go
1
star
41

linux-util

Most useful utils for Linux
Shell
1
star
42

pyredmine

Python redmine console grid renderer for specific user and sorted by priority
Python
1
star
43

cabal-dependency-resolver

Haskell Cabal packages dependency resolver
Python
1
star
44

agda-emacs

Agda & Emacs integrations and samples code
Agda
1
star
45

idris-docker

Idris language docker image builder
Makefile
1
star
46

yasvm

Yet another simple Virtual Machine
Rust
1
star
47

rust-patterns

Rust design putterns templates
Rust
1
star
48

useful-haskell

Useful Haskell and algorithms
Haskell
1
star
49

git-fetch-history

Filter git commits and change their data
Go
1
star
50

book-formatter

Format text book to html formatted with page separation
Rust
1
star