february 14, 2007l04-1 bluespec-1: design methods to facilitate rapid growth of socs arvind computer...

30
February 14, 2007 L04-1 http:// csg.csail.mit.edu/6.375/ Bluespec-1: Design methods to facilitate rapid growth of SoCs Arvind Computer Science & Artificial Intelligence Lab Massachusetts Institute of Technology System-on-a-chip

Upload: luke-day

Post on 03-Jan-2016

224 views

Category:

Documents


6 download

TRANSCRIPT

Page 1: February 14, 2007L04-1 Bluespec-1: Design methods to facilitate rapid growth of SoCs Arvind Computer Science & Artificial

February 14, 2007 L04-1http://csg.csail.mit.edu/6.375/

Bluespec-1:Design methods to facilitate rapid growth of SoCs

Arvind Computer Science & Artificial Intelligence LabMassachusetts Institute of Technology

System-on-a-chip

Page 2: February 14, 2007L04-1 Bluespec-1: Design methods to facilitate rapid growth of SoCs Arvind Computer Science & Artificial

February 14, 2007 L04-2http://csg.csail.mit.edu/6.375/

The biggest SoC drivers

Explosive growth in markets for cell phones game boxes sensors and actuators

Functionality and applications are constrained primarily by: - cost - power/energy constrains

Page 3: February 14, 2007L04-1 Bluespec-1: Design methods to facilitate rapid growth of SoCs Arvind Computer Science & Artificial

February 14, 2007 L04-3http://csg.csail.mit.edu/6.375/

Current Cellphone Architecture

Comms. Processin

gApplication Processing

WLAN RFWLAN RF WLAN RFWCDMA/GSM RF

Comple

x, Hig

h

Perform

ance

but must

not d

issip

ate

more

than 3

watts

Today’s chip becomes a block in tomorrow’s chip

IP reuse is essential

Hardware/software migration

IP = Intellectual Property

Page 4: February 14, 2007L04-1 Bluespec-1: Design methods to facilitate rapid growth of SoCs Arvind Computer Science & Artificial

February 14, 2007 L04-4http://csg.csail.mit.edu/6.375/

An under appreciated factIf a functionality (e.g. H.264) is moved from a programmable device to a specialized hardware block, the power/energy savings are 100 to 1000 fold

but our mind set Software is forgiving Hardware design is difficult, inflexible,

brittle, error prone, ...

Power savings more specialized hardware

Page 5: February 14, 2007L04-1 Bluespec-1: Design methods to facilitate rapid growth of SoCs Arvind Computer Science & Artificial

February 14, 2007 L04-5http://csg.csail.mit.edu/6.375/

SoC Trajectory:multicores, heterogeneous, regular, ...

On-chip memory banks

Structured on-chip networks

General-purpose

processors

Can we rapidly produce high-quality chips and surrounding systems and software?

Application-specific

processing units

IBM Cell Processor

Page 6: February 14, 2007L04-1 Bluespec-1: Design methods to facilitate rapid growth of SoCs Arvind Computer Science & Artificial

February 14, 2007 L04-6http://csg.csail.mit.edu/6.375/

Things to rememberDesign costs (hardware & software) dominate Within these costs verification and validation costs dominateIP reuse is essential to prevent design-team sizes from exploding

design cost = number of engineers x time to design

Page 7: February 14, 2007L04-1 Bluespec-1: Design methods to facilitate rapid growth of SoCs Arvind Computer Science & Artificial

February 14, 2007 L04-7http://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 8: February 14, 2007L04-1 Bluespec-1: Design methods to facilitate rapid growth of SoCs Arvind Computer Science & Artificial

February 14, 2007 L04-8http://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 9: February 14, 2007L04-1 Bluespec-1: Design methods to facilitate rapid growth of SoCs Arvind Computer Science & Artificial

February 14, 2007 L04-9http://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 10: February 14, 2007L04-1 Bluespec-1: Design methods to facilitate rapid growth of SoCs Arvind Computer Science & Artificial

February 14, 2007 L04-10http://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 11: February 14, 2007L04-1 Bluespec-1: Design methods to facilitate rapid growth of SoCs Arvind Computer Science & Artificial

February 14, 2007 L04-11http://csg.csail.mit.edu/6.375/

New ways of expressing behavior to reduce design complexity

Decentralize complexity: Rule-based specifications (Guarded Atomic Actions) Lets you think 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

Bluespec

Smaller, simpler, clearer, more correct code

Strong flavor of Unity

Page 12: February 14, 2007L04-1 Bluespec-1: Design methods to facilitate rapid growth of SoCs Arvind Computer Science & Artificial

February 14, 2007 L04-12http://csg.csail.mit.edu/6.375/

data_in

push_req_n

pop_req_n

clk

rstn

data_out

full

empty

Reusing IP Blocks

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 13: February 14, 2007L04-1 Bluespec-1: Design methods to facilitate rapid growth of SoCs Arvind Computer Science & Artificial

February 14, 2007 L04-13http://csg.csail.mit.edu/6.375/

Bluespec promotes compositionthrough guarded interfaces

not full

not empty

not empty

n

n

rdy

enab

rdy

enab

rdy

en

qd

eq

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 14: February 14, 2007L04-1 Bluespec-1: Design methods to facilitate rapid growth of SoCs Arvind Computer Science & Artificial

February 14, 2007 L04-14http://csg.csail.mit.edu/6.375/

Bluespec

What is it?Programming with Rules Example GCD

Synthesis of circuitsAnother Example: Multiplication

Bluespec is available in two versions:BSV – Bluespec in System VerilogESEPro – Bluespec in SystemC

These lectures will use BSV syntax

5-minute break to stretch you legs

Page 15: February 14, 2007L04-1 Bluespec-1: Design methods to facilitate rapid growth of SoCs Arvind Computer Science & Artificial

February 14, 2007 L04-15http://csg.csail.mit.edu/6.375/

Bluespec SystemVerilog (BSV)Power to express complex static structures and constraints Checked by the compiler

“Micro-protocols” are managed by the compiler The necessary hardware for muxing and

control is generated automatically and is correct by construction

Easier to make changes while preserving correctness

Smaller, simpler, clearer, more correct code

not just simulation, synthesis as well

Page 16: February 14, 2007L04-1 Bluespec-1: Design methods to facilitate rapid growth of SoCs Arvind Computer Science & Artificial

February 14, 2007 L04-16http://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 17: February 14, 2007L04-1 Bluespec-1: Design methods to facilitate rapid growth of SoCs Arvind Computer Science & Artificial

February 14, 2007 L04-17http://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

3 6 subtract

6 3 swap

3 3 subtract

0 3 subtractanswer:

Page 18: February 14, 2007L04-1 Bluespec-1: Design methods to facilitate rapid growth of SoCs Arvind Computer Science & Artificial

February 14, 2007 L04-18http://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

Internalbehavior

GCD in BSV

Externalinterface

State

typedef int Int#(32)

Assumes x /= 0 and y /= 0

x y

swap sub

Page 19: February 14, 2007L04-1 Bluespec-1: Design methods to facilitate rapid growth of SoCs Arvind Computer Science & Artificial

February 14, 2007 L04-19http://csg.csail.mit.edu/6.375/

rdyenab

int

intrdy

star

tre

sult

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 Modulet

#(type t)

t

t

t tt

In a GCD call t could beInt#(32),UInt#(16),Int#(13), ...

The module can easily be made polymorphic

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

Page 20: February 14, 2007L04-1 Bluespec-1: Design methods to facilitate rapid growth of SoCs Arvind Computer Science & Artificial

February 14, 2007 L04-20http://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 21: February 14, 2007L04-1 Bluespec-1: Design methods to facilitate rapid growth of SoCs Arvind Computer Science & Artificial

February 14, 2007 L04-21http://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

Bluesim CycleAccurate

Blueview

Page 22: February 14, 2007L04-1 Bluespec-1: Design methods to facilitate rapid growth of SoCs Arvind Computer Science & Artificial

February 14, 2007 L04-22http://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 23: February 14, 2007L04-1 Bluespec-1: Design methods to facilitate rapid growth of SoCs Arvind Computer Science & Artificial

February 14, 2007 L04-23http://csg.csail.mit.edu/6.375/

Generated Hardware

next state values

predicates

x_en y_en

x_en = swap?y_en = swap? OR subtract?

x y

> !(=0)

swap? subtract?

sub

xy

enrdy

xrdy

start

resu

lt

Page 24: February 14, 2007L04-1 Bluespec-1: Design methods to facilitate rapid growth of SoCs Arvind Computer Science & Artificial

February 14, 2007 L04-24http://csg.csail.mit.edu/6.375/

Generated Hardware Module

x_en y_en

x_en = swap? OR start_eny_en = swap? OR subtract? OR start_en

x y

> !(=0)

swap? subtract?

sub

xy

enrdy

xrdy

start

resu

lt

rdy = (y==0)

start_en start_en

Page 25: February 14, 2007L04-1 Bluespec-1: Design methods to facilitate rapid growth of SoCs Arvind Computer Science & Artificial

February 14, 2007 L04-25http://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 26: February 14, 2007L04-1 Bluespec-1: Design methods to facilitate rapid growth of SoCs Arvind Computer Science & Artificial

February 14, 2007 L04-26http://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

Feeds all pairs (c1,c2) 1 < c1 < 71 < c2 < 15

to GCD

Page 27: February 14, 2007L04-1 Bluespec-1: Design methods to facilitate rapid growth of SoCs Arvind Computer Science & Artificial

February 14, 2007 L04-27http://csg.csail.mit.edu/6.375/

GCD: Synthesis results

Original (16 bits) Clock Period: 1.6 ns Area: 4240 m2

Unrolled (16 bits) Clock Period: 1.65ns Area: 5944 m2

Unrolled takes 31% fewer cycles on the testbench

Page 28: February 14, 2007L04-1 Bluespec-1: Design methods to facilitate rapid growth of SoCs Arvind Computer Science & Artificial

February 14, 2007 L04-28http://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 29: February 14, 2007L04-1 Bluespec-1: Design methods to facilitate rapid growth of SoCs Arvind Computer Science & Artificial

February 14, 2007 L04-29http://csg.csail.mit.edu/6.375/

module mkMult (I_mult); Reg#(Int#(32)) product <- mkReg(0); Reg#(Int#(16)) 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 ?

rule cycle (r != 0); if (r[0] == 1) product <= product + d; d <= d << 1; r <= r >> 1;endrule

method Action start (Int#(16)x,Int#(16)y) if (r == 0); d <= signExtend(x); r <= y;endmethod

method Int#(32) result () if (r == 0); return product;endmethod

Page 30: February 14, 2007L04-1 Bluespec-1: Design methods to facilitate rapid growth of SoCs Arvind Computer Science & Artificial

February 14, 2007 L04-30http://csg.csail.mit.edu/6.375/

SummaryMarket forces are demanding a much greater variety of SoCsThe design cost for SoCs has to be brought down dramatically by facilitating IP reuseHigh-level synthesis tools are essential for architectural exploration and IP developmentBluespec is both high-level and synthesizable

Next time: Combinational Circuits and Simple pipelines