DOC PREVIEW
MIT 6 375 - Modular Refinement

This preview shows page 1-2-3-4-5-6 out of 17 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 17 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 17 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 17 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 17 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 17 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 17 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 17 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

1Modular Refinement Arvind Computer Science & Artificial Intelligence LabMassachusetts Institute of Technologygyhttp://csg.csail.mit.edu/6.375March 8, 2010 L10-1Successive refinement & Modular StructurefetchexecuteiMemrfCPUdecodememorypcwrite-backdMemCPUCan we derive the 5-stage pipeline by successive refinement of a 2-stage pipeline?fetch & decodeexecutepcrfCPUbuhttp://csg.csail.mit.edu/6.375March 8, 2010 L10-22Architectural refinementsSeparating Fetch and DecodeRl i b Replace magic memory by multicycle memoryMulticycle functional units …http://csg.csail.mit.edu/6.375First, let us examine our two-stage pipelineMarch 8, 2010 L10-3Two-stage Pipelinerule fetch_and_decode (!stallfunc(instr, bu)); bu.enq(newIt(instr,rf));pc <= predIa;fetch & decodeexecutepcrfCPUbufetch rule can execute concurrently pc <= predIa;endrulerule execAdd (it matches tagged EAdd{dst:.rd,src1:.va,src2:.vb});rf.upd(rd, va+vb); bu.deq(); endrulerule BzTaken(it matches tagged Bz {cond:.cv,addr:.av}) &&& (cv == 0); pc <= av; bu.clear(); endrule ltk(itthtd{d dd })concurrently with every execute rule except the BzTaken ruleXrule BzNotTaken(it matchestaggedBz {cond:.cv,addr:.av});&&& !(cv == 0);bu.deq(); endrulerule execLoad(it matches tagged ELoad{dst:.rd,addr:.av});rf.upd(rd, dMem.read(av)); bu.deq(); endrulerule execStore(it matches tagged EStore{value:.vv,addr:.av});dMem.write(av, vv); bu.deq(); endrulehttp://csg.csail.mit.edu/6.375March 8, 2010 L10-43Properties Required of Register File and FIFO for Instruction PipeliningBypass Register File:  rf.upd(r1, v) < rf.sub(r2)Pipeline SFIFO  bu: {first , deq} < {find, enq} ⇒ bu.first < bu.find  bu.first < bu.enqq bu.deq < bu.find bu.deq < bu.enqhttp://csg.csail.mit.edu/6.375March 8, 2010 L10-5Bypass Register Filemodule mkBypassRFFull(RegFile#(RName,Value));RegFile#(RName,Value) rf <-mkRegFileFullWCF();RegFile#(RName,Value) rf <mkRegFileFullWCF();RWire#(Tuple2#(RName,Value)) rw <- mkRWire();method Action upd (RName r, Value d);rf.upd(r,d); rw.wset(tuple2(r,d));endmethodmethod Value sub(RName r);caserw wget() matches“Config reg file”caserw.wget() matchestagged Valid {.wr,.d}: return (wr==r) ? d : rf.sub(r);tagged Invalid: return rf.sub(r);endcaseendmethodendmodulehttp://csg.csail.mit.edu/6.375March 8, 2010 L10-64One Element Searchable Pipeline SFIFOmodule mkSFIFO1#(function Bool findf(tr r, t x))(SFIFO#(t,tr));Reg#(t) data <- mkRegU(); R#(Bl) fll<kC fi R (F l )bu.enq > bu.deqReg#(Bool) full <-mkConfigReg(False);RWire#(void) deqEN <- mkRWire();Bool deqp = isValid (deqEN.wget()));method Action enq(t x) if (!full || deqp);full <= True; data <= x;endmethodmethod Action deq() if (full);full <= False; deqEN.wset(?);endmethodmethod t first() if (full);t(dt)bu.enq > bu.deqbu.enq > bu.firstbu.enq < bu.clearbu.find < bu.enqbu find < bu deqbu.deq > bu.firstbu.deq < bu.clearreturn(data);endmethodmethod Action clear();full <= False;endmethodmethod Bool find(tr r);return (findf(r, data) && full);endmethod endmodule (full && !deqp));bu.find < bu.deqbu.find < bu.clear http://csg.csail.mit.edu/6.375bu.find < bu.enqbu.find > bu.deqbu.find < bu.clear March 8, 2010 L10-7Suppose we used the wrong SFIFO?bu.find < bu.deqWill the system produce wrong results?results? NO because the fetch rule will simply conflict with the execute rules http://csg.csail.mit.edu/6.375March 8, 2010 L10-85CPU as one moduleiMemdMemfetch & decodepcexecuteRFile rfSFIFO buCPUhttp://csg.csail.mit.edu/6.375Read method callAction method callMethod calls embody both data and control (i.e., protocol)March 8, 2010 L10-9A Modular organizationiMemRFile rfFIFO budMemCPUfetch & decodepcexecutesetPcenqItWBstallSuppose we include rf and pc in Fetch and bu in ExecuteFetch delivers decoded instructions to Execute and needs to consult Execute for the stall conditionExecute writes back data in rf and supplies the pc value in case of a branch mispredictionhttp://csg.csail.mit.edu/6.375March 8, 2010 L10-106Interface definitions:Fetch and Executeinterface Fetch;method Action setPC (Iaddress cpc);method Action writeback (RName dst, Value v); endinterfaceinterface Execute;method Action enqIt(InstTemplate it);method Bool stall(Instr instr)endinterfacehttp://csg.csail.mit.edu/6.375March 8, 2010 L10-11Recursive modular organizationmodule mkCPU2#(Mem iMem, Mem dMem)();Execute execute <- mkExecute(dMem, fetch);Fetch fetch <- mkFetch(iMem, execute);endmodulerecursive callsUnfortunately, the recursive module syntax is not so simplehttp://csg.csail.mit.edu/6.375March 8, 2010 L10-127IssueA recursive call structure can be wrong in the sense of “circular calls”; fortunately the il f thi h kcompiler can perform this checkUnfortunately recursive call structure amongst modules is supported by the compiler in a limited way. The syntax is complicated Recursive modules cannot be synthesized separatelyhttp://csg.csail.mit.edu/6.375March 8, 2010 L10-13Syntax for Recursive Modulesmodule mkFix#(Tuple2#(Fetch, Execute) fe)(Tuple2#(Fetch, Execute));match{ f e} fe;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);moduleFix is like the Y combinatorF = Y Fmatch{.fetch, .execute} <moduleFix(mkFix);endmodulehttp://csg.csail.mit.edu/6.375March 8, 2010 L10-148Passing parametersmodule mkCPU#(IMem iMem, DMem dMem)(Empty);module mkFix#(Tuple2#(Fetch, Execute) fe)w (Tuple2#(Fetch, Execute));match{.f, .e} = fe;Fetch fetch <- mkFetch(iMem,e);Execute execute <- mkExecute(dMem,f);return(tuple2(fetch,execute);wendmodulematch {.fetch, .execute} <-moduleFix(mkFix);endmodulehttp://csg.csail.mit.edu/6.375March 8, 2010 L10-15Fetch Modulemodule mkFetch#(IMem iMem, Execute execute) (Fetch);Instr instr = iMem.read(pc);Iaddress predIa = pc + 1;pp;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;endrulemethod Action writeback(RName rd, Value v);rf.upd(rd,v);endmethodmethod Action setPC(Iaddress newPC);pc <= newPC;endmethodendmodulehttp://csg.csail.mit.edu/6.375March 8, 2010 L10-169Execute Modulemodule mkExecute#(DMem dMem, Fetch fetch) (Execute);SFIFO#(InstTemplate) bu <-mkSPipelineFifo(findf);#( p )p();InstTemplate it = bu.first;rule execute …method Action enqIt(InstTemplate it);bu.enq(it);endmethodmethod Bool stall(Instr


View Full Document

MIT 6 375 - Modular Refinement

Documents in this Course
IP Lookup

IP Lookup

15 pages

Verilog 1

Verilog 1

19 pages

Verilog 2

Verilog 2

23 pages

Encoding

Encoding

21 pages

Quiz

Quiz

10 pages

IP Lookup

IP Lookup

30 pages

Load more
Download Modular Refinement
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Modular Refinement and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Modular Refinement 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?