Pipelining combinational circuits

Slides:



Advertisements
Similar presentations
Elastic Pipelines and Basics of Multi-rule Systems Arvind Computer Science & Artificial Intelligence Lab Massachusetts Institute of Technology February.
Advertisements

An EHR based methodology for Concurrency management Arvind (with Asif Khan) Computer Science & Artificial Intelligence Lab Massachusetts Institute of Technology.
Constructive Computer Architecture: Multirule systems and Concurrent Execution of Rules Arvind Computer Science & Artificial Intelligence Lab. Massachusetts.
Folding and Pipelining complex combinational circuits Arvind Computer Science & Artificial Intelligence Lab Massachusetts Institute of Technology February.
EHRs: Designing modules with concurrent methods Arvind Computer Science & Artificial Intelligence Lab. Massachusetts Institute of Technology February 27,
Computer Architecture: A Constructive Approach EHRs: Designing modules with concurrent methods Teacher: Yoav Etsion Taken (with permission) from Arvind.
Asynchronous Pipelines: Concurrency Issues Arvind Computer Science & Artificial Intelligence Lab Massachusetts Institute of Technology October 13, 2009http://csg.csail.mit.edu/koreaL12-1.
February 21, 2007http://csg.csail.mit.edu/6.375/L07-1 Bluespec-4: Architectural exploration using IP lookup Arvind Computer Science & Artificial Intelligence.
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.
December 12, 2006http://csg.csail.mit.edu/6.827/L24-1 Scheduling Primitives for Bluespec Arvind Computer Science & Artificial Intelligence Lab Massachusetts.
Pipelining combinational circuits Arvind Computer Science & Artificial Intelligence Lab. Massachusetts Institute of Technology February 20, 2013http://csg.csail.mit.edu/6.375L05-1.
Constructive Computer Architecture: Guards Arvind Computer Science & Artificial Intelligence Lab. Massachusetts Institute of Technology September 24, 2014.
Constructive Computer Architecture Tutorial 2 Advanced BSV Andy Wright TA September 26, 2014http://csg.csail.mit.edu/6.175T02-1.
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.
Constructive Computer Architecture Sequential Circuits - 2 Arvind Computer Science & Artificial Intelligence Lab. Massachusetts Institute of Technology.
Constructive Computer Architecture: Control Hazards Arvind Computer Science & Artificial Intelligence Lab. Massachusetts Institute of Technology October.
Simple Inelastic and Folded Pipelines Arvind Computer Science & Artificial Intelligence Lab Massachusetts Institute of Technology February 14, 2011L04-1.
Computer Architecture: A Constructive Approach Pipelining combinational circuits Teacher: Yoav Etsion Taken (with permission) from Arvind et al.*, Massachusetts.
October 20, 2009L14-1http://csg.csail.mit.edu/korea Concurrency and Modularity Issues in Processor pipelines Arvind Computer Science & Artificial Intelligence.
Elastic Pipelines: Concurrency Issues
EHRs: Designing modules with concurrent methods
EHRs: Designing modules with concurrent methods
Bluespec-3: A non-pipelined processor Arvind
Concurrency properties of BSV methods and rules
Bluespec-6: Modeling Processors
Folded “Combinational” circuits
Scheduling Constraints on Interface methods
Blusepc-5: Dead cycles, bubbles and Forwarding in Pipelines Arvind
Sequential Circuits - 2 Constructive Computer Architecture Arvind
Sequential Circuits Constructive Computer Architecture Arvind
Sequential Circuits: Constructive Computer Architecture
Combinational Circuits in Bluespec
Performance Specifications
Combinational Circuits in Bluespec
Multirule Systems and Concurrent Execution of Rules
Constructive Computer Architecture: Guards
Sequential Circuits Constructive Computer Architecture Arvind
Pipelining combinational circuits
EHR: Ephemeral History Register
Constructive Computer Architecture: Well formed BSV programs
Blusepc-5: Dead cycles, bubbles and Forwarding in Pipelines Arvind
Control Hazards Constructive Computer Architecture: Arvind
Modules with Guarded Interfaces
Pipelining combinational circuits
Sequential Circuits - 2 Constructive Computer Architecture Arvind
Elastic Pipelines: Concurrency Issues
Bluespec-3: A non-pipelined processor Arvind
Multirule systems and Concurrent Execution of Rules
Modular Refinement - 2 Arvind
Combinational Circuits in Bluespec
IP Lookup: Some subtle concurrency issues
Computer Science & Artificial Intelligence Lab.
Elastic Pipelines: Concurrency Issues
Pipelined Processors Arvind
Elastic Pipelines and Basics of Multi-rule Systems
Constructive Computer Architecture: Guards
Elastic Pipelines and Basics of Multi-rule Systems
Control Hazards Constructive Computer Architecture: Arvind
Pipelined Processors Constructive Computer Architecture: Arvind
Simple Synchronous Pipelines
Multirule systems and Concurrent Execution of Rules
IP Lookup: Some subtle concurrency issues
Bluespec-5: Scheduling & Rule Composition
Control Hazards Constructive Computer Architecture: Arvind
Pipelining combinational circuits
Constructive Computer Architecture: Well formed BSV programs
Simple Synchronous Pipelines
Presentation transcript:

Pipelining combinational circuits Constructive Computer Architecture: Pipelining combinational circuits Arvind Computer Science & Artificial Intelligence Lab. Massachusetts Institute of Technology September 21, 2015 http://csg.csail.mit.edu/6.175

Content Elastic versus Inelastic pipelines The role of FIFOs Concurrency issues Ephemeral History Registers (EHRs) BSV Concepts The Maybe Type EHR September 21, 2015 http://csg.csail.mit.edu/6.175

Pipelining Combinational Functions xi+1 xi xi-1 3 different datasets in the pipeline f0 f1 f2 Lot of area and long combinational delay Folded or multi-cycle version can save area and reduce the combinational delay but throughput per clock cycle gets worse Pipelining: a method to increase the circuit throughput by evaluating multiple inputs September 21, 2015 http://csg.csail.mit.edu/6.175

Inelastic vs Elastic pipeline x sReg1 inQ f0 f1 f2 sReg2 outQ Inelastic: all pipeline stages move synchronously x fifo1 inQ f0 f1 f2 fifo2 outQ Elastic: A pipeline stage can process data if its input FIFO is not empty and output FIFO is not Full Most complex processor pipelines are a combination of the two styles September 21, 2015 http://csg.csail.mit.edu/6.175

Inelastic pipeline x sReg1 inQ f0 f1 f2 sReg2 outQ rule sync-pipeline; if(inQ.notEmpty && outQ.notFull) begin inQ.deq; sReg1 <= f0(inQ.first); sReg2 <= f1(sReg1); outQ.enq(f2(sReg2)) end endrule September 21, 2015 http://csg.csail.mit.edu/6.175

Pipeline bubbles x sReg1 inQ f0 f1 f2 sReg2 outQ rule sync-pipeline; if(inQ.notEmpty && outQ.notFull) begin inQ.deq; sReg1 <= f0(inQ.first); sReg2 <= f1(sReg1); outQ.enq(f2(sReg2)) end endrule Red and Green tokens must move even if there is nothing in inQ! Also if there is no token in sReg2 then nothing should be enqueued in the outQ Valid bits or the Maybe type Modify the rule to deal with these conditions September 21, 2015 http://csg.csail.mit.edu/6.175

Explicit encoding of Valid/Invalid data inQ f0 f1 f2 outQ sReg1 sReg2 typedef union tagged {void Valid; void Invalid; } Validbit deriving (Eq, Bits); rule sync-pipeline; if(outQ.notFull || sReg2v != Valid) if (inQ.notEmpty) begin sReg1 <= f0(inQ.first); inQ.deq; sReg1v <= Valid end else sReg1v <= Invalid; sReg2 <= f1(sReg1); sReg2v <= sReg1v; if (sReg2v == Valid) outQ.enq(f2(sReg2))) endrule September 21, 2015 http://csg.csail.mit.edu/6.175

When does the state change? rule sync-pipeline; if(outQ.notFull || sReg2v != Valid) if (inQ.notEmpty) begin sReg1 <= f0(inQ.first); inQ.deq; sReg1v <= Valid end else sReg1v <= Invalid; sReg2 <= f1(sReg1); sReg2v <= sReg1v; if (sReg2v == Valid) outQ.enq(f2(sReg2))) endrule sReg1 sReg2 inQ f0 f1 f2 outQ inQ sReg1v sReg2v outQ inQ sReg1v sReg2v outQ NE V V NF NE V V F NE V I NF NE V I F NE I V NF NE I V F NE I I NF NE I I F yes No Yes E V V NF E V V F E V I NF E V I F E I V NF E I V F E I I NF E I I F yes No Yes NE = Not Empty; NF = Not Full September 21, 2015 http://csg.csail.mit.edu/6.175

Elastic pipeline Use FIFOs instead of pipeline registers no need for maybe type f0 f1 f2 x inQ fifo1 fifo2 outQ rule elasticPipeline; if(inQ.notEmpty && fifo1.notFull) begin fifo1.enq(f0(inQ.first); inQ.deq end; if(fifo1.notEmpty && fifo2.notFull) begin fifo2.enq(f1(fifo1.first); fifo1.deq end; if(fifo2.notEmpty && outQ.notFull) begin outQ.enq(f2(fifo2.first); fifo2.deq) end; endrule When does the state change? Can tokens be left in the pipeline? September 21, 2015 http://csg.csail.mit.edu/6.175

State Change conditions for the rule x fifo1 inQ f0 f1 f2 fifo2 outQ inQ fifo1 fifo2 outQ act1 act2 act3 NE NE,NF NE,NF NF NE NE,NF NE,NF F NE NE,NF NE,F NF NE NE,NF NE,F F …. Yes Yes Yes Yes Yes No Yes No Yes Yes No No …. The execution of this rule assumes that enq and deq methods of the FIFOs can be executed concurrently What if they cannot? September 21, 2015 http://csg.csail.mit.edu/6.175

One-Element FIFO Implementation x en enq deq module Fifo !full !emty first notFull notEmpty module mkCFFifo (Fifo#(1, t)); Reg#(t) d <- mkRegU; Reg#(Bool) v <- mkReg(False); method Bool notFull; return !v; endmethod method Bool notEmpty; return v; method Action enq(t x); v <= True; d <= x; method Action deq; v <= False; method t first; return d; endmodule What if enq and deq were executed together? Can notEmpty and notFull be true simultaneously? double write error no! September 21, 2015 http://csg.csail.mit.edu/6.175

Two-Element FIFO db da module mkCFFifo (Fifo#(2, t)); Reg#(t) da <- mkRegU(); Reg#(Bool) va <- mkReg(False); Reg#(t) db <- mkRegU(); Reg#(Bool) vb <- mkReg(False); method Bool notFull; return !vb; endmethod method Bool notEmpty; return va; endmethod method Action enq(t x); if (va) begin db <= x; vb <= True; end else begin da <= x; va <= True; end endmethod method Action deq; if (vb) begin da <= db; vb <= False; end else begin va <= False; end method t first; return da; endmethod endmodule Assume, if there is only one element in the FIFO it resides in da notEmpty and notFull can be true simultaneously but concurrent execution of enq and deq will cause double write errors September 21, 2015 http://csg.csail.mit.edu/6.175

Concurrent method calls f1 f2 f3 x inQ fifo1 fifo2 outQ rule stage1; if(inQ.notEmpty && fifo1.notFull) begin fifo1.enq(f1(inQ.first); inQ.deq end; if(fifo1.notEmpty && fifo2.notFull) begin fifo2.enq(f2(fifo1.first); fifo1.deq end; if(fifo2.notEmpty && outQ.notFull) begin outQ.enq(f3(fifo2.first); fifo2.deq) end; endrule This rule is illegal if concurrent operations on FIFOs are not permitted September 21, 2015 http://csg.csail.mit.edu/6.175

Limitations of registers Limitations of a language with only the register primitive No communication between rules or between methods or between rules and methods in the same atomic action i.e. clock cycle Can’t express a FIFO with concurrent enq and deq September 21, 2015 http://csg.csail.mit.edu/6.175

EHR: Ephemeral History Register A new primitive element to design modules with concurrent methods September 21, 2015 http://csg.csail.mit.edu/6.175

Ephemeral History Register (EHR) Dan Rosenband [MEMOCODE’04] Q 1 w[0].data w[0].en r[0] normal bypass r[1] w[1].data w[1].en r[1] returns: – the current state if w[0] is not enabled – the value being written (w[0].data) if w[0] is enabled w[i+1] takes precedence over w[i] r[0] < w[0] r[1] < w[1] w[0] < w[1] < …. September 21, 2015 http://csg.csail.mit.edu/6.175

Designing FIFOs using EHRs Conflict-Free FIFO: Both enq and deq are permitted concurrently as long as the FIFO is not-full and not-empty The effect of enq is not visible to deq, and vise versa Pipeline FIFO: An enq into a full FIFO is permitted provided a deq from the FIFO is done simultaneously Bypass FIFO: A deq from an empty FIFO is permitted provided an enq into the FIFO is done simultaneously September 21, 2015 http://csg.csail.mit.edu/6.175

One-Element Pipelined FIFO module mkPipelineFifo(Fifo#(1, t)) provisos(Bits#(t, tSz)); Reg#(t) d <- mkRegU; Ehr#(2, Bool) v <- mkEhr(False); method Bool notFull = !v[1]; method Bool notEmpty = v[0]; method Action enq(t x); d <= x; v[1] <= True; endmethod method Action deq; v[0] <= False; method t first; return d; endmodule Desired behavior deq < enq first < deq first < enq No double write error In any given cycle: If the FIFO is not empty then simultaneous enq and deq are permitted; Otherwise, only enq is permitted September 21, 2015 http://csg.csail.mit.edu/6.175

One-Element Bypass FIFO module mkBypassFifo(Fifo#(1, t)) provisos(Bits#(t, tSz)); Ehr#(2, t) d <- mkEhr(?); Ehr#(2, Bool) v <- mkEhr(False); method Bool notFull = !v[0]; method Bool notEmpty = v[1]; method Action enq(t x); d[0] <= x; v[0] <= True; endmethod method Action deq; v[1] <= False; method t first; return d[1]; endmodule Desired behavior enq < deq first < deq enq < first No double write error In any given cycle: If the FIFO is not full then simultaneous enq and deq are permitted; Otherwise, only deq is permitted September 21, 2015 http://csg.csail.mit.edu/6.175

Two-Element Conflict-free FIFO db da module mkCFFifo(Fifo#(2, t)) provisos(Bits#(t, tSz)); Ehr#(2, t) da <- mkEhr(?); Ehr#(2, Bool) va <- mkEhr(False); Ehr#(2, t) db <- mkEhr(?); Ehr#(2, Bool) vb <- mkEhr(False); rule canonicalize; if(vb[1] && !va[1]) (da[1] <= db[1]; va[1] <= True; vb[1] <= False) endrule method Bool notFull = !vb[0]; method Bool notEmpty = va[0]; method Action enq(t x); db[0] <= x; vb[0] <= True; endmethod method Action deq; va[0] <= False; endmethod method t first; return da[0]; endmethod endmodule Assume, if there is only one element in the FIFO it resides in da Desired behavior enq CF deq first < deq first CF enq In any given cycle: Simultaneous enq and deq are permitted only if the FIFO is not full and not empty September 21, 2015 http://csg.csail.mit.edu/6.175