Bluespec-7: Semantics of Bluespec

Slides:



Advertisements
Similar presentations
Chapter 13 Control Structures. Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display Control Structures Conditional.
Advertisements

ICE1341 Programming Languages Spring 2005 Lecture #13 Lecture #13 In-Young Ko iko.AT. icu.ac.kr iko.AT. icu.ac.kr Information and Communications University.
Models of Concurrency Manna, Pnueli.
Elastic Pipelines and Basics of Multi-rule Systems Arvind Computer Science & Artificial Intelligence Lab Massachusetts Institute of Technology February.
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.
COMPILERS Basic Blocks and Traces hussein suleman uct csc3005h 2006.
Combinational Circuits in Bluespec
Propositional Calculus Math Foundations of Computer Science.
PPL Syntax & Formal Semantics Lecture Notes: Chapter 2.
December 10, 2009 L29-1 The Semantics of Bluespec Arvind Computer Science & Artificial Intelligence Lab Massachusetts Institute.
Systems Architecture I1 Propositional Calculus Objective: To provide students with the concepts and techniques from propositional calculus so that they.
December 12, 2006http://csg.csail.mit.edu/6.827/L24-1 Scheduling Primitives for Bluespec Arvind Computer Science & Artificial Intelligence Lab Massachusetts.
CPS120: Introduction to Computer Science Decision Making in Programs.
Constructive Computer Architecture: Bluespec execution model and concurrency semantics Arvind Computer Science & Artificial Intelligence Lab. Massachusetts.
Computer Science 210 Computer Organization Introduction to Boolean Algebra.
Propositional Calculus CS 270: Mathematical Foundations of Computer Science Jeremy Johnson.
March, 2007Intro-1http://csg.csail.mit.edu/arvind Design methods to facilitate rapid growth of SoCs Arvind Computer Science & Artificial Intelligence Lab.
PPL Applicative and Normal Form Verification, Type Checking and Inference.
SE424 Languages with Context A Block Structured Language.
Constructive Computer Architecture: Guards Arvind Computer Science & Artificial Intelligence Lab. Massachusetts Institute of Technology September 24, 2014.
Constructive Computer Architecture Sequential Circuits Arvind Computer Science & Artificial Intelligence Lab. Massachusetts Institute of Technology
CPS120: Introduction to Computer Science Decision Making in Programs.
Constructive Computer Architecture Sequential Circuits - 2 Arvind Computer Science & Artificial Intelligence Lab. Massachusetts Institute of Technology.
Arvind Computer Science and Artificial Intelligence Laboratory M.I.T. L04Ext-1 September 21, 2006http:// Some more thoughts.
ECE DIGITAL LOGIC LECTURE 6: BOOLEAN ALGEBRA Assistant Prof. Fareena Saqib Florida Institute of Technology Fall 2016, 02/01/2016.
Operational Semantics Mooly Sagiv Reference: Semantics with Applications Chapter 2 H. Nielson and F. Nielson
PPL Syntax & Formal Semantics Lecture Notes: Chapter 2.
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.
Artificial Intelligence and Lisp Lecture 6 LiU Course TDDC65 Autumn Semester,
CS314 – Section 5 Recitation 9
Hoda Roodaki Boolean Algebra Hoda Roodaki
Control Structures I Chapter 3
Boolean Algebra & Logic Gates
CS 550 Programming Languages Jeremy Johnson
Concurrency properties of BSV methods and rules
Decisions Chapter 4.
Scheduling Constraints on Interface methods
Sequential Circuits - 2 Constructive Computer Architecture Arvind
Sequential Circuits Constructive Computer Architecture Arvind
Functional Programming Lecture 2 - Functions
Multirule Systems and Concurrent Execution of Rules
Constructive Computer Architecture: Guards
Propositional Calculus: Boolean Algebra and Simplification
Sequential Circuits Constructive Computer Architecture Arvind
3-3 Side Effects A side effect is an action that results from the evaluation of an expression. For example, in an assignment, C first evaluates the expression.
Constructive Computer Architecture: Well formed BSV programs
Boolean Algebra.
3-3 Side Effects A side effect is an action that results from the evaluation of an expression. For example, in an assignment, C first evaluates the expression.
FP Foundations, Scheme In Text: Chapter 14.
Modules with Guarded Interfaces
Sequential Circuits - 2 Constructive Computer Architecture Arvind
A-calculus with Constants and Let-blocks
Propositional Equivalences
Multirule systems and Concurrent Execution of Rules
Constructive Computer Architecture: Guards
Statement-Level Control Structures
CS 1111 Introduction to Programming Spring 2019
Simple Synchronous Pipelines
Logic of an if statement
Multirule systems and Concurrent Execution of Rules
Introduction to Bluespec: A new methodology for designing Hardware
Chapter8: Statement-Level Control Structures April 9, 2019
Constructive Computer Architecture: Well formed BSV programs
Chapter 7: Expressions and Assignment Statements Sangho Ha
Simple Synchronous Pipelines
Introduction to the Lab
Functional Programming Lecture 2 - Functions
Representations & Reasoning Systems (RRS) (2.2)
Presentation transcript:

Bluespec-7: Semantics of Bluespec Arvind Computer Science & Artificial Intelligence Lab Massachusetts Institute of Technology March 13, 2006 http://csg.csail.mit.edu/6.375/

Topics Guarded actions versus Conditional actions Naming expressions: the “let” statement Modules and methods with implicit conditions Rule composition March 13, 2006 http://csg.csail.mit.edu/6.375/

BS0 : A simple language of Guarded Atomic Actions action a is guarded by predicate e a is an Action; e is an Expression; r is a register (state variable) a ::= r := e | a when e | if e then a | a ; a e ::= r | c | Op(e , e ) | e ? e : e | e when e | ... “;” is commutative and associative, i.e. a1;a2 = a2;a1 a1;(a2;a3) = (a1;a2);a3 conditional action compound atomic action conditional expression guarded expression March 13, 2006 http://csg.csail.mit.edu/6.375/

BS0 Program A program is a collection of registers and rules: R, R1, R2, ... are names for rules; r, r1, r2, ... are register names Program ::= Registers r1, ..., ; Rule R1 a1; ... ; Rule Rm am ; a ::= r := e | a when e | if e then a | a ; a e ::= r | c | Op(ra , rb ) | e ? e : e | e when e | ... March 13, 2006 http://csg.csail.mit.edu/6.375/

Guards vs If’s A guard on one action of a group of actions affects every action within the group (a1 when p1); (a2 when p2) ==> (a1; a2) when p1 & p2 A condition of a Conditional action only affects the actions within the scope of the conditional action (if p1 then a1); (if p2 then a2) p1 has no effect on a2 ... March 13, 2006 http://csg.csail.mit.edu/6.375/

Canonicalizing BS0 ignoring guards on expressions Rules for canonicalization: 1. (a1 when p); a2 ==> (a1; a2) when p 2. (a when p1) when p2 ==> a when (p1 & p2) 3. if p then (a when q) ==> (if p then a) when (p&q | !p) March 13, 2006 http://csg.csail.mit.edu/6.375/

Conditionals & Cases if p then a1 else a2 = if p then a1; if !p then a2 Similarly for cases March 13, 2006 http://csg.csail.mit.edu/6.375/

BS0 : Canonical form In the canonical form, expressions have no guards and an (or a compound) action has at most one guard and it occurs at the top level; ag is an Action with guard a is an Action without guard; e is an Expression; r is a register (state variable) ag::= a when e a ::= r := e | if e then a | a ; a e ::= r | c | Op(e , e ) | e ? e : e | ... move all the guards to the top level March 13, 2006 http://csg.csail.mit.edu/6.375/

Rules for Canonicalizing BS0 1. (a1 when p); a2 ==> (a1; a2) when p 2.1 (a when p) when q ==> a when (p & q) 2.2 (e when p) when q ==> e when (p & q) 3.1 if p then (a when q) ==> (if p then a) when (p&q | !p) 3.2 p ? (e1 when q) : e2 ==> (p ? e1 : e2) when (p&q | !p) 3.3 p ? e1 : (e2 when q) ==> (p ? e1 : e2) when (p | !p&q) 4 r := (e when q) ==> (r := e) when q 5.1 Op(e1 when q, e2) ==> Op(e1,e2) when q 5.2 Op(e1, e2 when q) ==> Op(e1,e2) when q 5.3 if (p when q) then a ==> (if p then a) when q 5.4 (p when q)? e1 : e2 ==> (p ? e1 : e2) when q Theorem: Canonical form for an action exists and is unique up to the boolean simplification of the guard expression. March 13, 2006 http://csg.csail.mit.edu/6.375/

BS1 = BS0 + Let blocks Introducing local names t, t1, t2, ... are identifiers (not registers) Program ::= Registers r1, ..., ; t1 = e1; ...; tn = en; Rule R1 a1; ... ; Rule Rm am ; a ::= r := e | a when e | if e then a | a ; a | (t1 = e1; ...; tn = en; in a) e ::= r | c | Op(ra , rb ) | e ? e : e | e when e | ... | t | (t1 = e1; ...; tn = en; in e) March 13, 2006 http://csg.csail.mit.edu/6.375/

BS1 Lifting rules Unique local names (t1, t2, ...) can be introduced anywhere for sharing e ==> (t = e in t) Lifting rules for actions r:= (t = e in e’) ==> (t = e in r:=e’) a when (t = e in e’) ==> (t = e in (a when e’)) (t = e in (e’ when p)) ==> (t = e in e’) when p if (t=e in p) then e1 ==> (t = e in (if p then e1)) (t = e in a1); a2 ==> (t = e in (a1;a2)) (t1 = e1 in (t2 = e2 in a)) ==> (t1 = e1; t2 = e2 in a) Some renaming of local variables may be required Substitution & when clauses (t=e when p in e’) ==> (t = e; t1 = p in [(t when t1)/t]e’) Lifting rules for expressions are similar March 13, 2006 http://csg.csail.mit.edu/6.375/

Lifting lets to the top level Registers r1, ..., ; t1 = e1; ...; tn = en; Rule R1 a1; ... ; Rule Rm am ; Rule Ri (ti1 = ei1; ...; tin = ein; in ai) ==> Registers r1, ..., ; t1 = e1 ; ...; tn = en ; ti1 = ei1; ...; tin = ein; Rule Ri ai Some renaming of local variables may be required March 13, 2006 http://csg.csail.mit.edu/6.375/

BS1: Canonical form Program ::= Registers r1, ..., ; t1 = e1; ...; tn = en; Rule R1 ac1; ... ; Rule Rm acm ; ac ::= (t1 = e1; ...; tn = en; in aw) ac’::= (t1 = e1; ...; tn = en; in a) aw ::= a | a when e a ::= r := e | if e then ac’ | a ; a ec ::= (t1 = e1; ...; tn = en; in ew) ec’::= (t1 = e1; ...; tn = en; in e) ew::= e | e when p e ::= r | c | Op(ra , rb ) | e ? ec’ : ec’... | t March 13, 2006 http://csg.csail.mit.edu/6.375/

BS2 = BS1 + Modules A program is a collection of (instantiated) modules m, m1,...; A module is a collection of rules and interface methods f, f1, f2, ... are names for “read methods” g, g1, g2, ... are names for “action methods” a ::= r := e | a when e | if e then a | a ; a | (t = e in a) | m.g(e) e ::= r | c | Op(ra , rb ) | e ? e : e | ... | e when e | t | (t = e in e) | m.f(e) March 13, 2006 http://csg.csail.mit.edu/6.375/

BS2 Program A program is a collection of instantiated modules: Program ::= m1 ; m2 ; m2 ; ... Module ::= Module name [Register r] [Rule R a]; Interface Interface ::= [action method]; [read method] action method ::= method g (x) = a read method ::= method f (x) = e March 13, 2006 http://csg.csail.mit.edu/6.375/

Implicit conditions Every method has two parts: guard and body. These will be designated by subscripts G and B, respectively Making guards explicit in every method call: m.h(e) ==> (p = m.hG in m.hB(e) when p) March 13, 2006 http://csg.csail.mit.edu/6.375/

BS2 : Additional Lifting rules Only read methods can be named in a let block m.f(e) ==> (t=m.f(e) in t) m.g (t = e in e’) ==> (t = e in m.g(e’)) m.g (e when p) ==> m.g(e) when p similar rules for read methods March 13, 2006 http://csg.csail.mit.edu/6.375/

Some subtle issues Does it matter if we first make the guards explicit and then lift or can we lift at any stage? March 13, 2006 http://csg.csail.mit.edu/6.375/

BS2 : Canonicalization procedure Make guards of method calls explicit Lift lets to the top Get rid of the whens from the lets Lift whens to the top March 13, 2006 http://csg.csail.mit.edu/6.375/

Getting ready for circuit generation We need to collect multiple conditional assignments to one register in one expression, i.e., ... if p1 then r:= e1; if p2 then r:= e2; (r:= p3? e4: e5); ... March 13, 2006 http://csg.csail.mit.edu/6.375/

Notation for conditional assignment r:= e1.p1 + ... + en.pn where - e1, e2, ... are expressions - p1, p2, ... are booleans e.p evaluates to e if p is true otherwise to False (zero’s) if pi’s are not pairwise mutually exclusive then the program is illegal e1.p1 + ... + en.pn evaluates to some ei or if all pis are false then the value of r does not change March 13, 2006 http://csg.csail.mit.edu/6.375/

Collecting conditional assignments to a register Apply the following rules after the guards have been made explicit and the program has been canonicalized, 1. if p then a ==> a . p 2.1 (r := e) . p ==> r := e . p 2.2 m.g(e) . p ==> m.g (e . p) 3. (a1; a2) . p ==> a1 . p ; a2 . p 4.1 r := e1 ; r := e2 ==> r := e1 + e2 4.2 m.g(e1); m.g(e2) ==> m.g(e1 + e2) Theorem: After applying the above rules to a Program in canonical form any action in it will be reduced the following form: r1 := e1; r2 := e2; .... m.g(e); m1.g1(e1); ... where e’s may contain “.” and “+” March 13, 2006 http://csg.csail.mit.edu/6.375/