6.375 Tutorial 2 Guards and Scheduling Ming Liu

Slides:



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

Simulation executable (simv)
Elastic Pipelines and Basics of Multi-rule Systems Arvind Computer Science & Artificial Intelligence Lab Massachusetts Institute of Technology February.
© 2003 Xilinx, Inc. All Rights Reserved Looking Under the Hood.
Overview Logistics Last lecture Today HW5 due today
Asynchronous Pipelines: Concurrency Issues Arvind Computer Science & Artificial Intelligence Lab Massachusetts Institute of Technology October 13, 2009http://csg.csail.mit.edu/koreaL12-1.
December 10, 2009 L29-1 The Semantics of Bluespec Arvind Computer Science & Artificial Intelligence Lab Massachusetts Institute.
ECE 2372 Modern Digital System Design
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.
1 Workshop Topics - Outline Workshop 1 - Introduction Workshop 2 - module instantiation Workshop 3 - Lexical conventions Workshop 4 - Value Logic System.
1 Workshop Topics - Outline Workshop 1 - Introduction Workshop 2 - module instantiation Workshop 3 - Lexical conventions Workshop 4 - Value Logic System.
Constructive Computer Architecture Tutorial 3 Debugging BSV Andy Wright TA September12, 2014http://csg.csail.mit.edu/6.175T01-1.
Anurag Dwivedi. Basic Block - Gates Gates -> Flip Flops.
Oct 2, 2014T01-1http://csg.csail.mit.edu/6.175 Constructive Computer Architecture Tutorial 1 BSV Sizhuo Zhang TA.
Constructive Computer Architecture: Guards Arvind Computer Science & Artificial Intelligence Lab. Massachusetts Institute of Technology September 24, 2014.
Constructive Computer Architecture Tutorial 2 Advanced BSV Sizhuo Zhang TA Oct 9, 2015T02-1http://csg.csail.mit.edu/6.175.
Constructive Computer Architecture Tutorial 4 Debugging Sizhuo Zhang TA Oct 23, 2015T04-1http://csg.csail.mit.edu/6.175.
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.
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 Tutorial 4: Running and Debugging SMIPS Andy Wright TA October 10, 2014http://csg.csail.mit.edu/6.175T04-1.
Constructive Computer Architecture Sequential Circuits Arvind Computer Science & Artificial Intelligence Lab. Massachusetts Institute of Technology September.
Constructive Computer Architecture Sequential Circuits - 2 Arvind Computer Science & Artificial Intelligence Lab. Massachusetts Institute of Technology.
February 20, 2009http://csg.csail.mit.edu/6.375L08-1 Asynchronous Pipelines: Concurrency Issues Arvind Computer Science & Artificial Intelligence Lab Massachusetts.
March 1, 2006http://csg.csail.mit.edu/6.375/L09-1 Bluespec-3: Architecture exploration using static elaboration Arvind Computer Science & Artificial Intelligence.
Introduction to Bluespec: A new methodology for designing Hardware Arvind Computer Science & Artificial Intelligence Lab. Massachusetts Institute of Technology.
6.375 Tutorial 3 Scheduling, Sce-Mi & FPGA Tools Ming Liu
Computer Architecture: A Constructive Approach Bluespec execution model and concurrent rule scheduling Teacher: Yoav Etsion Taken (with permission) from.
Overview Logistics Last lecture Today HW5 due today
Functions and Types in Bluespec
Concurrency properties of BSV methods and rules
Digital System Verification
Variables, Environments and Closures
Scheduling Constraints on Interface methods
Sequential Circuits: Constructive Computer Architecture
BSV Tutorial 1 Ming Liu Feb 12, 2016
Stmt FSM Arvind (with the help of Nirav Dave)
Combinational Circuits in Bluespec
Pipelining combinational circuits
Multirule Systems and Concurrent Execution of Rules
Constructive Computer Architecture: Lab Comments & RISCV
Constructive Computer Architecture: Guards
BSV Types Constructive Computer Architecture Tutorial 1 Andy Wright
Variables In programming, we often need to have places to store data. These receptacles are called variables. They are called that because they can change.
Chapter 11 Introduction to Programming in C
Pipelining combinational circuits
BSV objects and a tour of known BSV problems
EHR: Ephemeral History Register
Debugging BSV and Typeclasses. Constructive Computer Architecture
Module 2: Understanding C# Language Fundamentals
Modules with Guarded Interfaces
Pipelining combinational circuits
Sequential Circuits - 2 Constructive Computer Architecture Arvind
6.375 Tutorial 5 RISC-V 6-Stage with Caches Ming Liu
PHP.
Stmt FSM Arvind (with the help of Nirav Dave)
Computer Science & Artificial Intelligence Lab.
Constructive Computer Architecture: Guards
GCD: A simple example to introduce Bluespec
Multirule systems and Concurrent Execution of Rules
Introduction to Bluespec: A new methodology for designing Hardware
The Verilog Hardware Description Language
Bluespec-5: Scheduling & Rule Composition
Introduction to Verilog – Part-2 Procedural Statements
CS295: Modern Systems Bluespec Introduction
CSE 206 Course Review.
CS295: Modern Systems Bluespec Introduction – More Topics
Presentation transcript:

6.375 Tutorial 2 Guards and Scheduling Ming Liu Feb 19, 2016 http://csg.csail.mit.edu/6.375

Overview BSV reviews/notes Guard lifting EHRs Scheduling Lab 3 Feb 19, 2016 http://csg.csail.mit.edu/6.375

Expressions vs. Actions Have no side effects (state changes) Can be used outside of rules and modules in assignments Actions Can have side effects Can only take effect when used inside of rules Can be found in other places intended to be called from rules Action/ActionValue methods functions that return actions Feb 19, 2016 http://csg.csail.mit.edu/6.375

Variable vs. States Variables are used to name intermediate values Do not hold values over time Variable are bound to values Statically elaborated Bit#(32) firstElem = aQ.first(); rule process; aReg <= firstElem; endrule Feb 19, 2016 http://csg.csail.mit.edu/6.375

Scoping Any use of an identifier refers to its declaration in the nearest textually surrounding scope module mkShift( Shift#(a) ); function Bit#(32) f(); return fromInteger(valueOf(a))<<2; endfunction rule process; aReg <= f(); endrule endmodule Bit#(32) a = 1; rule process; aReg <= a; endrule Functions can take variables from surrounding scope Feb 19, 2016 http://csg.csail.mit.edu/6.375

Guard Lifting Last Time: implicit/explicit guards But there is more to it when there are conditionals (if/else) within a rule Compiler option -aggressive-conditions tells the compiler to peek into the rule to generate more aggressive enable signals Almost always used Feb 19, 2016 http://csg.csail.mit.edu/6.375

Guard Examples rule process; rule process; aQ.deq(); if (aReg==True) $display(“fire”); endrule rule process; if (aReg==True) aQ.deq(); else bQ.deq(); $display(“fire”); endrule rule process; if (aQ.notEmpty) aQ.deq(); $display(“fire”); endrule (aReg==True && aQ.notEmpty) || (aReg==False && bQ.notEmpty) || (aQ.notEmpty && aQ.notEmpty) || (!aQ.notEmpty)  Always fires Feb 19, 2016 http://csg.csail.mit.edu/6.375

Ephemeral History Register (EHR) D Q 1 w[0].data w[0].en r[0] normal bypass r[1] w[1].data w[1].en r[0] < w[0] r[1] < w[1] w[0] < w[1] < …. Encode a notion of “priority” when there are concurrent writes/reads Feb 19, 2016 http://csg.csail.mit.edu/6.375

Design Example An Up/Down Counter Feb 19, 2016 http://csg.csail.mit.edu/6.375

Up/Down Counter Design example Some modules have inherently conflicting methods that need to be concurrent This example will show a couple of ways to handle it interface Counter; Bit#(8) read; Action increment; Action decrement; endinterface Inherently conflicting Feb 19, 2016 http://csg.csail.mit.edu/6.375

Up/Down Counter Conflicting design module mkCounter( Counter ); Reg#(Bit#(8)) count <- mkReg(0); method Bit#(8) read; return count; endmethod method Action increment; count <= count + 1; method Action decrement; count <= count – 1; endmodule Can’t fire in the same cycle Feb 19, 2016 http://csg.csail.mit.edu/6.375

Up/Down Counter Conflicting design +1 D Q read -1 incr.en || decr.en Feb 19, 2016 http://csg.csail.mit.edu/6.375

Concurrent Design A general technique Replace conflicting registers with EHRs Choose an order for the methods Assign ports of the EHR sequentially to the methods depending on the desired schedule Feb 19, 2016 http://csg.csail.mit.edu/6.375

Up/Down Counter Concurrent design: read < inc < dec module mkCounter( Counter ); Ehr#(2, Bit#(8)) count <- mkEhr(0); method Bit#(8) read; return count[0]; endmethod method Action increment; count[0] <= count[0] + 1; method Action decrement; count[1] <= count[1] – 1; endmodule Feb 19, 2016 http://csg.csail.mit.edu/6.375

Up/Down Counter Concurrent design: read < inc < dec +1 D Q 1 incr.en read decr.en -1 Feb 19, 2016 http://csg.csail.mit.edu/6.375

Up/Down Counter Concurrent design: read < inc < dec +1 1 read D Q incr.en 1 decr.en -1 Feb 19, 2016 http://csg.csail.mit.edu/6.375

Valid Concurrent Rules A set of rules ri can fire concurrently if there exists a total order between the rules such that all the method calls within each of the rules can happen in that given order Rules r1, r2, r3 can fire concurrently if there is an order ri, rj, rk such that ri < rj, rj < rk, and ri < rk are all valid Feb 19, 2016 http://csg.csail.mit.edu/6.375

Concurrent rule firing Rules Ri Rj Rk rule steps Rj HW Rk clocks Ri Concurrently executable rules are scheduled to fire in the same cycle In HW, states change only at clock edges Feb 19, 2016 http://csg.csail.mit.edu/6.375

Rule Scheduling Intuitions Can these rules fire in the same cycle? rule r1 (a); x <= 1; endrule rule r2 (!a); x <= 2; No, guards are mutually exclusive Feb 19, 2016 http://csg.csail.mit.edu/6.375

Rule Scheduling Intuitions Can these rules fire in the same cycle? rule r1; y <= 1; endrule rule r2; x <= 1; Yes, methods are unrelated (conflict free) Feb 19, 2016 http://csg.csail.mit.edu/6.375

Rule Scheduling Intuitions Is it legal? Can these rules fire in the same cycle? rule increment; x <= x + 1; endrule rule decrement; x <= x - 1; Calls x._read() and x._write() Calls x._read() and x._write() increment C decrement, so the two rules will never fire in parallel Feb 19, 2016 http://csg.csail.mit.edu/6.375

Rule Scheduling Intuitions Can these rules fire in the same cycle? rule r1; x <= y; endrule rule r2; y <= x; Calls y._read() and x._write() Calls x._read() and y._write() r1 C r2, so the two rules will never fire in parallel Feb 19, 2016 http://csg.csail.mit.edu/6.375

Lab 3: Overview Completing the audio pipeline: PitchAdjust FromMP, ToMP Feb 19, 2016 http://csg.csail.mit.edu/6.375

Converting C to Hardware Think about what states you need to keep Loops in C are sequentially executed; loops in BSV are statically elaborated Unrolled Feb 19, 2016 http://csg.csail.mit.edu/6.375

Fixed Point typedef struct { Bit#(isize) i; Bit#(fsize) f; } FixedPoint#(numeric type isize, numeric type fsize ) Feb 19, 2016 http://csg.csail.mit.edu/6.375

Fixed Point Arithmetic Useful FixedPoint functions: fxptGetInt: extracts integer portion fxptMult: full precision multiply *: full multiply followed by rounding/saturation to the output size Other useful bit-wise functions: truncate, truncateLSB zeroExtend, extend Feb 19, 2016 http://csg.csail.mit.edu/6.375

BSV Debugging Display Statements See a bug, not sure what causes it Add display statements Recompile Run Still see bug, but you have narrowed it down to a smaller portion of code Repeat with more display statements… Find bug, fix bug, and remove display statements Feb 19, 2016 http://csg.csail.mit.edu/6.375

BSV Display Statements The $display() command is an action that prints statements to the simulation console Examples: $display(“Hello World!”); $display(“The value of x is %d”, x); $display(“The value of y is “, fshow(y)); Feb 19, 2016 http://csg.csail.mit.edu/6.375

Ways to Display Values Format Specifiers %d – decimal %b – binary %o – octal %h – hexadecimal %0d, %0b, %0o, %0h Show value without extra whitespace padding Feb 19, 2016 http://csg.csail.mit.edu/6.375

Ways to Display Values fshow fshow is a function in the FShow typeclass It can be derived for enumerations and structures FixedPoint is also a FShow typeclass Example: typedef emun {Red, Blue} Colors deriving(FShow); Color c = Red; $display(“c is “, fshow(c)); Prints “c is Red” Feb 19, 2016 http://csg.csail.mit.edu/6.375

Warning about $display $display is an Action within a rule Guarded methods called by $display will be part of implicit guard of rule rule process; if (aQ.notEmpty) aQ.deq(); $display(“first elem is %x”, aQ.first); endrule Feb 19, 2016 http://csg.csail.mit.edu/6.375

Extra Stuff Feb 19, 2016 http://csg.csail.mit.edu/6.375

BSV Debugging Waveform Viewer Simulation executables can dump VCD waveforms ./simMyTest –V test.vcd Produces test.vcd containing the values of all the signals used in the simulator Not the same as normal BSV signals VCD files can be viewed by a waveform viewer Such as gtkwave The signal names and values in test.vcd can be hard to understand Especially for structures and enumerations Feb 19, 2016 http://csg.csail.mit.edu/6.375

Step 1 Generate VCD File Run ./simTestName -V test.vcd Feb 19, 2016 http://csg.csail.mit.edu/6.375

Step 2 Open Bluespec GUI Run “bluespec fifo.bspec” Note, to run the GUI remotely, you need to SSH into the servers with the “ssh –X” command For the fifo lab, fifo.bspec can be found in Feb 19, 2016 http://csg.csail.mit.edu/6.375

Step 3 Set top module name Open project options Feb 19, 2016 http://csg.csail.mit.edu/6.375

Step 3 Set top module name Set the top module name to match the compiled module in TestBench.bsv Feb 19, 2016 http://csg.csail.mit.edu/6.375

Step 4 Open Module Viewer Feb 19, 2016 http://csg.csail.mit.edu/6.375

Step 4 Open Module Viewer Feb 19, 2016 http://csg.csail.mit.edu/6.375

Step 5 Open Wave Viewer Feb 19, 2016 http://csg.csail.mit.edu/6.375

Step 5 Open Wave Viewer Feb 19, 2016 http://csg.csail.mit.edu/6.375

Step 6 Open Wave Viewer Feb 19, 2016 http://csg.csail.mit.edu/6.375

Step 6 Add Some Signals Feb 19, 2016 http://csg.csail.mit.edu/6.375

Step 6 Add Some Signals Signals Module Hierarchy Feb 19, 2016 http://csg.csail.mit.edu/6.375

Step 7 Look at the Waveforms Feb 19, 2016 http://csg.csail.mit.edu/6.375

Step 7 Look at the Waveforms Types Human readable value names Feb 19, 2016 http://csg.csail.mit.edu/6.375

Step 7 Look at the Waveforms Feb 19, 2016 http://csg.csail.mit.edu/6.375

Step 8 Add Some More Signals Feb 19, 2016 http://csg.csail.mit.edu/6.375

Step 8 Add Some More Signals Feb 19, 2016 http://csg.csail.mit.edu/6.375

Step 9 Add Rules Too Feb 19, 2016 http://csg.csail.mit.edu/6.375

Step 9 Add Rules Too Feb 19, 2016 http://csg.csail.mit.edu/6.375