Code Monkey home page Code Monkey logo

yarvi3's Introduction

Design study for the 3rd generation YARVI

YARVI (Yet Another RISC-V Implementation, naming is hard) was the first non-Berkeley RISC-V softcore, originally release in 2014. It was quite bare-bones. The second generation (YARVI2) was a complete RV32IM, also in Verilog, but the performance wasn't acceptable and it was never released.

Finding Silice has inspired me to try again, this time starting over in Silice. The first steps is just getting a trivial pipeline going.

A four stage (ADD, BLT) pipeline with bypass and restart/flush

Due to a bug in Silice I couldn't annotate the pipeline stages, but it's the classic Fetch, Decode/Reg Fetch, Execute, Writeback.

Just a few RISC-V instructions are implemented, ADD, BLT, LW, and SW.

Pipeline restarting/flushing

The most interesting aspect of this implementation is how flush is handled.

Instead of the traditional valid bit in all stages that is cleared on restart (a messy and error prone process), the stage that can restart the pipeline (here Execute) has two-state state machine, Normal and Flushing. When it decides to restart the pipeline, it issues the Restart signal to the head of the pipeline (Fetch) and enters Flushing. While in Flushing, it ignores everything incoming. (For efficiency reasons we only gate assignments that affects state, such as register file writeback and the restart controls).

Once the restart signal has propagated back to Execute (captured in "restart_token") it signals that everything has been flushed and we should transition back to Normal.

Lessons

This was my first Silice design and the pipeline mechanism wasn't documented, but through trial and error, it turned out to be straight forward.

Clearly this is cleaner, simpler, and less error prone the equivalent Verilog implementation. Notably,

  • there is no need to name the stage explicity (pipeline variables refer back to the previous stage unless it's redefined in the current)

  • pipeline variables are automatically propagated between stages

  • it's impossible to accidentally capture values from the wrong stage

Together this also means that inserting a stage in the middle requires no changes to the other stages.

(20231119 addition below)

It doesn't change the need to reasons able multiple concurrent stages though; register bypass is still a completely manual and error prone process as is the critical handling of pipeline controls (hazards, restarts, flushing, stalling). Handling this correctly is interesting enough, but doing this while doing it efficiently is hard.

yarvi3's People

Contributors

tommythorn avatar

Stargazers

 avatar

Watchers

 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.