Computer Architecture: A Constructive Approach Sequential Circuits Arvind Computer Science & Artificial Intelligence Lab. Massachusetts Institute of Technology.

Slides:



Advertisements
Similar presentations
Combinational Circuits in Bluespec
Advertisements

Assume array size is 256 (mult: 4ns, add: 2ns)
Levels in Processor Design
11/16/2004EE 42 fall 2004 lecture 331 Lecture #33: Some example circuits Last lecture: –Edge triggers –Registers This lecture: –Example circuits –shift.
Logic and Computer Design Fundamentals Registers and Counters
Lab 10 RT methodology (cont’d) Example 1 – a counter Example 2 – a repetitive-adder multiplier.
CPEN Digital System Design Chapter 9 – Computer Design
Some Useful Circuits Lecture for CPSC 5155 Edward Bosworth, Ph.D. Computer Science Department Columbus State University.
Computer Architecture: A Constructive Approach Branch Direction Prediction – Six Stage Pipeline Joel Emer Computer Science & Artificial Intelligence Lab.
1 Registers and Counters A register consists of a group of flip-flops and gates that affect their transition. An n-bit register consists of n-bit flip-flops.
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.
1 KU College of Engineering Elec 204: Digital Systems Design Lecture 21 Multiplier Example Example: (101 x 011) Base 2 Note that the partial product summation.
Realistic Memories and Caches Li-Shiuan Peh Computer Science & Artificial Intelligence Lab. Massachusetts Institute of Technology March 21, 2012L13-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.
Chap 7. Register Transfers and Datapaths. 7.1 Datapaths and Operations Two types of modules of digital systems –Datapath perform data-processing operations.
Anurag Dwivedi. Basic Block - Gates Gates -> Flip Flops.
March 6, 2006http://csg.csail.mit.edu/6.375/L10-1 Bluespec-4: Rule Scheduling and Synthesis Arvind Computer Science & Artificial Intelligence Lab Massachusetts.
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.
EKT 221 : Chapter 4 Computer Design Basics
ALU (Continued) Computer Architecture (Fall 2006).
Computer Architecture: A Constructive Approach Combinational ALU Arvind Computer Science & Artificial Intelligence Lab. Massachusetts Institute of Technology.
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
6.S078 - Computer Architecture: A Constructive Approach Combinational circuits Arvind Computer Science & Artificial Intelligence Lab. Massachusetts Institute.
Introduction to ASIC flow and Verilog HDL
Constructive Computer Architecture Sequential Circuits Arvind Computer Science & Artificial Intelligence Lab. Massachusetts Institute of Technology September.
Chap 5. Registers and Counters
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.
EKT 221 : Digital 2 Computer Design Basics Date : Lecture : 2 hrs.
Introduction to Bluespec: A new methodology for designing Hardware Arvind Computer Science & Artificial Intelligence Lab. Massachusetts Institute of Technology.
Computer Architecture: A Constructive Approach Combinational circuits Teacher: Yoav Etsion Teaching Assistant: Yuval H. Nacson Taken (with permission)
Appendix C Basics of Logic Design. Appendix C — Logic Basic — 2 Logic Design Basics §4.2 Logic Design Conventions Objective: To understand how to build.
Introduction to Bluespec: A new methodology for designing Hardware
Introduction to Bluespec: A new methodology for designing Hardware
Combinational Circuits
Folded Combinational Circuits as an example of Sequential Circuits
Folded “Combinational” circuits
Sequential Circuits - 2 Constructive Computer Architecture Arvind
Chap 7. Register Transfers and Datapaths
Sequential Circuits Constructive Computer Architecture Arvind
Sequential Circuits: Constructive Computer Architecture
Combinational ALU Constructive Computer Architecture Arvind
Basics of digital systems
Combinational circuits-2
KU College of Engineering Elec 204: Digital Systems Design
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
5. Combinational circuits
Pipelining combinational circuits
BSV objects and a tour of known BSV problems
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
Constructive Computer Architecture: Guards
GCD: A simple example to introduce Bluespec
Introduction to Bluespec: A new methodology for designing Hardware
Levels in Processor Design
Combinational ALU 6.S078 - Computer Architecture:
Constructive Computer Architecture Tutorial 1 Andy Wright 6.S195 TA
Presentation transcript:

Computer Architecture: A Constructive Approach Sequential Circuits Arvind Computer Science & Artificial Intelligence Lab. Massachusetts Institute of Technology Revised February 21, 2012 (Slides from #16 onwards) February 15, 2012L3-1

Combinational circuits OpSelect - Add, Sub,... - And, Or, Xor, Not,... - GT, LT, EQ, Zero,... Result Comp? A B ALU Sel O A 0 A 1 A n-1 Mux... lg(n) Sel O 0 O 1 O n-1 A Demux... lg(n) A Decoder... O 0 O 1 O n-1 lg(n) Such circuits have no cycles (feedback) or state February 15, 2012 L3-2http://csg.csail.mit.edu/6.S078

A simple synchronous state element ff Q D C C D Q Metastability Data is sampled at the rising edge of the clock Edge-Triggered Flip-flop February 15, 2012 L3-3http://csg.csail.mit.edu/6.S078

Flip-flops with Write Enables ff Q D C EN C D Q ff Q DCDC EN 0101 ff Q D C EN dangerous! Data is captured only if EN is on February 15, 2012 L3-4http://csg.csail.mit.edu/6.S078

Registers Register: A group of flip-flops with a common clock and enable Register file: A group of registers with a common clock, input and output port(s) ff D D D D D D D QQQQQQQQ D C En February 15, 2012 L3-5http://csg.csail.mit.edu/6.S078

Register Files ReadData1 ReadSel1 ReadSel2 WriteSel Register file 2R + 1W ReadData2 WriteData WE Clock No timing issues in reading a selected register register 1 WSel C register 0 WData WE RSel2 RData2 RSel1 RData1 February 15, 2012 L3-6http://csg.csail.mit.edu/6.S078

Register Files and Ports Ports were expensive multiplex a port for read & write ReadData1 ReadSel1 ReadSel2 WriteSel Register file 2R + 1W ReadData2 WriteData WE ReadData ReadSel R/WSel Register file 1R + 1R/W R/WData WE February 15, 2012 L3-7http://csg.csail.mit.edu/6.S078

We can build useful and compact circuits using registers Example: Multiplication by repeated addition February 15, 2012L3-8

Multiplication by repeated addition 1101 (13) 1011 (11) (143) b Multiplicand a Muliplier * add4 a0 a1 a2 a3 m0 m1 m2 m3 0 mi = (a[i]==0)? 0 : b; February 15, 2012 L3-9http://csg.csail.mit.edu/6.S078

Combinational 32-bit multiply 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] = sum[0]; tp = truncateLSB(sum); end return {tp,prod}; endfunction February 15, 2012 L3-10http://csg.csail.mit.edu/6.S078

Design issues with combinational multiply Lot of hardware 32-bit multiply uses 31 addN 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! The speed of a combinational circuit is determined by its longest input-to-output path February 15, 2012 L3-11http://csg.csail.mit.edu/6.S078

Expressing a loop 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] = sum[0]; tp = truncateLSB(sum); end return {tp,prod}; endfunction February 15, 2012 L3-12http://csg.csail.mit.edu/6.S078 Need registers to hold a, b, tp prod and i Update the registers every cycle until we are done

Expressing a loop using registers February 15, 2012 L3-13http://csg.csail.mit.edu/6.S078 for(Integer i = 0; i < 32; i = i+1) begin let s = f(s); end return s; s  f  s0 i (init 0) +1 <32

Sequential multiply Reg#(Bit#(32)) a <- mkRegU(); Reg#(Bit#(32)) b <- mkRegU(); Reg#(Bit#(32)) prod <-mkRegU(); Reg#(Bit#(32)) tp <- mkRegU(); 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 dynamic behavior February 15, 2012 L3-14http://csg.csail.mit.edu/6.S078 So that the rule won’t fire until i is set to some other value

Dynamic selection requires a mux February 15, 2012 L3-15http://csg.csail.mit.edu/6.S078 a[i] a i a[0],a[1],a[2],… a  >> 0

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

Sequential Multiply bIn b a i February 15, 2012 L3-17http://csg.csail.mit.edu/6.S078 == 32 0 done +1 prod result (low) << [30:0] aIn << 31:0 tp result (high) add &……………& s1 s2 s1 s1 = start_en s2 = start_en | !done 32:1

rdy en Int#(32) Int#(64) rdy start result Multiply module Int#(32) implicit conditions interface Multiply; method Action start (Int#(32) a, Int#(32) b); method Int#(64) result(); endinterface Multiply Module Many different implementations can provide the same interface: module mkMultiply (Multiply) February 15, 2012 L3-18http://csg.csail.mit.edu/6.S078

Multiply Module module mkMultiply32 (Multiply32); Reg#(Bit#(32)) a <- mkRegU(); Reg#(Bit#(32)) b <- mkRegU(); Reg#(Bit#(32)) prod <-mkRegU(); Reg#(Bit#(32)) tp <- mkRegU(); Reg#(Bit#(6)) i <- mkReg(32); rule mulStep if (i < 32); Bit#(32) m = (a[0]==0)? 0 : b; Bit#(33) sum = add32(m,tp,0); prod > 1)[30:0]}; tp > 1; i <= i+1; endrule method Action start(Bit#(32) aIn, Bit#(32) bIn) if (i == 32); a <= aIn; b <= bIn; i <= 0; tp <= 0; prod <= 0; endmethod method Bit#(64) result() if (i == 32); return {tp,prod}; endmethod endmodule February 15, 2012 L3-19http://csg.csail.mit.edu/6.S078 State Internal behavior External interface

Module: Method Interface February 15, 2012 L3-20http://csg.csail.mit.edu/6.S078 s1 = start_en s2 = start_en | !done bIn b a i == 32 0 done +1 prod result (low) << [30:0] aIn << 31:0 tp result (high) add &……………& s1 s2 s1 32:1 aIn bIn  en rdy result rdy start result s1 OR s1 s2

rdy enab Int#(32) Int#(64) rdy start result Multiply module Int#(32) implicit conditions interface Multiply; method Action start (Int#(32) a, Int#(32) b); method Int#(64) result(); endinterface Polymorphic Multiply Module n #(Numeric type n) n Tadd(n+n) nn TAdd#(n,n) n could be Int#(32), Int#(13),... The module can easily be made polymorphic January 11, 2012

Sequential n-bit multiply module mkMultiplyN (MultiplyN); Reg#(Bit#(n)) a <- mkRegU(); Reg#(Bit#(n)) b <- mkRegU(); Reg#(Bit#(n)) prod <-mkRegU(); Reg#(Bit#(n)) tp <- mkRegU(); Reg#(Bit#(Add#(Tlog(n),1)) i <- mkReg(n); nv = valueOf(n); rule mulStep if (i < nv); Bit#(n) m = (a[0]==0)? 0 : b; Bit#(TAdd#(n,1)) sum = addn(m,tp,0); prod > 1)[(nv-2):0]}; tp > 1; i <= i+1; endrule method Action start(Bit#(n) aIn, Bit#(n) bIn) if (i == nv); a <= aIn; b <= bIn; i <= 0; tp <= 0; prod <= 0; endmethod method Bit#(TAdd#(n,n)) result() if (i == nv); return {tp,prod}; endmethod endmodule February 15, 2012 L3-22http://csg.csail.mit.edu/6.S078