Sequential Circuits - 2 Constructive Computer Architecture Arvind

Slides:



Advertisements
Similar presentations
Combinational Circuits in Bluespec
Advertisements

Stmt FSM Richard S. Uhler Computer Science & Artificial Intelligence Lab Massachusetts Institute of Technology (based on a lecture prepared by Arvind)
Chapter 6-2 Multiplier Multiplier Next Lecture Divider
Computer Architecture: A Constructive Approach Sequential Circuits Arvind Computer Science & Artificial Intelligence Lab. Massachusetts Institute of Technology.
Copyright 1995 by Coherence LTD., all rights reserved (Revised: Oct 97 by Rafi Lohev, Oct 99 by Yair Wiseman, Sep 04 Oren Kapah) IBM י ב מ 10-1 The ALU.
HCL and ALU תרגול 10. Overview of Logic Design Fundamental Hardware Requirements – Communication: How to get values from one place to another – Computation.
Digital Kommunikationselektronik TNE027 Lecture 2 1 FA x n –1 c n c n1- y n1– s n1– FA x 1 c 2 y 1 s 1 c 1 x 0 y 0 s 0 c 0 MSB positionLSB position Ripple-Carry.
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.
Digital Logic Design (CSNB163)
Constructive Computer Architecture: Guards Arvind Computer Science & Artificial Intelligence Lab. Massachusetts Institute of Technology September 24, 2014.
Topics covered: Arithmetic CSE243: Introduction to Computer Architecture and Hardware/Software Interface.
Constructive Computer Architecture Sequential Circuits Arvind Computer Science & Artificial Intelligence Lab. Massachusetts Institute of Technology
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.
Multipliers. More complicated than addition accomplished via shifting and addition More time and more area Multiplication What should be the length of.
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.
5.3 Sequential Circuits - An Introduction to Informatics WMN Lab. Hey-Jin Lee.
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.
Gunjeet Kaur Dronacharya Group of Institutions. Binary Adder-Subtractor A combinational circuit that performs the addition of two bits is called a half.
Overview Logistics Last lecture Today HW5 due today
Introduction to Bluespec: A new methodology for designing Hardware
Introduction to Bluespec: A new methodology for designing Hardware
Functions and Types in Bluespec
EKT 221 : Digital 2 Serial Transfers & Microoperations
Integer Multiplication and Division
Folded Combinational Circuits as an example of Sequential Circuits
Folded “Combinational” circuits
Scheduling Constraints on Interface methods
Lecture 12 Logic Design Review & HCL & Bomb Lab
EKT 221 : Digital 2 Serial Transfers & Microoperations
Sequential Circuits Constructive Computer Architecture Arvind
Sequential Circuits: Constructive Computer Architecture
Seoul National University
Combinational Logic Logic circuits for digital systems may be combinational or sequential. A combinational circuit consists of input variables, logic gates,
Combinational ALU Constructive Computer Architecture Arvind
Combinational circuits-2
Multipliers Multipliers play an important role in today’s digital signal processing and various other applications. The common multiplication method is.
Summary Half-Adder Basic rules of binary addition are performed by a half adder, which has two binary inputs (A and B) and two binary outputs (Carry out.
CprE 583 – Reconfigurable Computing
Stmt FSM Arvind (with the help of Nirav Dave)
Pipelining combinational circuits
Multirule Systems and Concurrent Execution of Rules
Iterative Versus Sequential Circuits
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
Unsigned Multiplication
Combinational circuits
Modules with Guarded Interfaces
Pipelining combinational circuits
Sequential Circuits - 2 Constructive Computer Architecture Arvind
Introduction to Bluespec: A new methodology for designing Hardware
Stmt FSM Arvind (with the help of Nirav Dave)
Constructive Computer Architecture: Guards
Recall: ROM example Here are three functions, V2V1V0, implemented with an 8 x 3 ROM. Blue crosses (X) indicate connections between decoder outputs and.
Reading: Study Chapter (including Booth coding)
Montek Singh Mon, Mar 28, 2011 Lecture 11
Introduction to Bluespec: A new methodology for designing Hardware
Combinational ALU 6.S078 - Computer Architecture:
Introduction to Verilog – Part-2 Procedural Statements
Caches-2 Constructive Computer Architecture Arvind
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 September 10, 2014 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 Mutliplication September 10, 2014 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 Start method should be called only if busy is False. The result is available only when resultRdy is True. September 10, 2014 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 10, 2014 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 10, 2014 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 10, 2014 http://csg.csail.mit.edu/6.175

Multiplication by repeated addition b Multiplicand a Muliplier * tp m0 m1 m2 m3 1101 (13) 1011 (11) 0000 + 1101 01101 + 1101 100111 + 0000 0100111 + 1101 10001111 (143) a1 m1 a2 m2 a3 m3 add4 a0 m0 mi = (a[i]==0)? 0 : b; September 10, 2014 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 10, 2014 http://csg.csail.mit.edu/6.175

Design issues with combinational multiply Lot of hardware 32-bit multiply uses 31 add32 circuits Long chains of gates 32-bit ripple carry adder has a 31-long chain of gates 32-bit multiply has 31 ripple carry adders in sequence! Total delay ? 2(n-1) FAs? The speed of a combinational circuit is determined by its longest input-to-output path Yes – Sequential Circuits; Circuits with state Can we do better? September 10, 2014 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 10, 2014 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); 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; 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 10, 2014 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 10, 2014 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 10, 2014 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 10, 2014 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 to one add32 plus a few muxes The sequential circuit will take 31 clock cycles to compute an answer September 10, 2014 http://csg.csail.mit.edu/6.175

Observations These programs are not very complex and yet it would have been tedious to express these programs in a state table or as a circuit directly BSV method calls are not available in Verilog/VHDL, and thus such programs sometimes require tedious programming Even the meaning of double-write errors is not standardized across tool implementations in Verilog September 10, 2014 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 1-element Fifo stay tuned! September 10, 2014 http://csg.csail.mit.edu/6.175