Modular Refinement Arvind

Slides:



Advertisements
Similar presentations
Multi-cycle Implementations Arvind Computer Science & Artificial Intelligence Lab. Massachusetts Institute of Technology January 13, 2012L6-1
Advertisements

Asynchronous Pipelines: Concurrency Issues Arvind Computer Science & Artificial Intelligence Lab Massachusetts Institute of Technology October 13, 2009http://csg.csail.mit.edu/koreaL12-1.
Modeling Processors Arvind Computer Science & Artificial Intelligence Lab Massachusetts Institute of Technology February 22, 2011L07-1
Computer Architecture: A Constructive Approach Branch Direction Prediction – Six Stage Pipeline Joel Emer Computer Science & Artificial Intelligence Lab.
March, 2007http://csg.csail.mit.edu/arvindIPlookup-1 IP Lookup Arvind Computer Science & Artificial Intelligence Lab Massachusetts Institute of Technology.
September 24, L08-1 IP Lookup: Some subtle concurrency issues Arvind Computer Science & Artificial Intelligence Lab.
Realistic Memories and Caches Li-Shiuan Peh Computer Science & Artificial Intelligence Lab. Massachusetts Institute of Technology March 21, 2012L13-1
1 Tutorial: Lab 4 Nirav Dave Computer Science & Artificial Intelligence Lab Massachusetts Institute of Technology.
Constructive Computer Architecture: Guards Arvind Computer Science & Artificial Intelligence Lab. Massachusetts Institute of Technology September 24, 2014.
September 22, 2009http://csg.csail.mit.edu/koreaL07-1 Asynchronous Pipelines: Concurrency Issues Arvind Computer Science & Artificial Intelligence Lab.
Constructive Computer Architecture Sequential Circuits Arvind Computer Science & Artificial Intelligence Lab. Massachusetts Institute of Technology
Elastic Pipelines: Concurrency Issues Arvind Computer Science & Artificial Intelligence Lab Massachusetts Institute of Technology February 28, 2011L08-1http://csg.csail.mit.edu/6.375.
Computer Architecture: A Constructive Approach Next Address Prediction – Six Stage Pipeline Joel Emer Computer Science & Artificial Intelligence Lab. Massachusetts.
Constructive Computer Architecture: Control Hazards Arvind Computer Science & Artificial Intelligence Lab. Massachusetts Institute of Technology October.
February 20, 2009http://csg.csail.mit.edu/6.375L08-1 Asynchronous Pipelines: Concurrency Issues Arvind Computer Science & Artificial Intelligence Lab Massachusetts.
1 Tutorial: Lab 4 Again Nirav Dave Computer Science & Artificial Intelligence Lab Massachusetts Institute of Technology.
Modular Refinement Arvind Computer Science & Artificial Intelligence Lab Massachusetts Institute of Technology March 8,
October 22, 2009http://csg.csail.mit.edu/korea Modular Refinement Arvind Computer Science & Artificial Intelligence Lab Massachusetts Institute of Technology.
Realistic Memories and Caches – Part III Li-Shiuan Peh Computer Science & Artificial Intelligence Lab. Massachusetts Institute of Technology April 4, 2012L15-1.
Introduction to Bluespec: A new methodology for designing Hardware Arvind Computer Science & Artificial Intelligence Lab. Massachusetts Institute of Technology.
October 20, 2009L14-1http://csg.csail.mit.edu/korea Concurrency and Modularity Issues in Processor pipelines Arvind Computer Science & Artificial Intelligence.
Modeling Processors Arvind Computer Science & Artificial Intelligence Lab Massachusetts Institute of Technology March 1, 2010
Elastic Pipelines: Concurrency Issues
February 28, 2005http://csg.csail.mit.edu/6.884/L09-1 Bluespec-3: Modules & Interfaces Arvind Computer Science & Artificial Intelligence Lab Massachusetts.
Bluespec-3: A non-pipelined processor Arvind
Concurrency properties of BSV methods and rules
Control Hazards Constructive Computer Architecture: Arvind
Bluespec-6: Modeling Processors
Bluespec-6: Modules and Interfaces
Scheduling Constraints on Interface methods
Blusepc-5: Dead cycles, bubbles and Forwarding in Pipelines Arvind
Sequential Circuits Constructive Computer Architecture Arvind
Sequential Circuits: Constructive Computer Architecture
Constructive Computer Architecture Tutorial 6: Discussion for lab6
Caches-2 Constructive Computer Architecture Arvind
Multistage Pipelined Processors and modular refinement
Performance Specifications
Constructive Computer Architecture: Guards
Sequential Circuits Constructive Computer Architecture Arvind
Modular Refinement Arvind
Modular Refinement Arvind
Lab 4 Overview: 6-stage SMIPS Pipeline
Blusepc-5: Dead cycles, bubbles and Forwarding in Pipelines Arvind
Bluespec-7: Scheduling & Rule Composition
Control Hazards Constructive Computer Architecture: Arvind
Modeling Processors: Concurrency Issues
Modules with Guarded Interfaces
6.375 Tutorial 5 RISC-V 6-Stage with Caches Ming Liu
Bypassing Computer Architecture: A Constructive Approach Joel Emer
Multistage Pipelined Processors and modular refinement
Modular Refinement Arvind
Elastic Pipelines: Concurrency Issues
Bluespec-3: A non-pipelined processor Arvind
Modular Refinement - 2 Arvind
Lecture 9. MIPS Processor Design – Decoding and Execution
Elastic Pipelines: Concurrency Issues
Bluespec-5: Modeling Processors
Constructive Computer Architecture: Guards
Bluespec-7: Scheduling & Rule Composition
Control Hazards Constructive Computer Architecture: Arvind
Pipelined Processors Constructive Computer Architecture: Arvind
Tutorial 4: RISCV modules Constructive Computer Architecture
Modeling Processors Arvind
Modeling Processors Arvind
Control Hazards Constructive Computer Architecture: Arvind
Implementing for Correct Concurrency
Modular Refinement Arvind
Tutorial 7: SMIPS Labs and Epochs Constructive Computer Architecture
Bluespec-8: Modules and Interfaces
Presentation transcript:

Modular Refinement Arvind Computer Science & Artificial Intelligence Lab Massachusetts Institute of Technology February 23, 2009 http://csg.csail.mit.edu/6.375

Successive refinement & Modular Structure fetch execute iMem rf CPU decode memory pc write- back dMem fetch & decode execute pc rf CPU bu Can we derive the 5-stage pipeline by successive refinement of a 2-stage pipeline? February 23, 2009 http://csg.csail.mit.edu/6.375

A 2-Stage Processor in RTL Design Microarchitecture Locate Datapaths/Memories and create modules Identify Input/Output ports Design the Controller (FSM) PC +4 Instuction Memory ALU Decode Register File Data buf Controller module regfile ( input [4:0] wa, //address for write port input [31:0] wd, //write data input we, //write enable (active high) input [4:0] ra1, //address for read port 1 output [31:0] rd1, //read data for port 1 ... February 23, 2009 http://csg.csail.mit.edu/6.375

Designing a 2-Stage Processor with GAA PC +4 Instuction Memory ALU Decode Register File Data buf Design Microarchitecture Locate Datapaths/Memories and create modules Define Interface methods: read, action, action value > setPC(new_pc) enqNextInst(dec_inst) update(addr,val) read(addr) interface RegisterFile#(addr_T, data_T); data_T read(addr_T); Action update(addr_T, data_T); endinterface; February 23, 2009 http://csg.csail.mit.edu/6.375

CPU as one module iMem dMem CPU fetch & decode RFile rf FIFO bu execute pc Method calls embody both data and control (i.e., protocol) Read method call Action method call February 23, 2009 http://csg.csail.mit.edu/6.375

CPU as one module module mkCPU#(Mem iMem, Mem dMem)(); // Instantiating state elements Reg#(Iaddress) pc <- mkReg(0); RegFile#(RName, Value) rf <- mkBypassRF(); SFIFO#(InstTemplate, RName) bu <- mkSLoopyFifo(findf); // Some definitions Instr instr = iMem.read(pc); Iaddress predIa = pc + 1; // Rules rule fetch_decode ... rule execute ... endmodule This first method describe what happens in the fetch of this pipeline. This methods says that given any processor term, we can always rewrite it to a new term wehre, and we enqueue the current instuction into bf. And at the same time the pc field is incremende by one It may look like this method can fire forever, but because bf is bounded, when a method enqueue into bf, there is an implied predicate that say bf must not be full. you have seen this before February 23, 2009 http://csg.csail.mit.edu/6.375 8 8 6 8

A Modular organization CPU iMem RFile rf FIFO bu dMem modules call each other (recursive) execute WB fetch & decode setPc pc stall enqIt Suppose we include rf and pc in Fetch and bu in Execute Fetch delivers decoded instructions to Execute and needs to consult Execute for the stall condition Execute writes back data in rf and supplies the pc value in case of a branch misprediction February 23, 2009 http://csg.csail.mit.edu/6.375

Recursive modular organization module mkCPU2#(Mem iMem, Mem dMem)(); Execute execute <- mkExecute(dMem, fetch); Fetch fetch <- mkFetch(iMem, execute); endmodule interface Fetch; method Action setPC (Iaddress cpc); method Action writeback (RName dst, Value v); endinterface interface Execute; method Action enqIt(InstTemplate it); method Bool stall(Instr instr) recursive calls This first method describe what happens in the fetch of this pipeline. This methods says that given any processor term, we can always rewrite it to a new term wehre, and we enqueue the current instuction into bf. And at the same time the pc field is incremende by one It may look like this method can fire forever, but because bf is bounded, when a method enqueue into bf, there is an implied predicate that say bf must not be full. Unfortunately, recursive module syntax is not as simple February 23, 2009 http://csg.csail.mit.edu/6.375 8 8 6 8

Fetch Module module mkFetch#(IMem iMem, Execute execute) (Fetch); Instr instr = iMem.read(pc); Iaddress predIa = pc + 1; Reg#(Iaddress) pc <- mkReg(0); RegFile#(RName, Bit#(32)) rf <- mkBypassRegFile(); rule fetch_and_decode (!execute.stall(instr)); execute.enqIt(newIt(instr,rf)); pc <= predIa; endrule method Action writeback(RName rd, Value v); rf.upd(rd,v); endmethod method Action setPC(Iaddress newPC); pc <= newPC; endmodule no change February 23, 2009 http://csg.csail.mit.edu/6.375

Execute Module no change module mkExecute#(DMem dMem, Fetch fetch) (Execute); SFIFO#(InstTemplate) bu <- mkSLoopyFifo(findf); InstTemplate it = bu.first; rule execute … method Action enqIt(InstTemplate it); bu.enq(it); endmethod method Bool stall(Instr instr); return (stallFunc(instr, bu)); endmodule no change February 23, 2009 http://csg.csail.mit.edu/6.375

Execute Module Rule rule execute (True); case (it) matches tagged EAdd{dst:.rd,src1:.va,src2:.vb}: begin fetch.writeback(rd, va+vb); bu.deq(); end tagged EBz {cond:.cv,addr:.av}: if (cv == 0) then begin fetch.setPC(av); bu.clear(); end else bu.deq(); tagged ELoad{dst:.rd,addr:.av}: begin fetch.writeback(rd, dMem.read(av)); bu.deq(); end tagged EStore{value:.vv,addr:.av}: begin dMem.write(av, vv); bu.deq(); endcase endrule February 23, 2009 http://csg.csail.mit.edu/6.375

Issue A recursive call structure can be wrong in the sense of “circular calls”; fortunately the compiler can perform this check Unfortunately recursive call structure amongst modules is supported by the compiler in a limited way. The syntax is complicated Recursive modules cannot be synthesized separately February 23, 2009 http://csg.csail.mit.edu/6.375

Syntax for Recursive Modules module mkFix#(Tuple2#(Fetch, Execute) fe) (Tuple2#(Fetch, Execute)); match{.f, .e} = fe; Fetch fetch <- mkFetch(e); Execute execute <- mkExecute(f); return(tuple2(fetch,execute)); endmodule (* synthesize *) module mkCPU(Empty); match {.fetch, .execute} <- moduleFix(mkFix); endmodule moduleFix is like the Y combinator F = Y F February 23, 2009 http://csg.csail.mit.edu/6.375

Passing parameters module mkCPU#(IMem iMem, DMem dMem)(Empty); module mkFix#(Tuple2#(Fetch, Execute) fe) (Tuple2#(Fetch, Execute)); match{.f, .e} = fe; Fetch fetch <- mkFetch(iMem,e); Execute execute <- mkExecute(dMem,f); return(tuple2(fetch,execute); endmodule match {.fetch, .execute} <- moduleFix(mkFix); endmodule February 23, 2009 http://csg.csail.mit.edu/6.375

Subtle Architecture Issues interface Fetch; method Action setPC (Iaddress cpc); method Action writeback (RName dst, Value v); endinterface interface Execute; method Action enqIt(InstTemplate it); method Bool stall(Instr instr) After setPC is called the next instruction enqueued via enqIt must correspond to iMem(cpc) stall and writeback methods are closely related; writeback affects the results of subsequent stalls the effect of writeback must be reflected immediately in the decoded instructions This first method describe what happens in the fetch of this pipeline. This methods says that given any processor term, we can always rewrite it to a new term wehre, and we enqueue the current instuction into bf. And at the same time the pc field is incremende by one It may look like this method can fire forever, but because bf is bounded, when a method enqueue into bf, there is an implied predicate that say bf must not be full. Any modular refinement must preserve these extra linguistic semantic properties February 23, 2009 http://csg.csail.mit.edu/6.375 8 8 6 8

Fetch Module Refinement Separating Fetch and Decode module mkFetch#(IMem iMem, Execute execute) (Fetch); FIFO#(Instr) fetchDecodeQ <- mkLoopyFIFO(); Instr instr = iMem.read(pc); Iaddress predIa = pc + 1; … rule fetch(True); pc <= predIa; fetchDecodeQ.enq(instr); endrule rule decode (!execute.stall(fetchDecodeQ.first())); execute.enqIt(newIt(fetchDecodeQ.first(),rf)); fetchDecodeQ.deq(); method Action setPC … method Action writeback … endmodule Are any changes needed in the methods? February 23, 2009 http://csg.csail.mit.edu/6.375

Fetch Module Refinement module mkFetch#(IMem iMem, Execute execute) (Fetch); FIFO#(Instr) fetchDecodeQ <- mkFIFO(); … Instr instr = iMem.read(pc); Iaddress predIa = pc + 1; method Action writeback(RName rd, Value v); rf.upd(rd,v); endmethod method Action setPC(Iaddress newPC); pc <= newPC; fetchDecodeQ.clear(); endmodule no change February 23, 2009 http://csg.csail.mit.edu/6.375

More refinements to consider Multicycle execution module Multicycle memory Bypassing Next time … February 23, 2009 http://csg.csail.mit.edu/6.375