Sequential Circuits - 2 Constructive Computer Architecture Arvind

Slides:



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

March, 2007http://csg.csail.mit.edu/arvind802.11a-1 Architectural Exploration: Area-Performance tradeoff in a Transmitter Arvind Computer Science.
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.
Folding and Pipelining complex combinational circuits Arvind Computer Science & Artificial Intelligence Lab Massachusetts Institute of Technology February.
1 EECS Components and Design Techniques for Digital Systems Lec 21 – RTL Design Optimization 11/16/2004 David Culler Electrical Engineering and Computer.
Stmt FSM Richard S. Uhler Computer Science & Artificial Intelligence Lab Massachusetts Institute of Technology (based on a lecture prepared by Arvind)
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.
Computer Architecture: A Constructive Approach Sequential Circuits Arvind Computer Science & Artificial Intelligence Lab. Massachusetts Institute of Technology.
Pipelining combinational circuits Arvind Computer Science & Artificial Intelligence Lab. Massachusetts Institute of Technology February 20, 2013http://csg.csail.mit.edu/6.375L05-1.
February 14, 2007L04-1http://csg.csail.mit.edu/6.375/ Bluespec-1: Design methods to facilitate rapid growth of SoCs Arvind Computer Science & Artificial.
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 Combinational circuits-2 Arvind Computer Science & Artificial Intelligence Lab. Massachusetts Institute of Technology.
Folded Combinational Circuits as an example of Sequential 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.
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
Folding complex combinational circuits to save area Arvind Computer Science & Artificial Intelligence Lab Massachusetts Institute of Technology February.
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.
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.
Simple Inelastic and Folded Pipelines Arvind Computer Science & Artificial Intelligence Lab Massachusetts Institute of Technology February 14, 2011L04-1.
Multiple Clock Domains (MCD) Arvind with Nirav Dave Computer Science & Artificial Intelligence Lab Massachusetts Institute of Technology.
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
Folded Combinational Circuits as an example of Sequential Circuits
Bluespec-6: Modeling Processors
Folded “Combinational” circuits
Scheduling Constraints on Interface methods
Sequential Circuits - 2 Constructive Computer Architecture Arvind
EKT 221 : Digital 2 Serial Transfers & Microoperations
Sequential Circuits Constructive Computer Architecture Arvind
Sequential Circuits: Constructive Computer Architecture
Combinational ALU Constructive Computer Architecture Arvind
Combinational circuits-2
Stmt FSM Arvind (with the help of Nirav Dave)
Performance Specifications
Pipelining combinational circuits
Multirule Systems and Concurrent Execution of Rules
Constructive Computer Architecture: Guards
BSV Types Constructive Computer Architecture Tutorial 1 Andy Wright
Sequential Circuits Constructive Computer Architecture Arvind
Pipelining combinational circuits
BSV objects and a tour of known BSV problems
EHR: Ephemeral History Register
Constructive Computer Architecture: Well formed BSV programs
Combinational circuits
Modules with Guarded Interfaces
Pipelining combinational circuits
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)
Constructive Computer Architecture: Guards
Elastic Pipelines and Basics of Multi-rule Systems
Control Hazards Constructive Computer Architecture: Arvind
Simple Synchronous Pipelines
Design methods to facilitate rapid growth of SoCs
Multirule systems and Concurrent Execution of Rules
Introduction to Bluespec: A new methodology for designing Hardware
Pipelining combinational circuits
Constructive Computer Architecture: Well formed BSV programs
Simple Synchronous Pipelines
Combinational ALU 6.S078 - Computer Architecture:
Constructive Computer Architecture Tutorial 1 Andy Wright 6.S195 TA
Presentation transcript:

Sequential Circuits - 2 Constructive Computer Architecture Arvind Computer Science & Artificial Intelligence Lab. Massachusetts Institute of Technology (Andy) Changed course website to correct website September 16, 2016 http://csg.csail.mit.edu/6.175

Content So far we have seen modules with methods which are called by rules outside the body Now we will see examples where a module may also contain rules gcd A common way to implement large combinational circuits is by folding where registers hold the state from one iteration to the next Implementing imperative loops Multiplication September 16, 2016 http://csg.csail.mit.edu/6.175

Programming with rules: A simple example Euclid’s algorithm for computing the Greatest Common Divisor (GCD): 15 6 9 6 subtract 3 6 subtract 6 3 swap 3 3 subtract 0 3 subtract answer: September 16, 2016 http://csg.csail.mit.edu/6.175

GCD module Euclidean Algorithm Reg#(Bit#(32)) x <- mkReg(0); Reg#(Bit#(32)) y <- mkReg(0); rule gcd; if (x >= y) begin x <= x – y; end else if (x != 0) begin x <= y; y <= x; end endrule method Action start(Bit#(32) a, Bit#(32) b); x <= a; y <= b; endmethod method Bit#(32) result; return y; endmethod method Bool resultRdy; return x == 0; endmethod method Bool busy; return x != 0; endmethod A rule inside a module may execute anytime If x is 0 then the rule has no effect (Andy) Changed code to conform with BSV syntax (Sizhuo) fixed GCD code bug: if(x>y)  if(x>=y) Start method should be called only if busy is False. The result is available only when resultRdy is True. September 16, 2016 http://csg.csail.mit.edu/6.175

Circuits for GCD - > A x y x!=0(s1) x>y(s3) x!=0(s1) y x x-y(s2) 0 1 y x x-y(s2) x>y(s3) 0 1 0 1 a b startEn startEn 1 0 1 0 x y Result !=0 - > Busy x!=0 (s1) x-y (s2) x>y (s3) ResultRdy A September 16, 2016 http://csg.csail.mit.edu/6.175

Expressing a loop using registers int s = s0; for (int i = 0; i < 32; i = i+1) {     s = f(s);        } return s; C-code We need two registers to hold s and i values from one iteration to the next. These registers are initialized when the computation starts and updated every cycle until the computation terminates < 32 notDone +1 s0 f sel sel i s en en sel = start en = start | notDone September 16, 2016 http://csg.csail.mit.edu/6.175

Expressing a loop in BSV Reg#(Bit#(32)) s <- mkRegU(); Reg#(Bit#(6)) i <- mkReg(32); rule step; if (i < 32) begin      s <= f(s); i <= i+1; end endrule When a rule executes: all the registers are read at the beginning of a clock cycle computations to evaluate the next value of the registers are performed Registers that need to be updated are updated at the end of the clock cycle Muxes are need to initialize the registers +1 sel f s0 sel i s en en < 32 sel = start en = start | notDone notDone September 16, 2016 http://csg.csail.mit.edu/6.175

Combinational 32-bit multiply function Bit#(64) mul32(Bit#(32) a, Bit#(32) b); Bit#(32) tp = 0; Bit#(32) prod = 0; for(Integer i = 0; i < 32; i = i+1) begin Bit#(32) m = (a[i]==0)? 0 : b; Bit#(33) sum = add32(m,tp,0); prod[i:i] = sum[0]; tp = sum[32:1]; end return {tp,prod}; endfunction Combinational circuit uses 31 add32 circuits We can reuse the same add32 circuit if we store the partial results in a register September 16, 2016 http://csg.csail.mit.edu/6.175

Multiply using registers function Bit#(64) mul32(Bit#(32) a, Bit#(32) b); Bit#(32) prod = 0; Bit#(32) tp = 0; for(Integer i = 0; i < 32; i = i+1) begin Bit#(32) m = (a[i]==0)? 0 : b; Bit#(33) sum = add32(m,tp,0); prod[i:i] = sum[0]; tp = sum[32:1]; end return {tp,prod}; endfunction Combinational version Need registers to hold a, b, tp, prod and i Update the registers every cycle until we are done September 16, 2016 http://csg.csail.mit.edu/6.175

Sequential Circuit for Multiply Reg#(Bit#(32)) a <- mkRegU(); Reg#(Bit#(32)) b <- mkRegU(); Reg#(Bit#(32)) prod <-mkRegU(); Reg#(Bit#(32)) tp <- mkReg(0); Reg#(Bit#(6)) i <- mkReg(32); rule mulStep; if (i < 32) begin Bit#(32) m = (a[i]==0)? 0 : b; Bit#(33) sum = add32(m,tp,0); prod[i] <= sum[0]; tp <= sum[32:1]; i <= i+1; end endrule state elements a rule to describe the dynamic behavior similar to the loop body in the combinational version So that the rule has no effect until i is set to some other value September 16, 2016 http://csg.csail.mit.edu/6.175

Dynamic selection requires a mux a[i] a i when the selection indices are regular then it is better to use a shift operator (no gates!) a >> a[0],a[1],a[2],… September 16, 2016 http://csg.csail.mit.edu/6.175

Replacing repeated selections by shifts Reg#(Bit#(32)) a <- mkRegU(); Reg#(Bit#(32)) b <- mkRegU(); Reg#(Bit#(32)) prod <-mkRegU(); Reg#(Bit#(32)) tp <- mkReg(0); Reg#(Bit#(6)) i <- mkReg(32); rule mulStep if (i < 32); Bit#(32) m = (a[0]==0)? 0 : b; a <= a >> 1; Bit#(33) sum = add32(m,tp,0); prod <= {sum[0], prod[31:1]}; tp <= sum[32:1]; i <= i+1; endrule September 16, 2016 http://csg.csail.mit.edu/6.175

Circuit for Sequential Multiply bIn aIn << 31:0 s1 b result (high) 31 add 32:1 == 32 done +1 s1 result (low) [30:0] << s1 s1 i a tp prod s2 s2 s2 s2 s1 = start_en s2 = start_en | !done September 16, 2016 http://csg.csail.mit.edu/6.175

Circuit analysis Number of add32 circuits has been reduced from 31 to one, though some registers and muxes have been added The longest combinational path has been reduced from 62 FAs to one add32 plus a few muxes The sequential circuit will take 31 clock cycles to compute an answer (Andy) longest combinational path was effectively 63 1-bit adders. September 16, 2016 http://csg.csail.mit.edu/6.175

A subtle problem while(!isDone(x)) { x = doStep(x); } doStep workQ ? doneQ let x = workQ.first; workQ.deq; if (isDone(x)) begin doneQ.enq(x); end else begin workQ.enq(doStep(x)); end Double write problem for previously shown FIFOs Later we will design FIFOs to permit simultaneous enq and deq September 16, 2016 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 16, 2016 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 16, 2016 http://csg.csail.mit.edu/6.175