17
DINO CPU A TEACHING-FOCUSED RISC-V DESIGN IN CHISEL Jason Lowe-Power Christopher Nitta @JasonLowePower https://github.com/jlpteaching/dinocpu

A TEACHING-FOCUSED RISC-V ESIGN IN CHISEL · DINO CPU A suite of RISC-V CPU designs Single cycle Five stage pipeline + Branch predictor All designs can run rv32i code compiled with

  • Upload
    others

  • View
    6

  • Download
    0

Embed Size (px)

Citation preview

Page 1: A TEACHING-FOCUSED RISC-V ESIGN IN CHISEL · DINO CPU A suite of RISC-V CPU designs Single cycle Five stage pipeline + Branch predictor All designs can run rv32i code compiled with

DINO CPUA TEACHING-FOCUSED

RISC-VDESIGN IN CHISEL

Jason Lowe-Power

Christopher Nitta

@JasonLowePower

https://github.com/jlpteaching/dinocpu

Page 2: A TEACHING-FOCUSED RISC-V ESIGN IN CHISEL · DINO CPU A suite of RISC-V CPU designs Single cycle Five stage pipeline + Branch predictor All designs can run rv32i code compiled with

DINO CPU

A suite of RISC-V CPU designsSingle cycleFive stage pipeline

+ Branch predictor

All designs can run rv32i code compiled with mainline GCC

A set of assignmentsOne for each design

Tools for classroom useChisel developmentAuto grading

Open sourcehttps://github.com/jlpteaching/dinocpu

Page 3: A TEACHING-FOCUSED RISC-V ESIGN IN CHISEL · DINO CPU A suite of RISC-V CPU designs Single cycle Five stage pipeline + Branch predictor All designs can run rv32i code compiled with

Open source hardware construction language

Embedded in Scala

Main benefit: Parameterizable

Used in industry: SiFive, Google, IBM, others…

https://chisel.eecs.berkeley.edu/

Page 4: A TEACHING-FOCUSED RISC-V ESIGN IN CHISEL · DINO CPU A suite of RISC-V CPU designs Single cycle Five stage pipeline + Branch predictor All designs can run rv32i code compiled with

Why Chisel?Vs Logisim

From an evaluation:

“I hate Logisim with a passion”

Scaling designs difficult

Grading time consuming

Page 5: A TEACHING-FOCUSED RISC-V ESIGN IN CHISEL · DINO CPU A suite of RISC-V CPU designs Single cycle Five stage pipeline + Branch predictor All designs can run rv32i code compiled with

Why Chisel?Vs Verilog

More modular design

Built-in unit tests + easy to add auto grading

Scala-basedMore familiar (to me)

Page 6: A TEACHING-FOCUSED RISC-V ESIGN IN CHISEL · DINO CPU A suite of RISC-V CPU designs Single cycle Five stage pipeline + Branch predictor All designs can run rv32i code compiled with

DINO CPU Design

Closely follows Patterson and Hennessy’s textbook’s design

Simple and modularNot fast, small, synthesizable

Complete-ishHide complexity when possible

Page 7: A TEACHING-FOCUSED RISC-V ESIGN IN CHISEL · DINO CPU A suite of RISC-V CPU designs Single cycle Five stage pipeline + Branch predictor All designs can run rv32i code compiled with

DINO CPU Assignment 1: R-types

Step 1: Logic for ALU control

Page 8: A TEACHING-FOCUSED RISC-V ESIGN IN CHISEL · DINO CPU A suite of RISC-V CPU designs Single cycle Five stage pipeline + Branch predictor All designs can run rv32i code compiled with

DINO CPU Assignment 1: R-types

Step 1: Logic for ALU control

Step 2: Draw R-type circuitBefore implementation!

Page 9: A TEACHING-FOCUSED RISC-V ESIGN IN CHISEL · DINO CPU A suite of RISC-V CPU designs Single cycle Five stage pipeline + Branch predictor All designs can run rv32i code compiled with

DINO CPU Assignment 1: R-types

Step 1: Logic for ALU control

Step 2: Draw R-type circuitBefore implementation!

Step 3: Write Chisel

Page 10: A TEACHING-FOCUSED RISC-V ESIGN IN CHISEL · DINO CPU A suite of RISC-V CPU designs Single cycle Five stage pipeline + Branch predictor All designs can run rv32i code compiled with

DINO CPU Assignment 2: Single-cycle

Given diagram:

Implement control

Wire control lines

Wire whole datapath

Assignment takes one instruction type at a time

Page 11: A TEACHING-FOCUSED RISC-V ESIGN IN CHISEL · DINO CPU A suite of RISC-V CPU designs Single cycle Five stage pipeline + Branch predictor All designs can run rv32i code compiled with

DINO CPU Assignment 3: Pipelined

Significant increase in complexity

Define all pipeline registers

Implement hazard and forwarding logic

Page 12: A TEACHING-FOCUSED RISC-V ESIGN IN CHISEL · DINO CPU A suite of RISC-V CPU designs Single cycle Five stage pipeline + Branch predictor All designs can run rv32i code compiled with

DINO CPU Assignment 4: Branch prediction

Extensions!We chose branchprediction

We updated pipeline

Students implemented two predictors

Ran benchmarks and compared results

Page 13: A TEACHING-FOCUSED RISC-V ESIGN IN CHISEL · DINO CPU A suite of RISC-V CPU designs Single cycle Five stage pipeline + Branch predictor All designs can run rv32i code compiled with

Tools included

Singularity containerMany dependenciesSafe and secure

Gradescope scriptsAutograder

Page 14: A TEACHING-FOCUSED RISC-V ESIGN IN CHISEL · DINO CPU A suite of RISC-V CPU designs Single cycle Five stage pipeline + Branch predictor All designs can run rv32i code compiled with

Open source

Everything on GitHubhttps://github.com/jlpteaching/dinocpu

Assignments

Documentation

Source code

Tools

Page 15: A TEACHING-FOCUSED RISC-V ESIGN IN CHISEL · DINO CPU A suite of RISC-V CPU designs Single cycle Five stage pipeline + Branch predictor All designs can run rv32i code compiled with

Future Improvements

Main feedback: Need better debugging

0%

10%

20%

30%

40%

50%

60%

< 5 5 - 10 10 - 20 > 20

Perc

ent

of

Stu

den

ts

Hours

"How much time did this assignment take?"

WQ L2 SQ L2

WQ L3 SQ L3

Page 16: A TEACHING-FOCUSED RISC-V ESIGN IN CHISEL · DINO CPU A suite of RISC-V CPU designs Single cycle Five stage pipeline + Branch predictor All designs can run rv32i code compiled with

Future Improvements

Main feedback: Need better debugging

More RISC-V supportPrivileged ISA for machine-mode rv32i (e.g., for embedded)

More assignmentsNon combinational memory + cacheMulti-issue?

Open source community!

Page 17: A TEACHING-FOCUSED RISC-V ESIGN IN CHISEL · DINO CPU A suite of RISC-V CPU designs Single cycle Five stage pipeline + Branch predictor All designs can run rv32i code compiled with

Questions/Comments?

Thanks to:

Students of ECS154B WQ19

Jared Barocsi, Filipe Eduardo Borges, Nima Ganjehloo,

Daniel Grau, Markus Hankins, and Justin

Perona