Constructive Computer Architecture: Bluespec execution model and concurrency semantics Arvind Computer Science & Artificial Intelligence Lab. Massachusetts.

Slides:



Advertisements
Similar presentations
1 Programming Languages (CS 550) Mini Language Interpreter Jeremy R. Johnson.
Advertisements

BSV execution model and concurrent rule scheduling Arvind Computer Science & Artificial Intelligence Lab. Massachusetts Institute of Technology February.
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.
Give qualifications of instructors: DAP
CS 151 Digital Systems Design Lecture 37 Register Transfer Level
George Mason University ECE 448 – FPGA and ASIC Design with VHDL Finite State Machines State Diagrams, State Tables, Algorithmic State Machine (ASM) Charts,
Lecture 10 Topics: Sequential circuits Basic concepts Clocks
December 10, 2009 L29-1 The Semantics of Bluespec 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 Arvind Computer Science & Artificial Intelligence Lab Massachusetts Institute of Technology 6.175: L01 – September 9,
Constructive Computer Architecture Cache Coherence Arvind Computer Science & Artificial Intelligence Lab. Massachusetts Institute of Technology November.
Constructive Computer Architecture Virtual Memory: From Address Translation to Demand Paging Arvind Computer Science & Artificial Intelligence Lab. Massachusetts.
ECE/CS 352 Digital System Fundamentals© 2001 C. Kime 1 ECE/CS 352 Digital Systems Fundamentals Spring 2001 Chapters 3 and 4: Verilog – Part 2 Charles R.
Constructive Computer Architecture Combinational circuits 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.
Basic Scheme February 8, 2007 Compound expressions Rules of evaluation Creating procedures by capturing common patterns.
Constructive Computer Architecture Sequential Circuits Arvind Computer Science & Artificial Intelligence Lab. Massachusetts Institute of Technology
1/33 Basic Scheme February 8, 2007 Compound expressions Rules of evaluation Creating procedures by capturing common patterns.
04/26/20031 ECE 551: Digital System Design & Synthesis Lecture Set : Introduction to VHDL 12.2: VHDL versus Verilog (Separate File)
Fall 2008Programming Development Techniques 1 Topic 17 Assignment, Local State, and the Environment Model of Evaluation Section 3.1 & 3.2.
1 Programming Languages (CS 550) Lecture 2 Summary Mini Language Interpreter Jeremy R. Johnson.
Constructive Computer Architecture Sequential Circuits Arvind Computer Science & Artificial Intelligence Lab. Massachusetts Institute of Technology September.
Chapter 11: System Design Methodology Digital System Designs and Practices Using Verilog HDL and 2008, John Wiley11-1 Chapter 11: System Design.
Constructive Computer Architecture Cache Coherence Arvind Computer Science & Artificial Intelligence Lab. Massachusetts Institute of Technology Includes.
Constructive Computer Architecture Sequential Circuits - 2 Arvind Computer Science & Artificial Intelligence Lab. Massachusetts Institute of Technology.
Constructive Computer Architecture: Hardware Compilation of Bluespec Arvind Computer Science & Artificial Intelligence Lab. Massachusetts Institute of.
Operational Semantics Mooly Sagiv Tel Aviv University Sunday Scrieber 8 Monday Schrieber.
Constructive Computer Architecture Store Buffers and Non-blocking Caches Arvind Computer Science & Artificial Intelligence Lab. Massachusetts Institute.
SYEN 3330 Digital SystemsJung H. Kim Chapter SYEN 3330 Digital Systems Chapters 4 – Part4: Verilog – Part 2.
Operational Semantics Mooly Sagiv Reference: Semantics with Applications Chapter 2 H. Nielson and F. Nielson
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.
Operational Semantics of Scheme
Constructive Computer Architecture
Basic Scheme February 8, 2007 Compound expressions Rules of evaluation
Concurrency properties of BSV methods and rules
Sequential Circuits - 2 Constructive Computer Architecture Arvind
Sequential Circuits Constructive Computer Architecture Arvind
Sequential Circuits: Constructive Computer Architecture
ECE 448 Lecture 6 Finite State Machines State Diagrams vs. Algorithmic State Machine (ASM) Charts.
FFT: An example of complex combinational circuits
Constructive Computer Architecture
Multirule Systems and Concurrent Execution of Rules
Constructive Computer Architecture: Guards
Sequential Circuits Constructive Computer Architecture Arvind
Mini Language Interpreter Programming Languages (CS 550)
Combinational circuits
Constructive Computer Architecture: Well formed BSV programs
The Metacircular Evaluator
Modules with Guarded Interfaces
Sequential Circuits - 2 Constructive Computer Architecture Arvind
The Metacircular Evaluator
Multirule systems and Concurrent Execution of Rules
Computer Science & Artificial Intelligence Lab.
FFT: An example of complex combinational circuits
Constructive Computer Architecture: Guards
The Metacircular Evaluator (Continued)
6.001 SICP Variations on a Scheme
Multirule systems and Concurrent Execution of Rules
Bluespec-7: Semantics of Bluespec
ECE 352 Digital System Fundamentals
Pipelining combinational circuits
Constructive Computer Architecture: Well formed BSV programs
ECE 448 Lecture 6 Finite State Machines State Diagrams, State Tables, Algorithmic State Machine (ASM) Charts, and VHDL code ECE 448 – FPGA and ASIC Design.
Introduction to the Lab
Rehearsal: Lazy Evaluation Infinite Streams in our lazy evaluator
Presentation transcript:

Constructive Computer Architecture: Bluespec execution model and concurrency semantics Arvind Computer Science & Artificial Intelligence Lab. Massachusetts Institute of Technology September 13, L04-1

Contributors to the course material Arvind, Rishiyur S. Nikhil, Joel Emer, Muralidaran Vijayaraghavan Staff and students in (Spring 2013), 6.S195 (Fall 2012), 6.S078 (Spring 2012) Asif Khan, Richard Ruhler, Sang Woo Jun, Abhinav Agarwal, Myron King, Kermin Fleming, Ming Liu, Li- Shiuan Peh External Prof Amey Karkare & students at IIT Kanpur Prof Jihong Kim & students at Seoul Nation University Prof Derek Chiou, University of Texas at Austin Prof Yoav Etsion & students at Technion September 13,

Finite State Machines (Sequential Ckts) Present state Q1 Q2 Next State, Output X=0 Next State, Output X=1 0011,001,0 0111,000,0 1010,011,1 1110,010,1 September 13, 2013 L04-3http://csg.csail.mit.edu/6.s195 Typical description: State Transition Table or Diagram Easily translated into circuits

Finite State Machines (Sequential Ckts) A computer (if fact all digital hardware) is an FSM Neither State tables nor diagrams is suitable for describing very large digital designs large circuits must be described in a modular fashion -- as a collection of cooperating FSMs Bluespec is a modern programming language to describe cooperating FSMs This lecture is about understanding the semantics of Bluespec September 13, 2013 L04-4http://csg.csail.mit.edu/6.s195

In this lecture we will use pseudo syntax, and assume that type checking has been performed (programs are type correct) September 13, 2013L04-5

KBS0: A simple language for describing Sequential ckts -1 A program consists of a collection of registers (x,y,...) and rules Registers hold the state from one clock cycle to the next A rule specifies how the state is to be modified each clock cycle All registers are read at the beginning of the clock cycle and updated at the end of the clock cycle September 13, 2013 L04-6http://csg.csail.mit.edu/6.s195

KBS0: A simple language for describing Sequential ckts - 2 ::= x:= register assignment | ; parallel actions | if ( ) conditional action | let t = in binding ::= c constants | t value of a binding | x.r register read | op(, ) operators like And, Or, Not, +,... | let t = in binding We will assume that the names in the bindings (t …) can be defined only once (single assignment restriction) September 13, A rule is simply an action described below. Expression is a way of describing combinational ckts

Evaluating expressions and actions The state of the system s is defined as the value of all its registers An expression is evaluated by computing its value on the current state An action defines the next value of some of the state elements based on the current value of the state A rule is evaluated by evaluating the corresponding action and simultaneously updating all the affected state elements x y z... rule x’ y’ z’...  September 13,

Bluespec Execution Model Repeatedly: Select a rule to execute Compute the state updates Make the state updates 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 Highly non- deterministic; User annotations can be used in rule selection September 13, Need a evaluator to define how a rule transforms the state

KBS0 Evaluator We will write the evaluator as a software program using case-by-case analysis of syntax September 13, 2013 L04-10http://csg.csail.mit.edu/6.s195 evalE :: (Bindings, State, e) -> Value evalA :: (Bindings, State, a) -> (Bindings, StateUpdates) Bindings is a set of (variable name,value) pairs State is a set of (register name, value) pairs. s.x gives the value of register x in the current state Syntax is represented as [[…]]

KBS0: Expression evaluator evalE (bs, s, [[c]]) = c evalE (bs, s, [[t]]) = bs[t] evalE (bs, s, [[x.r]]) = s[x] evalE (bs, s, [[op(e1,e2)]]) = op(evalE(bs, s, [[e1]]), evalE(bs, s, [[e2]])) evalE (bs, s, [[(let t = e in e1)]]) = { v = evalE(bs, s, [[e]]); return evalE(bs+(t,v), s, [[e1]])} evalE :: (Bindings, State, exp) -> Value lookup t; if t does not exist in bs then the rule is illegal Bindings bs is empty initially add a new binding to bs. The operation is illegal if t is already present in bs September 13,

KBS0: Action evaluator evalA (bs, s, [[x.w(e)]]) = (x, evalE(bs, s, [[e]])) evalA (bs, s, [[a1 ; a2]]) = { u1 = evalA(bs, s, [[a1]]); u2 = evalA(bs’, s, [[a2]]) return u1 + u2 } evalA (bs, s, [[if (e) a]]) = if evalE(bs, s, [[e]]) then evalA(bs, s, [[a]]) else {} evalA (bs, s, [[(let t = e in a)]]) = { v = evalE(bs, s, [[e]]) return evalA(bs+(t,v), s, [[a]]) } evalA :: (Bindings, State, a) -> StateUpdates initially bs is empty and s contains old register values merges two sets of updates; the rule is illegal if there are multiple updates for the same register extends the bindings by including one for t September 13,

Rule evaluator To apply a rule, we compute the state updates using EvalA and then simultaneously update all the state variables that need to be updated September 13,

Evaluation in the presence of modules It is easy to extend the evaluator we have shown to include non-primitive method calls An action method, just like a register write, can be called at most once from a rule The only additional complication is that a value method with parameters can also be called at most once from an action It these conditions are violated then it is an illegal rule/action/expression September 13,

Evaluation in the presence of guards In the presence of guards the expression evaluator has to return a special value – NR (for “not ready”). This ultimately affects whether an action can affect the state or not. Instead of complicating the evaluator we will give a procedure to lift when’s to the top of a rule. At the top level a guard behaves just like an “if” September 13,

Guard Elimination September 13, L04-16

Guards vs If’s A guard on one action of a parallel group of actions affects every action within the group (a1 when p1); a2 ==> (a1; a2) when p1 A condition of a Conditional action only affects the actions within the scope of the conditional action (if (p1) a1); a2 p1 has no effect on a2... Mixing ifs and whens (if (p) (a1 when q)) ; a2  ((if (p) a1); a2) when ((p && q) | !p)  ((if (p) a1); a2) when (q | !p) September 13,

Method calls have implicit guards Every method call, except the primitive method calls, i.e., x,r, x.w, has an implicit guard associated with it m.enq(x), the guard indicated whether one can enqueue into fifo m or not Make the guards explicit in every method call by naming the guard and separating it from the unguarded body of the method call, i.e., syntactically replace m.g(e) by m.g B (e) when m.g G Notice m.g G has no parameter because the guard value should not depend upon the input September 13,

Make implicit guards explicit ::= x.w( ) | ; | if ( ) | m.g( ) | let t = in | when m.g B ( ) when m.g G ::= ; | if ( ) | m.g( ) | let t = in | when methods without guards The new kernel language September 13,

Lifting implicit guards rule foo if (True); (if (p) fifo.enq(8)); x.w(7) rule foo if (fifo.enq G | !p); if (p) fifo.enq B (8); x.w(7) All implicit guards are made explicit, and lifted and conjoined to the rule guard September 13,

Guard Lifting Axioms without Let-blocks All the guards can be “lifted” to the top of a rule (a1 when p) ; a2 a1 ; (a2 when p) if (p when q) a if (p) (a when q) (a when p1) when p2 m.g B (e when p) similarly for expressions... Rule r (a when p) (a1 ; a2) when p (if (p) a) when q (if (p) a) when (q | !p) a when (p1 & p2) m.g B (e) when p Rule r (if (p) a) We will call this guard lifting transformation WIF, for when-to-if A complete guard lifting procedure also requires rules for let-blocks September 13,

Optional: A complete procedure for guard lifting September 13, 2013L

Let-blocks: Variable names and guards let t = e in f(t) Since e can have a guard, a variable name, t, can also have an implicit guard Essentially every expression has two parts: unguarded and guarded and consequently t has two parts t B and t G Each use of the variable name has to be replaced by (t B when t G ) September 13,

Lift procedure Bindings is a collection of (t,e) pairs where e is restricted to be c | x.r | t | op(t,t) | m.h(t) | {body: t, guard: t} The bindings of the type (t, {body:tx, guard:ty}) are not needed after When Lifting because all such t’s would have been eliminated from the returned expressions LWE :: (Bindings, Exp) -> (Bindings, Exp B, Exp G ) LW :: (Bindings, Exp) -> (Bindings, Action B, Exp G ) Returned exp, actions and bindings are all free of when’s September 13,

Bindings The bindings that LW and LWE return are simply a collection of (t,e) pairs where e is restricted to be c | x.r | x.r0| x.r1 | t | op(t,t) | m.h(t) | {body: t, guard: t} The bindings of the type (t, {body:tx, guard:ty}) are not needed after When Lifting because all such t’s would have been eliminated from the returned expressions September 13,

LWE: procedure for lifting when’s in expressions LWE (bs, [[c]])= (bs, c, T) ; LWE (bs, [[x.r]]) = (bs, x.r, T) LWE (bs, [[x.r0]]) = (bs, x.r0, T); LWE (bs, [[x.r1]]) = (bs, x.r1, T) LWE (bs, [[t]])= (bs, bs[t].body, bs[t].guard) LWE (bs, [[Op(e1,e2)]]) = {bs1, t1 B, t1 G = LWE(bs, [[e1]]); bs2, t2 B, t2 G = LWE(bs1, [[e2]]); return bs2, Op(t1 B, t2 B ), (t1 G &t2 G )} LWE(bs, [[m.h(e)]]) = {bs1, t B, t G = LWE(bs, [[e]]); return bs1, m.h B (t B ), (t G &m.h G )} LWE (bs, [[e1 when e2]]) = {bs1, t1 B, t1 G = LWE(bs, [[e1]]); bs2, t2 B, t2 G = LWE(bs1, [[e2]]); bs3 = bs2+(tx, t2 B &t2 G ) return bs3, t1 B, (tx&t1 G )} LWE(bs, [[let t=e1 in e2]]) = {bs1, t B, t G = LWE(bs, [[e1]]); bs2 = bs1+(tx,t B )+(ty,t G ) +(t,{body:tx,guard:ty}) return LWE(bs2, [[e2]]} LWE :: (Bindings, Exp) -> (Bindings, Exp B, Exp G ) tx, ty are new variable September 13,

LW: procedure for lifting when’s in actions LW (bs, [[x.w(e)]]) = {bs1, t B, t G = LWE(bs, [[e]]); return bs1, x.w(t B ), t G } LW (bs, [[m.g(e)]]) = {bs1, t B, t G = LWE(bs, [[e]]); return bs1, m.g B (t B ), (t G &m.g G )} LW (bs, [[a1;a2]]) = {bs1, a1 B, g1 = LW(bs, [[a1]]); bs2, a2 B, g2 = LW(bs1, [[a2]]); return bs2, (a1 B ; a2 B ), (g1&g2)} LW (bs, [[if (e) a]]) = {bs1, t B, t G = LWE(bs, [[e]]); bs2, a B, g = LW(bs1, [[a]]); bs3 = bs2+(tx,t B )+(ty,t G ) return bs3, a B, (g | !tx) & ty)} LW (bs, [[a when e]]) = {bs1, t B, t G = LWE(bs, [[e]]); bs2, a B, g = LW(bs1, [[a]]); return bs2+(tx, t B &t G ), a B, (tx&g)} LW(bs, [[let t=e in a]]) = {bs1, t B, t G = LWE(bs, [[e]]); bs2 = bs1+(tx,t B )+(ty,t G ) +(t,{body:tx,guard:ty}) return LW(bs2, [[a]]} LW :: (Bindings, Exp) -> (Bindings, Action B, Exp G ) tx, ty are new variable September 13,

WIF: when-to-if transformation Given rule ra a, WIF(ra) returns rule ra (let bs in (if (g) a B )) assuming LW({}, a) returns (bs, a B, g) Notice, WIF(ra) has no when’s WIF(a1;a2) ≠ (WIF(a1);WIF(a2)) September 13,