6.375 tutorial 5 risc-v 6-stage with...
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](https://reader031.vdocuments.us/reader031/viewer/2022020411/5a9de24b7f8b9a0d5a8d717d/html5/thumbnails/1.jpg)
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](https://reader031.vdocuments.us/reader031/viewer/2022020411/5a9de24b7f8b9a0d5a8d717d/html5/thumbnails/2.jpg)
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](https://reader031.vdocuments.us/reader031/viewer/2022020411/5a9de24b7f8b9a0d5a8d717d/html5/thumbnails/3.jpg)
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](https://reader031.vdocuments.us/reader031/viewer/2022020411/5a9de24b7f8b9a0d5a8d717d/html5/thumbnails/4.jpg)
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](https://reader031.vdocuments.us/reader031/viewer/2022020411/5a9de24b7f8b9a0d5a8d717d/html5/thumbnails/5.jpg)
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](https://reader031.vdocuments.us/reader031/viewer/2022020411/5a9de24b7f8b9a0d5a8d717d/html5/thumbnails/6.jpg)
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](https://reader031.vdocuments.us/reader031/viewer/2022020411/5a9de24b7f8b9a0d5a8d717d/html5/thumbnails/7.jpg)
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](https://reader031.vdocuments.us/reader031/viewer/2022020411/5a9de24b7f8b9a0d5a8d717d/html5/thumbnails/8.jpg)
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](https://reader031.vdocuments.us/reader031/viewer/2022020411/5a9de24b7f8b9a0d5a8d717d/html5/thumbnails/9.jpg)
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](https://reader031.vdocuments.us/reader031/viewer/2022020411/5a9de24b7f8b9a0d5a8d717d/html5/thumbnails/10.jpg)
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](https://reader031.vdocuments.us/reader031/viewer/2022020411/5a9de24b7f8b9a0d5a8d717d/html5/thumbnails/11.jpg)
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](https://reader031.vdocuments.us/reader031/viewer/2022020411/5a9de24b7f8b9a0d5a8d717d/html5/thumbnails/12.jpg)
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