Modules with Guarded Interfaces

Slides:



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

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.
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.
IP Lookup: Some subtle concurrency issues Arvind Computer Science & Artificial Intelligence Lab Massachusetts Institute of Technology March 4, 2013
December 10, 2009 L29-1 The Semantics of Bluespec Arvind Computer Science & Artificial Intelligence Lab Massachusetts Institute.
Computer Architecture: A Constructive Approach Sequential Circuits Arvind Computer Science & Artificial Intelligence Lab. Massachusetts Institute of Technology.
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.
September 3, 2009L02-1http://csg.csail.mit.edu/korea Introduction to Bluespec: A new methodology for designing Hardware Arvind Computer Science & Artificial.
Introduction to Bluespec: A new methodology for designing Hardware Arvind 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.
Constructive Computer Architecture Sequential Circuits Arvind Computer Science & Artificial Intelligence Lab. Massachusetts Institute of Technology September.
Introduction to Bluespec: A new methodology for designing Hardware Arvind Computer Science & Artificial Intelligence Lab. Massachusetts Institute of Technology.
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.
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.
Introduction to Bluespec: A new methodology for designing Hardware Arvind Computer Science & Artificial Intelligence Lab. Massachusetts Institute of Technology.
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
Introduction to Bluespec: A new methodology for designing Hardware
Introduction to Bluespec: A new methodology for designing Hardware
Bluespec-3: A non-pipelined processor Arvind
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
Pipelining combinational circuits
Multirule Systems and Concurrent Execution of Rules
Constructive Computer Architecture: Guards
Sequential Circuits Constructive Computer Architecture Arvind
Pipelining combinational circuits
Modular Refinement Arvind
EHR: Ephemeral History Register
Constructive Computer Architecture: Well formed BSV programs
Blusepc-5: Dead cycles, bubbles and Forwarding in Pipelines Arvind
Bluespec-7: Scheduling & Rule Composition
Pipelining combinational circuits
Sequential Circuits - 2 Constructive Computer Architecture Arvind
Introduction to Bluespec: A new methodology for designing Hardware
Bluespec-3: A non-pipelined processor Arvind
Multirule systems and Concurrent Execution of Rules
Modular Refinement - 2 Arvind
IP Lookup: Some subtle concurrency issues
Elastic Pipelines and Basics of Multi-rule Systems
Constructive Computer Architecture: Guards
Elastic Pipelines and Basics of Multi-rule Systems
Bluespec-7: Scheduling & Rule Composition
Control Hazards Constructive Computer Architecture: Arvind
Multirule systems and Concurrent Execution of Rules
Introduction to Bluespec: A new methodology for designing Hardware
IP Lookup: Some subtle concurrency issues
Bluespec-5: Scheduling & Rule Composition
Modular Refinement Arvind
Pipelining combinational circuits
Implementing for Correct Concurrency
Constructive Computer Architecture: Well formed BSV programs
Presentation transcript:

Modules with Guarded Interfaces Constructive Computer Architecture Modules with Guarded Interfaces Arvind Computer Science & Artificial Intelligence Lab. Massachusetts Institute of Technology (Andy) Changed course website to correct website September 15, 2017 http://csg.csail.mit.edu/6.175

Guarded interfaces Make the life of the programmers easier: Include some checks (readyness, fullness, ...) in the method definition itself, so that the user does not have to test the applicability of the method from outside Guarded Interface: Every method has a guard (rdy wire) The value returned by a method is meaningful only if its guard is true Every action method has an enable signal (en wire) and it can be invoked (en can be set to true) only if its guard is true n rdy en enq deq first FIFO not full not empty not empty interface Fifo#(numeric type size, type t); method Action enq(t x); method Action deq; method t first; endinterface notice, en and rdy wires are implicit September 15, 2017 http://csg.csail.mit.edu/6.175

One-Element FIFO Implementation with guards module mkFifo (Fifo#(1, t)); Reg#(t) d <- mkRegU; Reg#(Bool) v <- mkReg(False); method Action enq(t x) v <= True; d <= x; endmethod method Action deq v <= False; method t first return d; endmodule n rdy en enq deq first FIFO if (!v); not full Notice, no semicolon turns the if into a guard not empty if (v); not empty if (v); September 15, 2017 http://csg.csail.mit.edu/6.175

Rules with guards Like a method, a rule can also have a guard A rule can execute only if it’s guard is true, i.e., if the guard is false the rule has no effect True guards can be omitted guard rule foo (p); begin x1 <= e1; x2 <= e2 end endrule September 15, 2017 http://csg.csail.mit.edu/6.175

Streaming a function using a FIFO with guarded interfaces inQ outQ rule stream; if(inQ.notEmpty && outQ.notFull) begin outQ.enq(f(inQ.first)); inQ.deq; end endrule rule stream (True); outQ.enq(f(inQ.first)); inQ.deq; endrule September 15, 2017 http://csg.csail.mit.edu/6.175

Implicit Guards September 15, 2017 http://csg.csail.mit.edu/6.175

Switch using FIFOs with guarded interfaces inQ redQ greenQ switch rule switch; if (inQ.notEmpty) if (inQ.first.color == Red) begin1 if (redQ.notFull) begin2 redQ.enq(inQ.first.value); inQ.deq; end2 end1 else begin3 if (greenQ.notFull) begin4 greenQ.enq(inQ.first.value); inQ.deq; end4 end3 endrule All the red stuff can be deleted September 15, 2017 http://csg.csail.mit.edu/6.175

Switch using FIFOs with guarded interfaces inQ redQ greenQ switch rule switch (True); if (inQ.first.color == Red) begin redQ.enq (inQ.first.value); inQ.deq; end else begin greenQ.enq(inQ.first.value); inQ.deq; end endrule Implicit guard? September 15, 2017 http://csg.csail.mit.edu/6.175

GCD with and without guards start GCD busy getResult ready start GCD getResult ready busy en en en Interface without guards Interface with guards interface GCD; method Action start (Bit#(32) a, Bit#(32) b); method ActionValue#(Bit#(32)) getResult; method Bool busy; method Bool ready; endinterface September 15, 2017 http://csg.csail.mit.edu/6.175

Using GCD module with guarded interfaces getResult inQ get result invoke GCD start GCD outQ rule invokeGCD; gcd.start(inQ.first); inQ.deq; endrule; rule getResult; let x <- gcd.getResult; outQ.enq(x); endrule; A rule can be executed only if guards of all of its actions are true September 15, 2017 http://csg.csail.mit.edu/6.175

GCD with guarded interfaces implementation module mkGCD (GCD); Reg#(Bit#(32)) x <- mkReg(0); Reg#(Bit#(32)) y <- mkReg(0); Reg#(Bool) busy <- mkReg(False); rule gcd; if (x >= y) begin x <= x – y; end //subtract else if (x != 0) begin x <= y; y <= x; end //swap endrule method Action start(Bit#(32) a, Bit#(32) b) x <= a; y <= b; busy <= True; endmethod method ActionValue (Bit#(32)) getResult busy <= False; return y; endmodule interface GCD; method Action start (Bit#(32) a,Bit#(32) b); method ActionValue(Bit#(32)) getResult; endinterface if (!busy); if (x==0); Assume b /= 0 September 15, 2017 http://csg.csail.mit.edu/6.175

Guards vs Ifs method Action enq(t x) if (!v); v <= True; d <= x; endmethod guard is !v; enq can be applied only if v is false versus guard is True, i.e., the method is always applicable. method Action enq(t x); if (!v) begin v <= True; d <= x; end endmethod if v is true then x would get lost; bad September 15, 2017 http://csg.csail.mit.edu/6.175

Pipelining combinational circuits September 15, 2017 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 15, 2017 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 15, 2017 http://csg.csail.mit.edu/6.175

Elastic pipeline Use FIFOs instead of pipeline registers no need for valid bits f1 f2 f3 x inQ fifo1 fifo2 outQ rule stage1; fifo1.enq(f1(inQ.first)); inQ.deq(); endrule rule stage2; fifo2.enq(f2(fifo1.first)); fifo1.deq; endrule rule stage3; outQ.enq(f3(fifo2.first)); fifo2.deq; endrule When can stage1 rule fire? Can tokens be left in the pipeline? Can these rules execute concurrently? - inQ has an element - fifo1 has space No September 15, 2017 http://csg.csail.mit.edu/6.175

Elastic pipeline f1 f2 f3 x inQ fifo1 fifo2 outQ rule stage1; fifo1.enq(f1(inQ.first)); inQ.deq(); endrule rule stage2; fifo2.enq(f2(fifo1.first)); fifo1.deq; endrule rule stage3; outQ.enq(f3(fifo2.first)); fifo2.deq; endrule If these rules cannot execute concurrently, it is hardly a pipelined system When can rules execute concurrently? What hardware is synthesized to execute rules concurrently? September 15, 2017 http://csg.csail.mit.edu/6.175

Multi-rule Systems Repeatedly: Select a rule to execute Compute the state updates Make the state updates Non-deterministic choice; User annotations can be used in rule selection One-rule-at-a-time-semantics: Any legal behavior of a Bluespec program can be explained by observing the state updates obtained by applying only one rule at a time However, for performance we execute multiple rules concurrently whenever possible stay tuned … September 15, 2017 http://csg.csail.mit.edu/6.175

September 15, 2017 http://csg.csail.mit.edu/6.175

Inelastic pipeline x sReg1 inQ f0 f1 f2 sReg2 outQ rule sync_pipeline; inQ.deq; sReg1 <= f0(inQ.first); sReg2 <= f1(sReg1); outQ.enq(f2(sReg2)) endrule When can this rule execute? September 15, 2017 http://csg.csail.mit.edu/6.175

Pipeline bubbles x sReg1 inQ f0 f1 f2 sReg2 outQ Some issues rule sync_pipeline; inQ.deq; sReg1 <= f0(inQ.first); sReg2 <= f1(sReg1); outQ.enq(f2(sReg2)) 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 Modify the rule to deal with these conditions Introduce a valid bit September 15, 2017 http://csg.csail.mit.edu/6.175

Explicit encoding of data presence valid bit x inQ f0 f1 f2 outQ sReg1 sReg2 rule sync_pipeline; if(outQ.notFull || sReg2v != true) if (inQ.notEmpty) begin sReg1 <= f0(inQ.first); inQ.deq; sReg1v <= true end else sReg1v <= false; sReg2 <= f1(sReg1); sReg2v <= sReg1v; if (sReg2v == true) outQ.enq(f2(sReg2))) endrule September 15, 2017 http://csg.csail.mit.edu/6.175