Giter Site home page Giter Site logo

terrisc's Introduction

terrisc

This is an incomplete attempt to implement a RV32I v2.2(later up to RV64G) emulator.

It uses the terra programming language, which extends Lua by a staticly-typed language that integrates with normal Lua code.

Terra is great for writing an emulator like this, because you can use Lua to hide some of the ugly implementation details, making the code more readable, while still having the performance of a LLVM-compiled native binary.

In the future, it should be possible to export the emulator-part from terra as either a stand-alone library(As a .so file), or application. Also possible, although in the stand-alone versions not as easily, is a JIT for the emulator: Terra already has all the facility to make that happen(mostly LLVM).

Files

Filename Description
cpu_new.t Current implementation of CPU. Currently not working
mem_new.t (TODO) will implement memory
cpu.t old main entry: implements registers, step function, run, ...
mem.t old memory functions (e.g. reading a byte or word)
instruction_decoder.t generates an instruction decoder function, to resolve instructions to instruction callback pointers
instructions_RV32I.t implements the RV32I base instruction set(incomplete). Each instruction registers itself to an instrucion_decoder via a bitmask, bitpattern and a callback pointer
cpu_test.t Some tests for the CPU. Not automated. Also shows how instructions are manually encoded. Might be broken at times.

Please note that github misidentifys the .t files as perl files, so the syntax highlighting on github might not work properly.

Current status

IDK how often this status will be updated, the source code is the canonical documentation:

Implemented:

  • instruction decoder
  • decoding of most(all?) immediates for RV32I
  • some of the instruction callbacks

Missing(for base ISA):

  • missing instruction callbacks
  • traps, interrupts, ...
  • more

General TODO:

  • Floating point library binding(SoftFP?)
  • abstract the register typed away in the instructions and cpu
  • will most likely also mean touching every instruction :/
  • find test cases, run tests
  • write a simple assembler
  • check sign-ness for instructions(sign-extension to spec?)
  • in work, should be mostyl implemented, but untested
  • compressed instruction decoder
  • grep -nr "TODO:" *.t
  • Debug functions/interface option(Remove print's, only compile if needed)
  • (interactive) debugger?
  • debugger support?
  • build example C programm & run in emulator

terrisc's People

Contributors

max1220 avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.