Tuesday, August 16, 2016

That's all folks

If you recall Bugs Bunny from the title, you are awesome :).

On a more serious note, This is officially the last post of this myhdl-riscv gsoc series :(.

I implemented a RISC-V based processor Zscale in myHDL and validated-verified it with unit and assembly tests.

As of today, the entire core (Zscale processor) is functional except for the assembly test of the core. My co-gsocer, +Srivatsan Ramesh and I are working on it and hopefully should get it done soon. My college started on July 19 which slowed down the last few weeks which majorly involved testing the core.

A more holistic review :

Original Work Plan
My main motivation in the project was to demonstrate the power and flexibility of myHDL by developing a RISC-V based core in myHDL. A few main checpoints in mind were :
* Pure Python decoder for the entire instruction set.
* A complete RISCV core implemented in myHDL.
Work Completed
* Pure Python Decoder (y)
* myHDL based Decoder(y)
* Vscale individual modules (y)
* Vscale assembly modules (y)
* Vscale unit tests (y)
* Vscale assembly tests (n)
Work Remaining
Completion of Vscale assembly tests (remove a bug).
Links to commits
My Fork (more updated as I have a pending PR):
https://github.com/meetshah1995/riscv/commits/dev?author=meetshah1995

Main Repo (Contains all merged code ~5 PRs):
https://github.com/jck/riscv/commits/master?author=meetshah1995

Pull request(s) :

Pure Python RISC-V ISA Decoder Implementation
https://github.com/jck/riscv/pull/1

myHDL based RISCV 32I Decoder Implementation
https://github.com/jck/riscv/pull/2

Decoder module conversion and tests
https://github.com/jck/riscv/pull/3

Individual Vscale modules in myHDL
https://github.com/jck/riscv/pull/4

Assembly and test framework of Vscale in myHDL
https://github.com/jck/riscv/pull/5
Having said that, it gives me immense pleasure to have helped the myHDL & PSF community and would be more than glad if myHDL users used the riscv repository for their research and development.

It has been a great 3 months with a lot of learning and interaction experiences I gained on the way. Shout out to my mentors +Keerthan JC  and +Christopher Felton   for guiding my way through this seemingly difficult task.

I will promote myHDL in my university and contribute to the main myhdl repository in the coming months as and when I gather time.

Until next time,
MS.    

Thursday, August 11, 2016

Verify -> Validate -> Vscale

As you probably can guess from the post title, the last few weeks was mostly about verifying and validating the vscale modules.

I developed unit tests for each module and now the ongoing work is to create unified tests for the entire assembly of modules. With the successful (*fingers crossed*) implementation of these tests, and some awesome documentation,  riscv module will finally come alive to be fully used by the myHDL community :) .


See you next week,
MS.

Saturday, July 30, 2016

Let's build a processor !

We finally choose Zscale (by Berkeley Architecture Research) as the core for our project as it had a verilog implementation and was a simplistic core using RISC-V ISA, meeting all our specifications.

The Zscale core like any other processor consisted of the standard modules found in a processor :


  • Controller 
  • ALU (Arithmetic and Logic Unit) 
  • Register File 
  • CSR File 
  • Pipeline stages
  • Immediate Generators
  • Muxes
Currently we have ported all the modules to myHDL with tests (with the exception of one module) and we are currently assembling them to form the core. 

Zscale is just like another processor implementation, the reason why such a complex processor can be described in hardware so compactly is because of the beautifully designed ISA. 

As I was converting the core to myHDL, I realised the placement of each every bit in the ISA was a ingeniously planned thought which made it easy to write logic for the processor. 

To conclude, as we near the completion of this processor, the entire myHDL community will have a  RISCV processor which supports the RV32I ( crux of the ISA ).


See you next week,
MS 

Thursday, July 14, 2016

RISC-V Core review


The last two weeks have mostly been debugging and reviewing cores for our project. I had gathered all riscv implementations and then I reviewed them this week. Here is a list of the cores I reviewed.

I also was struggling with my health last week and thus could not post on the blog. I am also working on the decoder debugging currently as a side task.

Core Review

Cores :

  • Yarvi
  • Zscale
  • Shakti
    • E Class
    • C Class
  • PicoRV32

Yarvi

  • Type : In-order , 3 stage pipeline
  • Source : SystemVerilog
  • ISA : RV32I
  • Cache : None
  • Branch Predictor : None
  • Instruction Mem : 4KB
  • Data Mem : 4KB
  • Memory Interface : Avalon-MM
  • RISCV toolchain : riscv32-unknown-elf-gcc
  • Simulation support : Yes
  • In development : No
  • Future updates : No

Zscale

  • Source : Chisel and Verilog (vscale)
  • Type : Single-issue, In-order , 3 stage pipeline
  • ISA : RV32
  • Cache : None
  • Branch Predictor : None
  • Instruction Mem : 4KB
  • Data Mem : 4KB
  • Memory Interface : AHB-Lite bus
  • In development : Yes
  • Future updates : Yes
  • RISCV toolchain : riscv32
  • Simulation support : Yes

SHAKTI Cores

E Class

  • Source : Bluespec
  • Type : In-order , 3 stage pipeline
  • ISA : RV32I
  • Cache : L2
  • Branch Predictor : Custom
  • Instruction Mem : 4KB
  • Data Mem : 4KB
  • Memory Interface : AXI
  • In development : Yes
  • Future updates : Yes
  • RISCV toolchain : riscv32
  • Simulation support : No

C Class

  • Source : Bluespec
  • Type : In-order , 8 stage pipeline
  • ISA : RV32I
  • Cache : L2
  • Branch Predictor : Custom
  • Instruction Mem : 4KB
  • Data Mem : 4KB
  • Memory Interface : AXI
  • In development : Yes
  • Future updates : Yes
  • RISCV toolchain : None
  • Simulation support : No

PicoRV32

  • Source : Verilog
  • Type : In-order , 8 stage pipeline
  • ISA : RV32IMC
  • Cache : L2
  • Branch Predictor : Custom
  • Instruction Mem : 4KB
  • Data Mem : 4KB
  • Memory Interface : AXI Lite
  • In development : Yes
  • Future updates : Yes
  • RISCV toolchain : rv32
  • Simulation support : No

See you until next week !
MS.

Friday, June 24, 2016

Let's Silicon

As the title may suggest , most part of the next part pf my GSoC will be making hardware modules for RISC-V cores and interfacing them to make a processor !. 

I already have a working and tested myHDL based decoder in place. I am now in discussions with my mentor to finalize a RISC-V module which I can port to myHDL. This will embark the next phase of my coding in GSoC. 

We will be selecting a RV32I based core to implement in the coming weeks as the HDL decoder fully supports RV32I at the present.

I have also shifted my development on the `dev` branch keeping my `master` up to date with the main repository. 

See you next week. 
MS 
  

Sunday, June 12, 2016

Developer's Den

This week was a fun filled week. I had to setup continous integration, documentation, test coverage and code quality tags for my repository.

I always wanted to have those tags for my repository like the professinal OS repositories on github. Turns out this was my chance.

We chose travis for CI, coveralls for test coverage, landscape.io for code quality and readthedocs for documentation. It was a bit difficult to get all in place at first , but once I got a hold of it, it became very easy to setup.

One another important progress this week was that I got my First PR merged into the main repo :). with the python decoder, I am looking forward to get the hdl decoder working as soon as possible so that I can move on to the real RISC-V processor design.

This week was majorly getting the PRs and repo workflow in place with some interaction with my mentor and invaluable tips from his end.

With all things cleared up I think I am good to go for the coming weeks !.

See you next week,
MS

Friday, June 3, 2016

The Code has been broken !


The RISC-V is one of the most structured ISA I have come across so far , hence it was easy for me to design a structural module for the decoder. Like any other RISC instruction set, RISC-V also has a family of instructions with similar family-code and argument list. These instructions which belong to a particular family are distinguished by their own instruction opcodes.

Since the number of families in the ISA was not very large , I chose to segregate the instructions by their family first and then to decode the exact instruction by extracting its individual opcode.

This sounded all fine when I planned it. But the implementation was a bit difficult than I had thought. I had to come up with a data structure that can efficiently store multiple hierarchies of keys and values as the bitwise difference of different instructions was quite varied especially in the non logical and arithmetic instructions.

I decided to go with the multiple-key dictionary available directly in python. I made a hierarchy of keys , each differentiating one instruction from each other, First key being the family-code. Maximum number of keys that I had to use per instructions was 4, in very large families [0x14, 0x1C] etc.

Sample Decode Logic :

`addw rd rs1 rs2 31..25=0 14..12=0 6..2=0x0E 1..0=3`

My decoder will extract the 5 bit family-code from `6 to 2`, the 7 bit slice and the 3 bit slice from `31 to 27` and `14 to 12` respectively. Thus as you can probably guess, the order of the keys will be family-code-> 3-bit slice -> 7-bit slice. 

Thus when these keys are fed to the decoder table, it spits out the instruction name. Once we have the instruction name we can easily extract the arguments it takes from the 32 bit instruction.

I got a lot of help from the opcode repository from risc-v as it listed down the args, opcodes and instruction names in a very lucid readable manner.

Then came the testing part. I created the tests for each instruction and test method for each family. Thankfully they all passed :).

So I guess the code has indeed been broken. Now I have to move on with the remaining RISC-V implementation.

See you next week,
MS

Friday, May 27, 2016

Invitation Game ? no please !

This week I had to get ahead with the pure python decoder implementation. I surely went ahead but it was more like a step ahead, two steps back , recursion more or less.

I had to tread through the never-ending RISC-V ISA specification manual to understand each instructions encoding and write tests to make sure my decoder is working as it should - correctly! .

Murphy said it righteously, if there were x mistakes one can make , I made them all implementing the decoder.

But nonetheless a very basic version of the decoder is ready , I have to still polish it and rigorously test it for correctness. I expect to do that by tomorrow.

So see you next week. Decoding isn't very inviting a game though folks :P .

Best,
MS.  

Monday, May 23, 2016

Community.bond()

Community bonding period is over and now comes the real fun part - coding :D.

To summarize my community bonding period , I completed the following exercises :

  • Get familiar with the inherent decorators and generator structure of myHDL.
  • Learn to model sequential and combinational logic hardware components in myHDL. 
  • Learnt to read Chisel and be able to interpret model from code which maybe needed in further parts of the RISC-V CPU design. 
  • Read and understand the RISC-V and its instruction set model.
  • Search , understand and assimilate existing RISC-V implementations and choose one to focus on. 
  • Get started with the decoder implementation. 
Other than these exercises , I also got to know more about my mentors and had fruitful discussions on the road ahead.

See you next week !

MS

Saturday, April 23, 2016

./gsoc init

As it turns out , my proposal has been selected as a project. Looking forward to an awesome summer.

return 0;  

Thursday, March 3, 2016

Introduction

Hello everyone,

I am Meet Shah and I will be writing more about my experience with myHDL community and a few implementation details of my project here.