+ All Categories
Home > Documents > 6.375 Tutorial 5 RISC-V 6-Stage with...

6.375 Tutorial 5 RISC-V 6-Stage with...

Date post: 06-Mar-2018
Category:
Upload: buikhuong
View: 217 times
Download: 3 times
Share this document with a friend
12
6.375 Tutorial 5 RISC-V 6-Stage with Caches Ming Liu March 4, 2016 http://csg.csail.mit.edu/6.375 T04-1
Transcript
Page 1: 6.375 Tutorial 5 RISC-V 6-Stage with Cachescsg.csail.mit.edu/6.375/6_375_2016_www/handouts/tutorials/T05-RISC... · RISC-V 6-Stage with Caches Ming Liu ... Notes In Lab 6, ... Only

6.375 Tutorial 5

RISC-V 6-Stage with Caches

Ming Liu

March 4, 2016 http://csg.csail.mit.edu/6.375 T04-1

Page 2: 6.375 Tutorial 5 RISC-V 6-Stage with Cachescsg.csail.mit.edu/6.375/6_375_2016_www/handouts/tutorials/T05-RISC... · RISC-V 6-Stage with Caches Ming Liu ... Notes In Lab 6, ... Only

Overview

Interface as parameters

6 Stage Pipeline

Caches

March 4, 2016 http://csg.csail.mit.edu/6.375 T04-2

Page 3: 6.375 Tutorial 5 RISC-V 6-Stage with Cachescsg.csail.mit.edu/6.375/6_375_2016_www/handouts/tutorials/T05-RISC... · RISC-V 6-Stage with Caches Ming Liu ... Notes In Lab 6, ... Only

Notes

In Lab 6, you should use the Fifo::*; library defined in includes/

Do NOT use the BSV library FIFO::*;

Code shown in lecture is meant to be a guideline

Make sure you understand it because the code you write in the lab may be similar but not identical

March 4, 2016 T04-3 http://csg.csail.mit.edu/6.375

Page 4: 6.375 Tutorial 5 RISC-V 6-Stage with Cachescsg.csail.mit.edu/6.375/6_375_2016_www/handouts/tutorials/T05-RISC... · RISC-V 6-Stage with Caches Ming Liu ... Notes In Lab 6, ... Only

Interfaces as Module Parameters

Entire interfaces/subinterfaces (not just static types) can be passed as a parameter into a module

March 4, 2016 T04-4 http://csg.csail.mit.edu/6.375

module mkTb();

Integer init = 0;

IMemory iMem <- mkIMemory;

Proc#(2) p <- mkProc(iMem, init);

endmodule

module mkProc(IMemory mem,

Integer init,

Proc#(ncores) ifc);

rule doFetch;

mem.req(addr);

..

endrule

method ... //define Proc interface

endmethod

endmodule

Last parameter is always interface of module being defined

module mkProc(Proc);

endmodule

“ifc” is optional when no other parameters

Page 5: 6.375 Tutorial 5 RISC-V 6-Stage with Cachescsg.csail.mit.edu/6.375/6_375_2016_www/handouts/tutorials/T05-RISC... · RISC-V 6-Stage with Caches Ming Liu ... Notes In Lab 6, ... Only

Interfaces as Module Parameters

Passing interfaces to a module breaks synthesis boundary (*synthesize*)

Compiler currently cannot create a separate Verilog file for this module due to scheduling difficulties

Beware that all the scheduling/rule legality checks are still in place. Even across modules

March 4, 2016 T04-5 http://csg.csail.mit.edu/6.375

module mkTb();

IMemory iMem <- mkIMemory;

Proc p0 <- mkProc(iMem);

Proc p1 <- mkProc(iMem);

endmodule

If both p0 and p1 contain rules that calls iMem.req, then they may conflict.

Page 6: 6.375 Tutorial 5 RISC-V 6-Stage with Cachescsg.csail.mit.edu/6.375/6_375_2016_www/handouts/tutorials/T05-RISC... · RISC-V 6-Stage with Caches Ming Liu ... Notes In Lab 6, ... Only

Six Stage Pipeline

Use the 2-stage pipeline as a starting point. Subdivide the rules and create Fifos (elastic pipeline) between stages.

Not necessary to try and modularize the stages

March 4, 2016 T04-6 http://csg.csail.mit.edu/6.375

IMem DMem

F D R E M W

Scoreboard

RegFile Epoch

Page 7: 6.375 Tutorial 5 RISC-V 6-Stage with Cachescsg.csail.mit.edu/6.375/6_375_2016_www/handouts/tutorials/T05-RISC... · RISC-V 6-Stage with Caches Ming Liu ... Notes In Lab 6, ... Only

Six Stage Pipeline At Execute stage, we filter out instructions with mismatched epochs (caused by a prior branch insn)

However we can’t just “kill” or toss out the instruction as we did in the 2 stage. Why?

March 4, 2016 T04-7 http://csg.csail.mit.edu/6.375

IMem DMem

F D R E M W

Scoreboard

RegFile Epoch

RegFetch stage has changed state of our processor Scoreboard insert!

Solution: Mark instruction as “poisoned” and pass it on (but do not process it). Remove from SB in Writeback stage

Page 8: 6.375 Tutorial 5 RISC-V 6-Stage with Cachescsg.csail.mit.edu/6.375/6_375_2016_www/handouts/tutorials/T05-RISC... · RISC-V 6-Stage with Caches Ming Liu ... Notes In Lab 6, ... Only

Other Notes

Play with the type/size of RegFile and Scoreboard to see its effect on performance

Look at info_dut/mkProc.sched to see

if the schedule is what you expect

Pay attention to scheduling warnings related to your processor

March 4, 2016 T04-8 http://csg.csail.mit.edu/6.375

Page 9: 6.375 Tutorial 5 RISC-V 6-Stage with Cachescsg.csail.mit.edu/6.375/6_375_2016_www/handouts/tutorials/T05-RISC... · RISC-V 6-Stage with Caches Ming Liu ... Notes In Lab 6, ... Only

Part B: FPGA Infrastructure

Runs large benchmarks

SW-mkProc Interface

Start PC

mtohost

Init DRAM

Avoid re-programming FPGA

Reset FPGA after each test Nov 6, 2015 T06-9 http://csg.csail.mit.edu/6.175

mkProc

1GB DRAM

SW testbench

Start PC

mtohost

Init DRAM

Page 10: 6.375 Tutorial 5 RISC-V 6-Stage with Cachescsg.csail.mit.edu/6.375/6_375_2016_www/handouts/tutorials/T05-RISC... · RISC-V 6-Stage with Caches Ming Liu ... Notes In Lab 6, ... Only

Simulation

DRAM

RegFile + pipelined delay of resp

We also simulate DRAM initialization

Longer simulation time

Nov 6, 2015 T06-10 http://csg.csail.mit.edu/6.175

Reg file ...

Page 11: 6.375 Tutorial 5 RISC-V 6-Stage with Cachescsg.csail.mit.edu/6.375/6_375_2016_www/handouts/tutorials/T05-RISC... · RISC-V 6-Stage with Caches Ming Liu ... Notes In Lab 6, ... Only

Memory Interface

March 4, 2016 T04-11 http://csg.csail.mit.edu/6.375

DDR3 Mem Controller

1GB DRAM

WideMemWrapper

Splitter

DCache ICache

To proc pipeline stages

InitDDR3 Scemi/Tb

Page 12: 6.375 Tutorial 5 RISC-V 6-Stage with Cachescsg.csail.mit.edu/6.375/6_375_2016_www/handouts/tutorials/T05-RISC... · RISC-V 6-Stage with Caches Ming Liu ... Notes In Lab 6, ... Only

Implementing Cache

MemUtil.bsv and CacheTypes.bsv has a lot of useful utilities functions and constants you should use

Port code from DDR3Example.bsv to your 6-stage pipeline

Only very minor changes to the pipeline itself is needed

Guard all your rules in processor with (csrf.started)

Proc should execute only when the host tells it to start

March 4, 2016 T04-12 http://csg.csail.mit.edu/6.375


Recommended