bluespec-1: design affects everything arvind computer science & artificial intelligence lab

36
February 24, 2006 http:// csg.csail.mit.edu/6.375/ L07-1 Bluespec-1: Design Affects Everything Arvind Computer Science & Artificial Intelligence Lab Massachusetts Institute of Technology

Upload: sauda

Post on 17-Jan-2016

26 views

Category:

Documents


0 download

DESCRIPTION

Bluespec-1: Design Affects Everything Arvind Computer Science & Artificial Intelligence Lab Massachusetts Institute of Technology. Prototype. Validation. Physical. Verification. Architecture. Source: IBM/IBS, Inc. Chip costs are exploding because of design complexity. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Bluespec-1: Design Affects Everything Arvind  Computer Science & Artificial Intelligence Lab

February 24, 2006 http://csg.csail.mit.edu/6.375/ L07-1

Bluespec-1: Design Affects Everything

Arvind Computer Science & Artificial Intelligence LabMassachusetts Institute of Technology

Page 2: Bluespec-1: Design Affects Everything Arvind  Computer Science & Artificial Intelligence Lab

February 24, 2006 L07-2http://csg.csail.mit.edu/6.375/

Chip costs are explodingbecause of design complexity

Design and verification dominate escalating project costs

I ssues Found on First Spin I Cs/ ASI Cs

43%20%

17%14%12%11%11%10%10%

7%4%3%

0% 10% 20% 30% 40% 50%

Functional Logic ErrorAnalog Tuning Issue

Signal Integrity IssueClock Scheme Error

Reliability IssueMixed Signal Problem

Too Much PowerHas Path(s) Too SlowHas Path(s) Too Fast

IR Drop IssuesFirmware Error

Other

Source: Aart de Geus, CEO of SynopsysBased on a survey of 2000 users by Synopsys

SoC failures costing

time/spins

IC Design Costs

0

5

10

15

20

25

30

0.18µm 0.13µm 90nm

Silicon Feature Dimension

Cos

t ($

M)

Source: IBM/IBS, Inc.

Architecture

Verification

Physical

ValidationPrototype

Page 3: Bluespec-1: Design Affects Everything Arvind  Computer Science & Artificial Intelligence Lab

February 24, 2006 L07-3http://csg.csail.mit.edu/6.375/

Common quotes

“Design is not a problem; design is easy”

Almost complete reliance on post-design verification for qualityMind se

t

“Verification is a problem”“Timing closure is a problem”“Physical design is a problem”

Page 4: Bluespec-1: Design Affects Everything Arvind  Computer Science & Artificial Intelligence Lab

February 24, 2006 L07-4http://csg.csail.mit.edu/6.375/

The U.S. auto industry Sought quality solely through post-build inspection Planned for defects and rework

and U.S. quality was…

Through the early 1980s:

Defect

Make Inspect Rework

Def

ect

Defe

ct

Page 5: Bluespec-1: Design Affects Everything Arvind  Computer Science & Artificial Intelligence Lab

February 24, 2006 L07-5http://csg.csail.mit.edu/6.375/

… less than world class

Adding quality inspectors (“verification engineers”) and giving them better tools, was not the solutionThe Japanese auto industry showed the way

“Zero defect” manufacturing

Page 6: Bluespec-1: Design Affects Everything Arvind  Computer Science & Artificial Intelligence Lab

February 24, 2006 L07-6http://csg.csail.mit.edu/6.375/

New mind set:

Design affects everything!A good design methodology Can keep up with changing specs Permits architectural exploration Facilitates verification and debugging Eases changes for timing closure Eases changes for physical design Promotes reuse

Design for Correctness

It is essential to

Page 7: Bluespec-1: Design Affects Everything Arvind  Computer Science & Artificial Intelligence Lab

February 24, 2006 L07-7http://csg.csail.mit.edu/6.375/

New semantics for expressing behavior to reduce design complexity

Decentralize complexity: Rule-based specifications (Guarded Atomic Actions)

Let us think about one rule at a time

Formalize composition: Modules with guarded interfaces Automatically manage and ensure the

correctness of connectivity, i.e., correct-by-construction methodology

Retain resilience to changes in design or layout, e.g. compute latency ’s

Promote regularity of layout at macro level

Bluespec

Page 8: Bluespec-1: Design Affects Everything Arvind  Computer Science & Artificial Intelligence Lab

February 24, 2006 L07-8http://csg.csail.mit.edu/6.375/

data_in

push_req_n

pop_req_n

clk

rstn

data_out

full

empty

RTL has poor semantics for composition

Example: Commercially available FIFO IP block

These constraints are spread over many pages of the documentation...

No machine verification of such

informal constraints is feasible

Page 9: Bluespec-1: Design Affects Everything Arvind  Computer Science & Artificial Intelligence Lab

February 24, 2006 L07-9http://csg.csail.mit.edu/6.375/

Bluespec promotes compositionthrough guarded interfaces

not full

not empty

not empty

n

n

rdy

enab

rdy

enab

rdy

enq

deq

first

FIFO

theModuleA

theModuleB

theFifo.enq(value1);

theFifo.deq();value2 = theFifo.first();

theFifo.enq(value3);

theFifo.deq();value4 = theFifo.first();

theFifo

Enqueue arbitration

control

Dequeue arbitration

control

Self-documenting interfaces; Automatic generation of logic to eliminate conflicts in use.

Page 10: Bluespec-1: Design Affects Everything Arvind  Computer Science & Artificial Intelligence Lab

February 24, 2006 L07-10http://csg.csail.mit.edu/6.375/

In Bluespec SystemVerilog (BSV) …

Power to express complex static structures and constraints Checked by the compiler

“Micro-protocols” are managed by the compiler The compiler generates the necessary

hardware (muxing and control) Micro-protocols need less or no verification

Easier to make changes while preserving correctness

Smaller, simpler, clearer, more correct code

Page 11: Bluespec-1: Design Affects Everything Arvind  Computer Science & Artificial Intelligence Lab

February 24, 2006 L07-11http://csg.csail.mit.edu/6.375/

Bluespec: State and Rules organized into modules

All state (e.g., Registers, FIFOs, RAMs, ...) is explicit.Behavior is expressed in terms of atomic actions on the state:

Rule: condition action Rules can manipulate state in other modules only via their interfaces.

interface

module

Page 12: Bluespec-1: Design Affects Everything Arvind  Computer Science & Artificial Intelligence Lab

February 24, 2006 L07-12http://csg.csail.mit.edu/6.375/

Examples

GCDMultiplicationIP Lookup

Page 13: Bluespec-1: Design Affects Everything Arvind  Computer Science & Artificial Intelligence Lab

February 24, 2006 L07-13http://csg.csail.mit.edu/6.375/

Programming withrules: A simple example

Euclid’s algorithm for computing the Greatest Common Divisor (GCD):

15 6 9 6 subtract

Page 14: Bluespec-1: Design Affects Everything Arvind  Computer Science & Artificial Intelligence Lab

February 24, 2006 L07-14http://csg.csail.mit.edu/6.375/

module mkGCD (I_GCD); Reg#(int) x <- mkRegU; Reg#(int) y <- mkReg(0);

rule swap ((x > y) && (y != 0)); x <= y; y <= x; endrule rule subtract ((x <= y) && (y != 0)); y <= y – x; endrule

method Action start(int a, int b) if (y==0);x <= a; y <= b;

endmethod method int result() if (y==0); return x; endmethodendmodule

GCD in BSV

Assumes x /= 0 and y /= 0

x y

swap sub

Page 15: Bluespec-1: Design Affects Everything Arvind  Computer Science & Artificial Intelligence Lab

February 24, 2006 L07-15http://csg.csail.mit.edu/6.375/

rdyenab

int

intrdy

start

result

GC

Dm

odule

int

y == 0

y == 0

implicit conditions

interface I_GCD; method Action start (int a, int b); method int result();endinterface

GCD Hardware Module

The module can easily be made polymorphic

Many different implementations can provide the same interface: module mkGCD (I_GCD)

Page 16: Bluespec-1: Design Affects Everything Arvind  Computer Science & Artificial Intelligence Lab

February 24, 2006 L07-16http://csg.csail.mit.edu/6.375/

module mkGCD (I_GCD); Reg#(int) x <- mkRegU; Reg#(int) y <- mkReg(0);

rule swapANDsub ((x > y) && (y != 0)); x <= y; y <= x - y; endrule rule subtract ((x<=y) && (y!=0)); y <= y – x; endrule

method Action start(int a, int b) if (y==0);x <= a; y <= b;

endmethod method int result() if (y==0); return x; endmethodendmodule

GCD: Another implementation

Combine swap and subtract rule

Does it compute faster ?

Page 17: Bluespec-1: Design Affects Everything Arvind  Computer Science & Artificial Intelligence Lab

February 24, 2006 L07-17http://csg.csail.mit.edu/6.375/

Bluespec Tool flowBluespec SystemVerilog source

Verilog 95 RTL

Verilog sim

VCD output

DebussyVisualization

Bluespec Compiler

files

Bluespec tools

3rd party tools

Legend

RTL synthesis

gates

C

Bluespec C sim CycleAccurate

Blueview

Page 18: Bluespec-1: Design Affects Everything Arvind  Computer Science & Artificial Intelligence Lab

February 24, 2006 L07-18http://csg.csail.mit.edu/6.375/

Generated Verilog RTL: GCDmodule mkGCD(CLK,RST_N,start_a,start_b,EN_start,RDY_start,

result,RDY_result); input CLK; input RST_N;// action method start input [31 : 0] start_a; input [31 : 0] start_b; input EN_start; output RDY_start;// value method result output [31 : 0] result; output RDY_result;// register x and y reg [31 : 0] x; wire [31 : 0] x$D_IN; wire x$EN; reg [31 : 0] y; wire [31 : 0] y$D_IN; wire y$EN;...// rule RL_subtract assign WILL_FIRE_RL_subtract = x_SLE_y___d3 && !y_EQ_0___d10 ;// rule RL_swap assign WILL_FIRE_RL_swap = !x_SLE_y___d3 && !y_EQ_0___d10 ;...

Page 19: Bluespec-1: Design Affects Everything Arvind  Computer Science & Artificial Intelligence Lab

February 24, 2006 L07-19http://csg.csail.mit.edu/6.375/

Generated Hardware

x_en y_enx y

> !(=0)

swap? subtract?

sub

Page 20: Bluespec-1: Design Affects Everything Arvind  Computer Science & Artificial Intelligence Lab

February 24, 2006 L07-20http://csg.csail.mit.edu/6.375/

Generated Hardware Module

x_en y_enx y

> !(=0)

swap? subtract?

sub

xy

enrdy

xrdy

start

resu

ltstart_en start_en

Page 21: Bluespec-1: Design Affects Everything Arvind  Computer Science & Artificial Intelligence Lab

February 24, 2006 L07-21http://csg.csail.mit.edu/6.375/

GCD: A Simple Test Benchmodule mkTest (); Reg#(int) state <- mkReg(0); I_GCD gcd <- mkGCD();

rule go (state == 0);

gcd.start (423, 142); state <= 1; endrule

rule finish (state == 1); $display (“GCD of 423 & 142 =%d”,gcd.result()); state <= 2; endruleendmodule

Why do we need the state variable?

Page 22: Bluespec-1: Design Affects Everything Arvind  Computer Science & Artificial Intelligence Lab

February 24, 2006 L07-22http://csg.csail.mit.edu/6.375/

GCD: Test Benchmodule mkTest (); Reg#(int) state <- mkReg(0); Reg#(Int#(4)) c1 <- mkReg(1); Reg#(Int#(7)) c2 <- mkReg(1); I_GCD gcd <- mkGCD();

rule req (state==0); gcd.start(signExtend(c1), signExtend(c2)); state <= 1; endrule

rule resp (state==1); $display (“GCD of %d & %d =%d”, c1, c2, gcd.result()); if (c1==7) begin c1 <= 1; c2 <= c2+1; state <= 0; end else c1 <= c1+1; if (c2 == 63) state <= 2; endruleendmodule

Page 23: Bluespec-1: Design Affects Everything Arvind  Computer Science & Artificial Intelligence Lab

February 24, 2006 L07-23http://csg.csail.mit.edu/6.375/

GCD: Synthesis results

Original (16 bits) Clock Period: 1.6 ns Area: 4240.10 mm2

Unrolled (16 bits) Clock Period: 1.65ns Area: 5944.29 mm2

Unrolled takes 31% fewer cycles on testbench

Page 24: Bluespec-1: Design Affects Everything Arvind  Computer Science & Artificial Intelligence Lab

February 24, 2006 L07-24http://csg.csail.mit.edu/6.375/

Multiplier ExampleSimple binary multiplication:

100101011001

0000 1001 0000 0101101

// d = 4’d9// r = 4’d5// d << 0 (since r[0] == 1)// 0 << 1 (since r[1] == 0)// d << 2 (since r[2] == 1)// 0 << 3 (since r[3] == 0)// product (sum of above) = 45

x

What does it look like in Bluespec?

d r product

One step of multiplicationOne step of multiplication

Page 25: Bluespec-1: Design Affects Everything Arvind  Computer Science & Artificial Intelligence Lab

February 24, 2006 L07-25http://csg.csail.mit.edu/6.375/

module mkMult (I_mult); Reg#(Int#(32)) product <- mkReg(0); Reg#(Int#(32)) d <- mkReg(0); Reg#(Int#(16)) r <- mkReg(0);

rule cycle

endrule

method Action start

endmethod

method Int#(32) result ()

endmethodendmodule

Multiplier in Bluespec

What is the interface I_mult ?

Page 26: Bluespec-1: Design Affects Everything Arvind  Computer Science & Artificial Intelligence Lab

February 24, 2006 http://csg.csail.mit.edu/6.375/ L07-26

Exploring microarchitectures

IP Lookup Module

Page 27: Bluespec-1: Design Affects Everything Arvind  Computer Science & Artificial Intelligence Lab

February 24, 2006 L07-27http://csg.csail.mit.edu/6.375/

IP Lookup block in a router

QueueManager

Packet Processor

Exit functions

ControlProcessor

Line Card (LC)

IP Lookup

SRAM(lookup table)

Arbitration

Switch

LC

LC

LC

A packet is routed based on the “Longest Prefix Match” (LPM) of it’s IP address with entries in a routing tableLine rate and the order of arrival must be maintained line rate 15Mpps for 10GE

Page 28: Bluespec-1: Design Affects Everything Arvind  Computer Science & Artificial Intelligence Lab

February 24, 2006 L07-28http://csg.csail.mit.edu/6.375/

18

2

3

IP address Result M Ref

7.13.7.3 F

10.18.201.5 F

7.14.7.2

5.13.7.2 E

10.18.200.7 C

Sparse tree representation

3

A…

A…

B

C…

C…

5 D

F…

F…

14

A…

A…

7

F…

F…

200

F…

F…

F*

E5.*.*.*

D10.18.200.5

C10.18.200.*

B7.14.7.3

A7.14.*.* F…F…

F

F…

E5

7

10

255

0

14

4A Real-world lookup algorithms are more complex but all make a sequence of dependent memory references.

Page 29: Bluespec-1: Design Affects Everything Arvind  Computer Science & Artificial Intelligence Lab

February 24, 2006 L07-29http://csg.csail.mit.edu/6.375/

SW (“C”) version of LPMintlpm (IPA ipa) /* 3 memory lookups */{ int p;

p = RAM [ipa[31:16]]; /* Level 1: 16 bits */if (isLeaf(p)) return p;

p = RAM [p + ipa [15:8]]; /* Level 2: 8 bits */if (isLeaf(p)) return p;

p = RAM [p + ipa [7:0]]; /* Level 3: 8 bits */return p; /* must be a leaf */

}

How to implement LPM in HW?Not obvious from C code!

Page 30: Bluespec-1: Design Affects Everything Arvind  Computer Science & Artificial Intelligence Lab

February 24, 2006 L07-30http://csg.csail.mit.edu/6.375/

Longest Prefix Match for IP lookup:3 possible implementation architectures

Rigid pipeline

Inefficient memory usage but simple design

Linear pipeline

Efficient memory usage through memory port replicator

Circular pipeline

Efficient memory with most complex control

Designer’s Ranking:

1 2 3Which is “best”?

Page 31: Bluespec-1: Design Affects Everything Arvind  Computer Science & Artificial Intelligence Lab

February 24, 2006 L07-31http://csg.csail.mit.edu/6.375/

Static Pipeline

RAM

MUX

req

IP addr

resp

Page 32: Bluespec-1: Design Affects Everything Arvind  Computer Science & Artificial Intelligence Lab

February 24, 2006 L07-32http://csg.csail.mit.edu/6.375/

Static coderule static (True); if (canInsert(c5)) begin c1 <= 0; r1 <= in.first(); in.deq(); end else begin r1 <= r5; c1 <= c5; end if (notEmpty(r1)) makeMemReq(r1); r2 <= r1; c2 <= c1; r3 <= r2; c3 <= c2; r4 <= r3; c4 <= c3; r5 <= getMemResp(); c5 <= (c4 == n-1) ? 0 : n; if (c5 == n) out.enq(r5);endrule

Page 33: Bluespec-1: Design Affects Everything Arvind  Computer Science & Artificial Intelligence Lab

February 24, 2006 L07-33http://csg.csail.mit.edu/6.375/

Circular pipeline

luReq

luResp

enter?enter?done?done?RAM

cbufyes

getToken

in

active

no

Page 34: Bluespec-1: Design Affects Everything Arvind  Computer Science & Artificial Intelligence Lab

February 24, 2006 L07-34http://csg.csail.mit.edu/6.375/

Circular Pipeline coderule enter (True); t <- cbuf.newToken(); IP ip = in.first(); ram.req(ip[31:16]); active.enq(tuple2(ip[15:0], t)); in.deq();endrulerule done (True); p <- ram.resp(); match {.rip, .t} = active.first(); if (isLeaf(p)) cbuf.complete(t, p); else begin match {.newreq, .newrip} = remainder(p, rip); active.enq(rip << 8, t); ram.req(p+signExtend(rip[15:7])); end active.deq();endrule

Page 35: Bluespec-1: Design Affects Everything Arvind  Computer Science & Artificial Intelligence Lab

February 24, 2006 L07-35http://csg.csail.mit.edu/6.375/

Synthesis results

V = VerilogBSV = Bluespec System Verilog

LPM versions

Code size(lines)

Best Area(gates)

Best Speed(ns)

Mem. util. (random workload)

Static V 220 2271 3.56 63.5%

Static BSV 179 2391 (5% larger) 3.32 (7% faster) 63.5%

Linear V 410 14759 4.7 99.9%

Linear BSV 168 15910 (8% larger) 4.7 (same) 99.9%

Circular V 364 8103 3.62 99.9%

Circular BSV 257 8170 (1% larger) 3.67 (2% slower) 99.9%

Synthesized to TSMC 0.18 µm library

Bluespec and Verilog synthesis results are nearly identical

Arvind, Nikhil, Rosenband & Dave ICCAD 2004

Page 36: Bluespec-1: Design Affects Everything Arvind  Computer Science & Artificial Intelligence Lab

February 24, 2006 L07-36http://csg.csail.mit.edu/6.375/

Next Time

Combinational Circuits and Types