December 10, 2009 L29-1 The Semantics of Bluespec Arvind Computer Science & Artificial Intelligence Lab Massachusetts Institute.

Slides:



Advertisements
Similar presentations
BSV execution model and concurrent rule scheduling Arvind Computer Science & Artificial Intelligence Lab. Massachusetts Institute of Technology February.
Advertisements

Elastic Pipelines and Basics of Multi-rule Systems Arvind Computer Science & Artificial Intelligence Lab Massachusetts Institute of Technology February.
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.
March 2007http://csg.csail.mit.edu/arvindSemantics-1 Scheduling Primitives for Bluespec Arvind Computer Science & Artificial Intelligence Lab Massachusetts.
Combinational Circuits in Bluespec
Stmt FSM Richard S. Uhler Computer Science & Artificial Intelligence Lab Massachusetts Institute of Technology (based on a lecture prepared by Arvind)
Asynchronous Pipelines: Concurrency Issues Arvind Computer Science & Artificial Intelligence Lab Massachusetts Institute of Technology October 13, 2009http://csg.csail.mit.edu/koreaL12-1.
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.
March 4, 2008 DF4-1http://csg.csail.mit.edu/arvind/ From Id/pH to Dataflow Graphs Arvind Computer Science & Artificial Intelligence Lab Massachusetts Institute.
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: Bluespec execution model and concurrency semantics Arvind Computer Science & Artificial Intelligence Lab. Massachusetts.
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.
March, 2007Intro-1http://csg.csail.mit.edu/arvind Design methods to facilitate rapid growth of SoCs Arvind Computer Science & Artificial Intelligence Lab.
Constructive Computer Architecture: Guards Arvind Computer Science & Artificial Intelligence Lab. Massachusetts Institute of Technology September 24, 2014.
March, 2007http://csg.csail.mit.edu/arvindIFFT-1 Combinational Circuits: IFFT, Types, Parameterization... Arvind Computer Science & Artificial Intelligence.
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
September 8, 2009http://csg.csail.mit.edu/koreaL03-1 Combinational Circuits in Bluespec Arvind Computer Science & Artificial Intelligence Lab Massachusetts.
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.
Operational Semantics Mooly Sagiv Tel Aviv University Sunday Scrieber 8 Monday Schrieber.
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.
Multiple Clock Domains (MCD) Arvind with Nirav Dave Computer Science & Artificial Intelligence Lab Massachusetts Institute of Technology.
Computer Architecture: A Constructive Approach Bluespec execution model and concurrent rule scheduling Teacher: Yoav Etsion Taken (with permission) from.
October 20, 2009L14-1http://csg.csail.mit.edu/korea Concurrency and Modularity Issues in Processor pipelines Arvind Computer Science & Artificial Intelligence.
Introduction to Bluespec: A new methodology for designing Hardware
Introduction to Bluespec: A new methodology for designing Hardware
Concurrency properties of BSV methods and rules
Bluespec-6: Modeling Processors
Scheduling Constraints on Interface methods
Sequential Circuits Constructive Computer Architecture Arvind
Sequential Circuits: Constructive Computer Architecture
Combinational Circuits in Bluespec
Stmt FSM Arvind (with the help of Nirav Dave)
Performance Specifications
Combinational Circuits in Bluespec
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
Modular Refinement Arvind
EHR: Ephemeral History Register
Constructive Computer Architecture: Well formed BSV programs
Modules with Guarded Interfaces
Pipelining combinational circuits
Sequential Circuits - 2 Constructive Computer Architecture Arvind
Introduction to Bluespec: A new methodology for designing Hardware
Multirule systems and Concurrent Execution of Rules
Stmt FSM Arvind (with the help of Nirav Dave)
Combinational Circuits in Bluespec
Computer Science & Artificial Intelligence Lab.
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
Simple Synchronous Pipelines
Multirule systems and Concurrent Execution of Rules
Introduction to Bluespec: A new methodology for designing Hardware
Bluespec-7: Semantics of Bluespec
Bluespec-5: Scheduling & Rule Composition
Constructive Computer Architecture: Well formed BSV programs
Simple Synchronous Pipelines
Presentation transcript:

December 10, 2009 L The Semantics of Bluespec Arvind Computer Science & Artificial Intelligence Lab Massachusetts Institute of Technology Nirav Dave, Mike Pellauer, Arvind [MEMOCODE 2007]

December 10, 2009 L Why Semantics? The semantics helps in deciding The meaning of a language construct – especially the corner cases The correctness of the compiler, especially the correctness of optimizations If the meaning of a construct is ambiguous or underspecified Characteristics of useful semantics The “kernel language” should be small The semantics should be concise, easy to understand and remember

December 10, 2009 L Indirect Semantics Most modern languages are big and their syntax contains many features for user convenience which interfere in understanding the deep semantics Consequently, the semantics are often given in two parts: 1. A static translation from the source language into a simpler, smaller kernel language 2. An Operational and sometimes the Denotational semantics of the kernel language

December 10, 2009 L Bluespec: Two-Level Compilation Object code (Verilog/C) Rules and Actions (Term Rewriting System) Rule conflict analysis Rule scheduling  James Hoe & Arvind Bluespec (Objects, Types, Higher-order functions) Level 1 compilation Type checking Massive partial evaluation and static elaboration Level 2 synthesis  Lennart Augustsson Now we call this Guarded Atomic Actions We will give an operational semantics at this level

December 10, 2009 L Bluespec: State and Rules organized into modules All state (e.g., Registers, FIFOs, RAMs,...) is explicit. Behavior is expressed in terms of atomic actions on the state: Rule: condition  action Rules can manipulate state in other modules only via their interfaces. interface module

December 10, 2009 L BTRS: A Language of GAAs A program is a collection of instantiated modules m 1, m 2,... Module ::= Module name [Register r] [Rule R a] [Action method g (x) = a] [Read method f (x) = e] e ::= r | c | t | Op(e, e) | e ? e : e | (t = e in e) | m.f(e) | e when e a ::= r := e | (t = e in a) | if e then a | m.g(e) | a when e  | a | a  | a ; a Conditional action Parallel Composition Method call Guarded action Sequential Composition New

December 10, 2009 L Action Connectives: Par vs. Seq Parallel compositions (a1|a2) Neither action observes others’ updates Writes are disjoint (muliple writes to a register in a rule is an error) Natural in hardware Sequential Connective (a1;a2) a2 observes a1’s updates Still atomic Not in BSV due to implementation complications (requires modules with“derived” interfaces) (r1:= r2 | r2:= r1) swaps r1 & r2

December 10, 2009 L BSV Guards BSV allows guards only at the top level in rules However, it has implicit guards in method calls For semantics these implicit guards are made explicit using “when” BTRS allows guards everywhere without introducing any additional complexity

December 10, 2009 L Guarded Interfaces: An Example FIFO interface FIFO#(type t); method Action enq(t); method Action deq(); method t first() endinterface make implicit guards explicit m.g B (e) when m.g G m.g(e) not full not empty rdy enab rdy enab rdy enq deq first FIFO module

December 10, 2009 L Predicating Actions: Guards vs. Ifs Guards affect their surroundings (a1 when p1) | a2 ==> (a1 | a2) when p1 The effect of an “if” is local (if p1 then a1) | a2 ==> if p1 then (a1 | a2) else a2 p1 has no effect on a2

December 10, 2009 L Exercise: Understanding Guards 1. (a1 when p1) | (a2 when p2) ==> (a1 | a2) when (p1 && p2) 2. (if p then (a1 when q)) | a2 ==> ((if p then a1)| a2) when (q || !p)

December 10, 2009 L GAA Execution model Repeatedly: Select a rule to execute Compute the state updates Make the state updates Highly non- deterministic Hardware Implementation: Needs to restrict this behavior to be deterministic To get “good” hardware: The compiler must schedule multiple rules in a single cycle But the effect must look like a serial execution of rules

December 10, 2009 L Operational Semantics We will first give the semantics of a single rule, i.e., how it modifies the state of the system Give a rule for how each language construct modifies the state Rules must be compositional Then we will give the semantics of multiple rules

December 10, 2009 L Semantics of a rule execution Specify which state elements the rule modifies Let S represent the value of all the registers before the rule executes Let U be the set of updates implied by the rule execution Let B represent the let-bound values we encounter in execution

December 10, 2009 L BTRS Action Rules: Register Assignment reg-update ├ e  v, ├ (r := e)  {}[v/r] NR represents the “not ready” value (v != NR)

December 10, 2009 L if-true ├ e  true, ├ a  U’ ├ (if e then a)  U’ BTRS Action Rules: Conditional Action if-false ├ e  false ├ (if e then a)  U

December 10, 2009 L BTRS Action Rules: Par and Seq action composition par ├ a1  U1, ├ a2  U2 ├ (a1 | a2)  pmerge(U1,U2) seq ├ a1  U1, ├ a2  U2 ├ (a1 ; a2)  U2++U1 Like a set union but blows up if there are any duplicates Like a set union but U2 dominates if there are any duplicates

December 10, 2009 L BTRS Action Rules: Let and Method calls a-let-sub ├ e  v, ├ a  U’ ├ ((t = e) in a)  U’ a-meth-call ├ e  v, (v != NR), x.a = lookup(m.g), ├ a  U’ ├ m.g(e)  U’

December 10, 2009 L Guard Semantics If no rule applies, e.g., if e in (a when e) returns false or NR, then the system is stuck and the effect of the whole atomic action of which (a when e) is a part is “no action”. a-when-ready ├ e  true, ├ a  U  ├ (a when e)  U e-when-true ├ e1  v, ├ e2  true  ├ (e1 when e2)  v e-when-false ├ e1  v, ├ e2  false  ├ (e1 when e2)  NR

December 10, 2009 L Variable ├ t  B(t) BTRS Expression Rules: register,constant,variables,ops op ├ e1  v1, v1 != NR ├ e2  v2, v2 != NR ├ (e1 op e2)  v1 op v2 Constant ├ c  c register read ├ r  (U++S) (r)

December 10, 2009 L tri-true ├ e1  true, ├ e2  v ├ (e1 ? e2 : e3)  v BTRS Expression Rules: Conditional expression tri-fasle ├ e1  false, ├ e3  v ├ (e1 ? e2 : e3)  v

December 10, 2009 L BTRS Expression Rules: Let and Method calls e-let-sub ├ e  v, ├ e2  v2 ├ ((t = e1) in e2)  v2 e-meth-call ├ e  v, (v != NR), x.eb = lookup(m.f), ├ eb v’ ├ m.f(e)  v’

December 10, 2009 L BTRS Specification Semantics 1. Pick a rule 2. Compute initial (read all registers) 3. Apply the rule yielding U 4. If no failure then update all registers according to U 5. Go to step 1

December 10, 2009 L Scheduling Schedules specify which rules should be executed concurrently without violating one-rule-at-a-time semantics A schedule can be specified by parallel and conditional composition or rules

December 10, 2009 L Lifting When’s to the top A1. (a1 when p) | a2  (a1 | a2) when p A2. a1 | (a2 when p)  (a1 | a2) when p A3. (a1 when p) ; a2  (a1 ; a2) when p A4. a1 ; (a2 when p)  (a1 ; a2) when p’ where p’ is p after the effect of a1 A5. if (p when q) then a  (if p then a) when q A6. if p then (a when q)  (if p then a) when (q || !p) A7. (a when p1) when p2  a when (p1 && p2) A8. r := (e when p)  (r := e) when p A9. m.g(e when p)  m.g(e) when p similarly for expressions...

December 10, 2009 L Final Takeaway Have fun designing systems with Bluespec Thanks Pizza time now!