Top Banner
1 OpenSoC Fabric An open source, parameterized, network generation tool Farzad Fatollahi-Fard, Dave Donofrio, George Michelogiannakis, John Shalf 8th International Symposium on Networks-on-Chip (NOCS) September 17-19, 2014. Ferrara, Italy. CoDEx
83

OpenSoC Fabric - Unifempsoc.unife.it/~nocsymposium/images/slides/tutorial.pdf · OpenSoC Fabric An open source, ... index or array 23 ... • x (optional) create a literal from Scala

May 29, 2018

Download

Documents

danghanh
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: OpenSoC Fabric - Unifempsoc.unife.it/~nocsymposium/images/slides/tutorial.pdf · OpenSoC Fabric An open source, ... index or array 23 ... • x (optional) create a literal from Scala

1

OpenSoC Fabric An open source, parameterized, network generation tool Farzad Fatollahi-Fard, Dave Donofrio, George Michelogiannakis, John Shalf 8th International Symposium on Networks-on-Chip (NOCS) September 17-19, 2014. Ferrara, Italy.

CoDEx

Page 2: OpenSoC Fabric - Unifempsoc.unife.it/~nocsymposium/images/slides/tutorial.pdf · OpenSoC Fabric An open source, ... index or array 23 ... • x (optional) create a literal from Scala

2

Motivation 1 Chisel Overview 2 Scala Crash Course 3 Chisel Deep Dive 4

OpenSoC Walk Through 6 Using OpenSoC 7 Interactive Session 8 Future Work 9

Interactive Session 5 Conclusion 10

Page 3: OpenSoC Fabric - Unifempsoc.unife.it/~nocsymposium/images/slides/tutorial.pdf · OpenSoC Fabric An open source, ... index or array 23 ... • x (optional) create a literal from Scala

Meet the OpenSoC Team

3

‣  Berkeley National Lab

‣  CoDEx

‣  CAL

‣  Farzad Fatollahi-Fard

‣  David Donofrio

‣  George Michelogiannakis

‣  John Shalf

Page 4: OpenSoC Fabric - Unifempsoc.unife.it/~nocsymposium/images/slides/tutorial.pdf · OpenSoC Fabric An open source, ... index or array 23 ... • x (optional) create a literal from Scala

4

A Radical Shift for the Future of Scientific Applications “…exascale computing (will) revolutionize our approaches to global challenges in energy, environmental sustainability, and security.” -E3 Report

Page 5: OpenSoC Fabric - Unifempsoc.unife.it/~nocsymposium/images/slides/tutorial.pdf · OpenSoC Fabric An open source, ... index or array 23 ... • x (optional) create a literal from Scala

Power: The New Design Constraint

5

‣  Power densities have ceased to increase

‣  No power efficiency increase with smaller transistors

Trends beginning in 2004 are continuing…

0

1

10

100

1,000

1975

1980

1985

1990

1995

2000

2005

2010

2015

2020

Watts�per�S

quare�cm

Historical�Single�Core Historical�MultiͲCoreITRS�Hi�Perf

100W�lightbulb

Hot�Plate

Nuclear�Reactor

1.E+01

1.E+02

1.E+03

1.E+04

1/1/92

1/1/96

1/1/00

1/1/04

1/1/08

1/1/12

1/1/16

Clock�(M

Hz)

Node�Processor�Clock�(MHz)�(H)Node�Processor�Clock�(MHz)�(L)Node�Processor�Clock�(MHz)�(M)Acclerator�Core�Clock�(MHz)�(H)Acclerator�Core�Clock�(MHz)�(L)Acclerator�Core�Clock�(MHz)�(M)Peter Kogge (Indiana University)

Page 6: OpenSoC Fabric - Unifempsoc.unife.it/~nocsymposium/images/slides/tutorial.pdf · OpenSoC Fabric An open source, ... index or array 23 ... • x (optional) create a literal from Scala

6

‣  We have come to the end of clock frequency scaling

‣  Moore’s Law is alive and well •  Now seeing core count

increasing

Power: The New Design Constraint On-chip parallelism increasing to maintain performance increases…

Peter Kogge (DARPA 2008 “Exascale Challenges” Report)

Page 7: OpenSoC Fabric - Unifempsoc.unife.it/~nocsymposium/images/slides/tutorial.pdf · OpenSoC Fabric An open source, ... index or array 23 ... • x (optional) create a literal from Scala

Parallelism increasing NERSC Trends

Franklin Hopper Edison Cori (NERSC 8)

Core Count 4 24 48 (logical) >60

Clock Rate 2.3GHz 2.1GHz 2.4 GHz ~1.5GHz

Memory 8GB 32GB 64GB 64-128GB

+On package

Peak Perf .352 PF 1.288 PF 2.57 PF > 3 TF

Page 8: OpenSoC Fabric - Unifempsoc.unife.it/~nocsymposium/images/slides/tutorial.pdf · OpenSoC Fabric An open source, ... index or array 23 ... • x (optional) create a literal from Scala

Hierarchical Power Costs

8

Data movement is the dominant power cost

120 pJ

2000 pJ

250 pJ

~2500 pJ

100 pJ

6 pJ

Cost to move data off chip to a neighboring node

Cost to move data off chip into DRAM

Cost to move off-chip, but stay within the package (SMP)

Cost to move data 20 mm on chip

Typical cost of a single floating point operation

Cost to move data 1 mm on-chip

Page 9: OpenSoC Fabric - Unifempsoc.unife.it/~nocsymposium/images/slides/tutorial.pdf · OpenSoC Fabric An open source, ... index or array 23 ... • x (optional) create a literal from Scala

9

What Interconnect Provides the Best Power / Performance Ratio? What tools exist to answer this question?

Page 10: OpenSoC Fabric - Unifempsoc.unife.it/~nocsymposium/images/slides/tutorial.pdf · OpenSoC Fabric An open source, ... index or array 23 ... • x (optional) create a literal from Scala

What tools exist for SoC research

‣  Software models •  Fast to create, but

plagued by long runtimes as system size increases

‣  Hardware emulation •  Fast, accurate evaluate

that scales with system size but suffers from long development time

What tools do we have to evaluate large, complex networks of cores?

A complexity-effective architecture for accelerating full-system multiprocessor simulations using FPGAs. FPGA 2008

Page 11: OpenSoC Fabric - Unifempsoc.unife.it/~nocsymposium/images/slides/tutorial.pdf · OpenSoC Fabric An open source, ... index or array 23 ... • x (optional) create a literal from Scala

Booksim

11

‣  C++ ‣  Cycle-accurate

‣  Verified against RTL

‣  Long runtimes limit simulation size •  Few thousand cycles

per second

Cycle-accurate on-chip network simulator

A detailed and flexible cycle-accurate network-on-chip simulator. ISPASS 2013

Page 12: OpenSoC Fabric - Unifempsoc.unife.it/~nocsymposium/images/slides/tutorial.pdf · OpenSoC Fabric An open source, ... index or array 23 ... • x (optional) create a literal from Scala

Garnet

12

‣  C++ ‣  Event-driven

‣  Verified against other network simulators

‣  Still not fast enough for thousand cores

Event-driven on-chip network simulator

GARNET: A detailed on-chip network model inside a full-system simulator. ISPASS 2009

Page 13: OpenSoC Fabric - Unifempsoc.unife.it/~nocsymposium/images/slides/tutorial.pdf · OpenSoC Fabric An open source, ... index or array 23 ... • x (optional) create a literal from Scala

Open-source NoC router RTL

13

‣  Parameterized Verilog •  Configuration can be

difficult

•  Adding new features high effort

‣  High effort for development

‣  Verilog simulation does not scale https://nocs.stanford.edu/cgi-bin/trac.cgi/wiki/Resources/

Router

localparam flit_ctrl_width = (packet_format == `PACKET_FORMAT_HEAD_TAIL) ? (1 + vc_idx_width + 1 + 1) : (packet_format == `PACKET_FORMAT_TAIL_ONLY) ? (1 + vc_idx_width + 1) : (packet_format == `PACKET_FORMAT_EXPLICIT_LENGTH) ? (1 + vc_idx_width + 1) : -1;

Page 14: OpenSoC Fabric - Unifempsoc.unife.it/~nocsymposium/images/slides/tutorial.pdf · OpenSoC Fabric An open source, ... index or array 23 ... • x (optional) create a literal from Scala

Connect: config network creation

14

‣  Verilog generator ‣  Optimized for FPGA

based networks ‣  Highly configurable •  Pre-defined options

•  Generator code in Bluspec

Hardware generator based on input parameters

CONNECT: fast flexible FPGA-tuned networks-on-chip. CARL 2012

Page 15: OpenSoC Fabric - Unifempsoc.unife.it/~nocsymposium/images/slides/tutorial.pdf · OpenSoC Fabric An open source, ... index or array 23 ... • x (optional) create a literal from Scala

15

Motivation 1 Chisel Overview 2 Scala Crash Course 3 Chisel Deep Dive 4

OpenSoC Walk Through 6 Using OpenSoC 7 Interactive Session 8 Future Work 9

Interactive Session 5 Conclusion 10

Page 16: OpenSoC Fabric - Unifempsoc.unife.it/~nocsymposium/images/slides/tutorial.pdf · OpenSoC Fabric An open source, ... index or array 23 ... • x (optional) create a literal from Scala

Chisel: A New Hardware DSL

‣  Chisel provides both software and hardware models from the same codebase

‣  Object-oriented hardware development •  Allows definition of

structs and other high-level constructs

‣  Powerful libraries and components ready to use

‣  Working processors fabricated using chisel

Using Scala to construct Verilog and C++ descriptions

Verilog

FPGA ASIC

Hardware Compilation

Software Compilation

SystemC Simulation

C++ Simulation

Scala

Chisel

Page 17: OpenSoC Fabric - Unifempsoc.unife.it/~nocsymposium/images/slides/tutorial.pdf · OpenSoC Fabric An open source, ... index or array 23 ... • x (optional) create a literal from Scala

Recent Chisel Designs

17

Chisel code successfully boots Linux

Clock test site

SRAM test site

DCDC test site

Processor Site

•  First tape-out in 2012 •  Raven core just taped out

in 2014 – 28nm

Page 18: OpenSoC Fabric - Unifempsoc.unife.it/~nocsymposium/images/slides/tutorial.pdf · OpenSoC Fabric An open source, ... index or array 23 ... • x (optional) create a literal from Scala

Chisel Overview

18

‣  Not “Scala to Gates” ‣  Describe hardware

functionality ‣  Chisel creates graph

representation •  Flattened

‣  Each node translated to Verilog or C++

How does Chisel work?

Algebraic Graph Construction 16

Mux(x > y, x, y) > Mux

x

y

Algebraic Graph Construction 16

Mux(x > y, x, y) > Mux

x

y

Page 19: OpenSoC Fabric - Unifempsoc.unife.it/~nocsymposium/images/slides/tutorial.pdf · OpenSoC Fabric An open source, ... index or array 23 ... • x (optional) create a literal from Scala

Chisel Overview

19

‣  All bit widths are inferred

‣  Clock and reset implied •  Multiple clock domains

possible

‣  IOs grouped into convenient bundles

How does Chisel work?

Creating Module 17

class Max2 extends Module {val io = new Bundle {val x = UInt(INPUT, 8)val y = UInt(INPUT, 8)val z = UInt(OUTPUT, 8) }

io.z := Mux(io.x > io.y, io.x, io.y)}

> Mux

x

y

z

Max

Creating Module 17

class Max2 extends Module {val io = new Bundle {val x = UInt(INPUT, 8)val y = UInt(INPUT, 8)val z = UInt(OUTPUT, 8) }

io.z := Mux(io.x > io.y, io.x, io.y)}

> Mux

x

y

z

Max

Page 20: OpenSoC Fabric - Unifempsoc.unife.it/~nocsymposium/images/slides/tutorial.pdf · OpenSoC Fabric An open source, ... index or array 23 ... • x (optional) create a literal from Scala

20

Motivation 1 Chisel Overview 2 Scala Crash Course 3 Chisel Deep Dive 4

OpenSoC Walk Through 6 Using OpenSoC 7 Interactive Session 8 Future Work 9

Interactive Session 5 Conclusion 10

Page 21: OpenSoC Fabric - Unifempsoc.unife.it/~nocsymposium/images/slides/tutorial.pdf · OpenSoC Fabric An open source, ... index or array 23 ... • x (optional) create a literal from Scala

Scala Crash Course

21

‣  Developed specifically for DSLs

‣  Strong typing

‣  Large community

‣  Object Oriented

‣  Functional Semantics

‣  Compiled to JVM

Page 22: OpenSoC Fabric - Unifempsoc.unife.it/~nocsymposium/images/slides/tutorial.pdf · OpenSoC Fabric An open source, ... index or array 23 ... • x (optional) create a literal from Scala

Scala Basics

‣  var vs val ‣  Common types •  Byte, Char, Int, Long, Float, Double

‣  All types are classes •  So support operators, such as: -  1.to(10) -> (1,2,3,4,5,6,7,8,9,10)

•  obj.method(arg) is equivalent to obj method arg

22

Variables, types

Page 23: OpenSoC Fabric - Unifempsoc.unife.it/~nocsymposium/images/slides/tutorial.pdf · OpenSoC Fabric An open source, ... index or array 23 ... • x (optional) create a literal from Scala

Scala Basics

‣  If / else •  If( x > 0) /* do stuff */ else /*do something else*/

‣  For •  for ( i <- 0 to n) // i traverses all values, including n

•  for (i <- 0 until n) // i traverses all values up to n-1

•  for (i <- “NoCs are Cool”) // i traverses all values in an index or array

23

Control Structures

Page 24: OpenSoC Fabric - Unifempsoc.unife.it/~nocsymposium/images/slides/tutorial.pdf · OpenSoC Fabric An open source, ... index or array 23 ... • x (optional) create a literal from Scala

Scala basics

‣  While •  while (n > 0){ /* do something */ }

‣  More interesting loop… •  for (i<-1 to 3; from = 4 – i; j <- from to 3)

print( (10 * i + j ) + ” ") -  Prints: 13 22 23 31 32 33

-  Note the need for semicolons

24

Control structures

Page 25: OpenSoC Fabric - Unifempsoc.unife.it/~nocsymposium/images/slides/tutorial.pdf · OpenSoC Fabric An open source, ... index or array 23 ... • x (optional) create a literal from Scala

Scala Basics

‣  Functions •  Last line is return function

•  def factorial( n : Int ) : Int = { var r = 1

for ( i <-1 to n ) r= r * i r

}

25

Function calls

Page 26: OpenSoC Fabric - Unifempsoc.unife.it/~nocsymposium/images/slides/tutorial.pdf · OpenSoC Fabric An open source, ... index or array 23 ... • x (optional) create a literal from Scala

Scala Basics

‣  Fixed Size Arrays •  Declared as: -  val a = new Array[String][10] //”10” is the size of the array

•  Accessed as -  a(3)

‣  Variable Sized Arrays – Array Buffers •  val b = new ArrayBuffer[Int]() •  Using: -  Insert, remove, trim, etc functions available -  b += 3 //add element to the end

26

Arrays and Maps

Page 27: OpenSoC Fabric - Unifempsoc.unife.it/~nocsymposium/images/slides/tutorial.pdf · OpenSoC Fabric An open source, ... index or array 23 ... • x (optional) create a literal from Scala

Scala Basics

‣  Maps •  val myMap = (key1 -> value1, key2 -> value2)

•  val myMutableMap = collection.mutable.Map(key1 –>val… •  Val myEmptyMap = new collection.mutable.HashMap[KeyType][ValueType]

•  Access as: myMap(key)

‣  Interesting functions for arrays (and other collections) •  sum() product() sortWith()

27

Arrays and Maps

Page 28: OpenSoC Fabric - Unifempsoc.unife.it/~nocsymposium/images/slides/tutorial.pdf · OpenSoC Fabric An open source, ... index or array 23 ... • x (optional) create a literal from Scala

Scala Basics

28

‣  Classes

•  Default to public

•  Get / set functions auto created

•  class Counter {

private var Value : Int = 0

def increment() { value += 1 }

def current() = value

}

Classes and Objects

‣  Use •  myCounter.increment()

•  myCounter.current

Page 29: OpenSoC Fabric - Unifempsoc.unife.it/~nocsymposium/images/slides/tutorial.pdf · OpenSoC Fabric An open source, ... index or array 23 ... • x (optional) create a literal from Scala

Scala Basics

‣  Objects are singletons •  Defines a single instance of a class with features you define

•  Often are companion objects to an identically named class

•  Example below will create a new unique account number

object Accounts {

private var lastNumber = 0

def newUniqueNumber() {lastNumber += 1; lastNumber}

} 29

Objects

Page 30: OpenSoC Fabric - Unifempsoc.unife.it/~nocsymposium/images/slides/tutorial.pdf · OpenSoC Fabric An open source, ... index or array 23 ... • x (optional) create a literal from Scala

Scala Basics

‣  Inheritance supported through extends keyword

‣  Abstract classes can be created to created to enforce an interface in derived classes •  Think virtual functions in C++

‣  Types inferred at runtime but can be checked using .isInstanceOf

‣  Casting can be done using the .asInstanceOf 30

A few more things to know…

Page 31: OpenSoC Fabric - Unifempsoc.unife.it/~nocsymposium/images/slides/tutorial.pdf · OpenSoC Fabric An open source, ... index or array 23 ... • x (optional) create a literal from Scala

Scala basics

‣  Type is always written after the variable •  val myStr : String = “NoCs are cool”

•  But type is typically not required – it is inferred by the compiler

‣  The apply function •  “NoCs are cool”(2) returns “C”

‣  No ternary function •  if / else used in place since “if” statement returns a value

‣  No semicolons needed (usually) 31

A few gotchas…

Page 32: OpenSoC Fabric - Unifempsoc.unife.it/~nocsymposium/images/slides/tutorial.pdf · OpenSoC Fabric An open source, ... index or array 23 ... • x (optional) create a literal from Scala

Scala Exercises

‣  <This is highly time dependent – would require participants to get their VM up and running. This may be a better time to do this than during the OpenSoC Example session>

32

Use the Scala REPL to try out a few Scala concepts

Page 33: OpenSoC Fabric - Unifempsoc.unife.it/~nocsymposium/images/slides/tutorial.pdf · OpenSoC Fabric An open source, ... index or array 23 ... • x (optional) create a literal from Scala

33

Motivation 1 Chisel Overview 2 Scala Crash Course 3 Chisel Deep Dive 4

OpenSoC Walk Through 6 Using OpenSoC 7 Interactive Session 8 Future Work 9

Interactive Session 5 Conclusion 10

Page 34: OpenSoC Fabric - Unifempsoc.unife.it/~nocsymposium/images/slides/tutorial.pdf · OpenSoC Fabric An open source, ... index or array 23 ... • x (optional) create a literal from Scala

Chisel Crash Course

34

‣  Chisel acts as a hardware generator •  Think about how data

would flow through the hardware described

•  This is a different mindset then describing an algorithm with C/C++

A few things to remember…

Creating Module 17

class Max2 extends Module {val io = new Bundle {val x = UInt(INPUT, 8)val y = UInt(INPUT, 8)val z = UInt(OUTPUT, 8) }

io.z := Mux(io.x > io.y, io.x, io.y)}

> Mux

x

y

z

Max

Creating Module 17

class Max2 extends Module {val io = new Bundle {val x = UInt(INPUT, 8)val y = UInt(INPUT, 8)val z = UInt(OUTPUT, 8) }

io.z := Mux(io.x > io.y, io.x, io.y)}

> Mux

x

y

z

Max

Page 35: OpenSoC Fabric - Unifempsoc.unife.it/~nocsymposium/images/slides/tutorial.pdf · OpenSoC Fabric An open source, ... index or array 23 ... • x (optional) create a literal from Scala

Chisel Basics

‣  Modules are at the top of the hierarchy •  Similar to Verilog modules

•  Can create sub-modules

‣  Wires used to connect Modules are Bundles •  Compile time configurable

•  Do not hold state, simply specify an interface

‣  Simple state elements – Reg, Mem, Queue included

35

Some preliminary concepts

Page 36: OpenSoC Fabric - Unifempsoc.unife.it/~nocsymposium/images/slides/tutorial.pdf · OpenSoC Fabric An open source, ... index or array 23 ... • x (optional) create a literal from Scala

Chisel Deep Dive

‣  Bool([x:Boolean]) ‣  Bits/UInt/SInt([x:Int/String], [width:Int]) •  x (optional) create a literal from Scala type/ pased String,

or declare unassigned if missing

•  width (optional) bit width (inferred if missing)

36

Basic Data Types

Page 37: OpenSoC Fabric - Unifempsoc.unife.it/~nocsymposium/images/slides/tutorial.pdf · OpenSoC Fabric An open source, ... index or array 23 ... • x (optional) create a literal from Scala

Chisel Deep Dive

‣  Vec •  Indexable vector of Data types •  val myVec = Vec(elts:Iterable[Data])

-  elts - initial element Data (vector depth inferred)

•  val myVec = Vec.fill(n:Int) {gen:Data} -  n - vector depth (elements)"

gen - initial element Data, called once per element

‣  Usage •  Elements can be dynamically or statically indexing

-  readVal := myVec(ind:Data/idx:Int)"myVec(ind:Data/idx:Int) := writeVal

37

Aggregate Types

Page 38: OpenSoC Fabric - Unifempsoc.unife.it/~nocsymposium/images/slides/tutorial.pdf · OpenSoC Fabric An open source, ... index or array 23 ... • x (optional) create a literal from Scala

Chisel Deep Dive

‣  Bundle •  Contains Data types indexed by name -  class MyBundle extends Bundle {"

val a = Bool ()" val b = UInt(width = 32) "

}

‣  Using val my_bundle = new MyBundle()"val bundleVal = my_bundle.a"my_bundle.a := Bool(true)

38

Aggregate Types

Page 39: OpenSoC Fabric - Unifempsoc.unife.it/~nocsymposium/images/slides/tutorial.pdf · OpenSoC Fabric An open source, ... index or array 23 ... • x (optional) create a literal from Scala

Chisel Deep Dive

‣  val x = UInt() •  Allocate as wire of type UInt()

‣  x := y •  Assign (connect) wire y to wire x

‣  x <> y •  Connect x and y (mostly for aggregate types)

•  Wire directionality is automatically inferred 39

Chisel Wire Operators

Page 40: OpenSoC Fabric - Unifempsoc.unife.it/~nocsymposium/images/slides/tutorial.pdf · OpenSoC Fabric An open source, ... index or array 23 ... • x (optional) create a literal from Scala

Chisel Deep Dive

40

‣  When •  Executes blocks

conditionally by Bool

•  Equivalent to Verilog if

‣  Switch •  Executes blocks

conditionally by data

Conditional Operators

when (condition1) { // run if condition1 true and skip rest

}  .elsewhen (condition2) { // run if condition2 true and skip rest

}  .unless (condition3) { // run if condition3 false and skip rest

}  .otherwise { // run if none of the above ran

}

switch(x) { is(value1) {

// run if x === value1 } is(value2) {

// run if x === value2 }

}

Page 41: OpenSoC Fabric - Unifempsoc.unife.it/~nocsymposium/images/slides/tutorial.pdf · OpenSoC Fabric An open source, ... index or array 23 ... • x (optional) create a literal from Scala

Chisel Deep Dive Bool Operators

Chisel Explanation Width

!x Logical NOT 1

x && y Logical AND 1

x || y Logical OR 1

Page 42: OpenSoC Fabric - Unifempsoc.unife.it/~nocsymposium/images/slides/tutorial.pdf · OpenSoC Fabric An open source, ... index or array 23 ... • x (optional) create a literal from Scala

Chisel Deep Dive Bits Operators

Chisel Explanation Width x(n) Extract bit, 0 is LSB 1

x(n, m) Extract bitfield n - m + 1 x << y Dynamic left shift Width(x)+MaxVal(y) x >> y Dynamic right shift Width(x)-MaxVal(y) x << n Static left shift Width(x) + n x >> n Static right shift Width(x) - n

Fill(n, x) Replicate x, n times n * Width(x) Cat(x, y) Concatenate bits Width(x) + Width(y)

Mux(c, x, y) If c, then x; else y MaxWidth(x,y)

Page 43: OpenSoC Fabric - Unifempsoc.unife.it/~nocsymposium/images/slides/tutorial.pdf · OpenSoC Fabric An open source, ... index or array 23 ... • x (optional) create a literal from Scala

Chisel Deep Dive Bits Operators

Chisel Explanation Width ~x Bitwise NOT Width(x)

x & y Bitwise AND MaxWidth(x, y) x | y Bitwise OR MaxWidth(x, y) x ^ y Bitwise XOR MaxWidth(x, y)

x === y Equality 1 x != y Inequality 1

andR(x) AND-reduce 1 orR(x) OR-reduce 1 xorR(x) XOR-reduce 1

Page 44: OpenSoC Fabric - Unifempsoc.unife.it/~nocsymposium/images/slides/tutorial.pdf · OpenSoC Fabric An open source, ... index or array 23 ... • x (optional) create a literal from Scala

Chisel Deep Dive UInt/SInt Operators

Chisel Explanation Width x + y Bitwise NOT MaxWidth(x, y) x - y Bitwise AND MaxWidth(x, y) x * y Bitwise OR Width(x) + Width(y) x / y Bitwise XOR Width(x)

x % y Equality MaxVal(y) - 1 x > y Inequality 1

x >= y AND-reduce 1 x < y OR-reduce 1

x <= y XOR-reduce 1

Page 45: OpenSoC Fabric - Unifempsoc.unife.it/~nocsymposium/images/slides/tutorial.pdf · OpenSoC Fabric An open source, ... index or array 23 ... • x (optional) create a literal from Scala

Chisel Deep Dive UInt/SInt Operators

Chisel Explanation Width

x >> y Arithmetic right shift Width(x) – MinVal(y)

x >> n Arithmetic right shift Width(x) - n

Page 46: OpenSoC Fabric - Unifempsoc.unife.it/~nocsymposium/images/slides/tutorial.pdf · OpenSoC Fabric An open source, ... index or array 23 ... • x (optional) create a literal from Scala

Chisel Deep Dive

‣  Registers •  val my_reg = Reg([outType:Data], [next:Data], [init:Data])

outType (optional) - register type (or inferred)

next (optional) - update value every clock

init (optional) - initialization value on reset

‣  Updating •  my_reg := next_val

Assign to latch new value on next clock 46

State Elements

Page 47: OpenSoC Fabric - Unifempsoc.unife.it/~nocsymposium/images/slides/tutorial.pdf · OpenSoC Fabric An open source, ... index or array 23 ... • x (optional) create a literal from Scala

Chisel Deep Dive

‣  Read-Write Memory •  val my_mem = Mem(out:Data, n:Int, seqRead:Boolean)

out - memory element type

n - memory depth (elements)

seqRead - only update reads on clock edge

‣  Using •  Reads: val readVal = mem(addr:UInt/Int)

•  Writes: mem(addr:UInt/Int) := y 47

State Elements

Page 48: OpenSoC Fabric - Unifempsoc.unife.it/~nocsymposium/images/slides/tutorial.pdf · OpenSoC Fabric An open source, ... index or array 23 ... • x (optional) create a literal from Scala

Chisel Deep Dive

48

Creating a Module

‣  Class must extend Module class •  Abstract classes legal

‣  IO ports listed as a Bundle with directions and widths specified

Creating Module 17

class Max2 extends Module {val io = new Bundle {val x = UInt(INPUT, 8)val y = UInt(INPUT, 8)val z = UInt(OUTPUT, 8) }

io.z := Mux(io.x > io.y, io.x, io.y)}

> Mux

x

y

z

Max

Creating Module 17

class Max2 extends Module {val io = new Bundle {val x = UInt(INPUT, 8)val y = UInt(INPUT, 8)val z = UInt(OUTPUT, 8) }

io.z := Mux(io.x > io.y, io.x, io.y)}

> Mux

x

y

z

Max

Page 49: OpenSoC Fabric - Unifempsoc.unife.it/~nocsymposium/images/slides/tutorial.pdf · OpenSoC Fabric An open source, ... index or array 23 ... • x (optional) create a literal from Scala

Chisel Deep Dive

49

Connecting Modules – Simplest way is to assign each individual element in the IO bundle

Connecting Modules 18

val m1 =Module(new Max2())

m1.io.x := am1.io.y := bval m2 =Module(new Max2())

m2.io.x := cm2.io.y := dval m3 =Module(new Max2())

m3.io.x := m1.io.zm3.io.y := m2.io.z

> Mux

x

y

z

> Mux

x

y

z

> Mux

x

y

z

c

d

b

a

m1

m2

m3

Page 50: OpenSoC Fabric - Unifempsoc.unife.it/~nocsymposium/images/slides/tutorial.pdf · OpenSoC Fabric An open source, ... index or array 23 ... • x (optional) create a literal from Scala

Chisel Deep Dive

50

Using the Chisel bulk connection interface to connect routers

class Router extends Module {!val io = new Bundle {!val InChannel = new Channel()!val OutChannels =new Channel()!

}!}! class Network extends Module {!val Router1 = new Router val Router2 = new Router!!Router1.io.inChannel <> Router2.io.outChannel!Router1.io.outChannel <> Router2.io.inChannel!

Page 51: OpenSoC Fabric - Unifempsoc.unife.it/~nocsymposium/images/slides/tutorial.pdf · OpenSoC Fabric An open source, ... index or array 23 ... • x (optional) create a literal from Scala

Chisel Deep Dive

‣  Functions •  Provide block abstractions for code -  def Adder(op_a:UInt, op_b:UInt): UInt = { op_a + op_b }

•  Hardware is instantiated when called -  sum := Adder(UInt(1), some_data)

‣  If/For •  Used to control hardware generation

•  Equivalent to Verilog generate if/for 51

Hardware Generation

Page 52: OpenSoC Fabric - Unifempsoc.unife.it/~nocsymposium/images/slides/tutorial.pdf · OpenSoC Fabric An open source, ... index or array 23 ... • x (optional) create a literal from Scala

Chisel Deep Dive

‣  Function Blocks •  Stateless: UIntToOH, OHToUInt, Reverse, PopCount, etc

•  Stateful: LFSR16, ShiftRegister

‣  Interfaces •  DecoupledIO, ValidIO, Queue, Pipe, Arbiter

52

Standard Library

Page 53: OpenSoC Fabric - Unifempsoc.unife.it/~nocsymposium/images/slides/tutorial.pdf · OpenSoC Fabric An open source, ... index or array 23 ... • x (optional) create a literal from Scala

Chisel Deep Dive

‣  Class with functions for testing Modules, connecting and communicating with a simulator •  reset

•  step

•  poke

•  peek

•  expect 53

Tester

Page 54: OpenSoC Fabric - Unifempsoc.unife.it/~nocsymposium/images/slides/tutorial.pdf · OpenSoC Fabric An open source, ... index or array 23 ... • x (optional) create a literal from Scala

54

Motivation 1 Chisel Overview 2 Scala Crash Course 3 Chisel Deep Dive 4

OpenSoC Walk Through 6 Using OpenSoC 7 Interactive Session 8 Future Work 9

Interactive Session 5 Conclusion 10

Page 55: OpenSoC Fabric - Unifempsoc.unife.it/~nocsymposium/images/slides/tutorial.pdf · OpenSoC Fabric An open source, ... index or array 23 ... • x (optional) create a literal from Scala

Build a NxN Switch

‣  Open VM ‣  Navigate to •  ~/opensoc-demo/switch-demo/

‣  Switch Code and tester in: •  src/main/scala/switch.scala

‣  To test your code run: sbt run

55

Page 56: OpenSoC Fabric - Unifempsoc.unife.it/~nocsymposium/images/slides/tutorial.pdf · OpenSoC Fabric An open source, ... index or array 23 ... • x (optional) create a literal from Scala

56

Motivation 1 Chisel Overview 2 Scala Crash Course 3 Chisel Deep Dive 4

OpenSoC Walk Through 6 Using OpenSoC 7 Interactive Session 8 Future Work 9

Interactive Session 5 Conclusion 10

Page 57: OpenSoC Fabric - Unifempsoc.unife.it/~nocsymposium/images/slides/tutorial.pdf · OpenSoC Fabric An open source, ... index or array 23 ... • x (optional) create a literal from Scala

OpenSoC Fabric

‣  Part of the CoDEx tool suite, written in Chisel ‣  Dimensions, topology, VCs all configurable

‣  Fast functional C++ model for functional validation •  SystemC ready

‣  Verilog based description for FPGA or ASIC •  Synthesis path enables accurate power / energy modeling

‣  AXI Based endpoints •  Ready for ARM integration

57

An open source, flexible, parameterized, NoC generator

Page 58: OpenSoC Fabric - Unifempsoc.unife.it/~nocsymposium/images/slides/tutorial.pdf · OpenSoC Fabric An open source, ... index or array 23 ... • x (optional) create a literal from Scala

OpenSoC Fabric An open source, flexible, parameterized, NoC generator

AXIOpenSoC

FabricCPU(s)

HMC

AXI

AXI

CPU(s)

AXI CPU(s)AXI

CPU(s)

AXI

CPU(s)

AXI

AXI

10GbE

PCIe

Page 59: OpenSoC Fabric - Unifempsoc.unife.it/~nocsymposium/images/slides/tutorial.pdf · OpenSoC Fabric An open source, ... index or array 23 ... • x (optional) create a literal from Scala

OpenSoC: Current Status

59

‣  On your Flash Drive:

•  2-D concentrated mesh network of arbitrary size

•  Wormhole routing

‣  Included in 1.0 Release

•  Virtual Channels

•  AXI Interface

•  Additional Topologies

Projected v1.0 release date of October 1st

Page 60: OpenSoC Fabric - Unifempsoc.unife.it/~nocsymposium/images/slides/tutorial.pdf · OpenSoC Fabric An open source, ... index or array 23 ... • x (optional) create a literal from Scala

OpenSoC – Top Level Diagram

60

Page 61: OpenSoC Fabric - Unifempsoc.unife.it/~nocsymposium/images/slides/tutorial.pdf · OpenSoC Fabric An open source, ... index or array 23 ... • x (optional) create a literal from Scala

OpenSoC – Functional Hierarchy

61

Page 62: OpenSoC Fabric - Unifempsoc.unife.it/~nocsymposium/images/slides/tutorial.pdf · OpenSoC Fabric An open source, ... index or array 23 ... • x (optional) create a literal from Scala

62

Motivation 1 Chisel Overview 2 Scala Crash Course 3 Chisel Deep Dive 4

OpenSoC Walk Through 6 Using OpenSoC 7 Interactive Session 8 Future Work 9

Interactive Session 5 Conclusion 10

Page 63: OpenSoC Fabric - Unifempsoc.unife.it/~nocsymposium/images/slides/tutorial.pdf · OpenSoC Fabric An open source, ... index or array 23 ... • x (optional) create a literal from Scala

63

OpenSoC Top Level Modules

Page 64: OpenSoC Fabric - Unifempsoc.unife.it/~nocsymposium/images/slides/tutorial.pdf · OpenSoC Fabric An open source, ... index or array 23 ... • x (optional) create a literal from Scala

OpenSoC – Functional Hierarchy

64

Page 65: OpenSoC Fabric - Unifempsoc.unife.it/~nocsymposium/images/slides/tutorial.pdf · OpenSoC Fabric An open source, ... index or array 23 ... • x (optional) create a literal from Scala

OpenSoC – Top Level Modules

‣  Stiches routers together ‣  Assigns routers individual ID

‣  Assigns Routing Function to routers

‣  Connections Injection and Ejection Queues for network endpoints

65

Topology

Page 66: OpenSoC Fabric - Unifempsoc.unife.it/~nocsymposium/images/slides/tutorial.pdf · OpenSoC Fabric An open source, ... index or array 23 ... • x (optional) create a literal from Scala

OpenSoC – Functional Hierarchy

66

Page 67: OpenSoC Fabric - Unifempsoc.unife.it/~nocsymposium/images/slides/tutorial.pdf · OpenSoC Fabric An open source, ... index or array 23 ... • x (optional) create a literal from Scala

OpenSoC Top Level Modules

‣  Created and connected by Topology module ‣  Instantiates and connects: •  Routing Function

•  Allocators

•  Switch

‣  Created as a 3 stage pipeline •  Includes state storage for each sub-module

‣  Connects to Injection / Ejection Queues 67

Router

Page 68: OpenSoC Fabric - Unifempsoc.unife.it/~nocsymposium/images/slides/tutorial.pdf · OpenSoC Fabric An open source, ... index or array 23 ... • x (optional) create a literal from Scala

OpenSoC – Functional Hierarchy

68

Page 69: OpenSoC Fabric - Unifempsoc.unife.it/~nocsymposium/images/slides/tutorial.pdf · OpenSoC Fabric An open source, ... index or array 23 ... • x (optional) create a literal from Scala

OpenSoC – Top Level Modules

‣  Collection of Arbiters •  Currently all arbiters are round-robin, locking

•  Arbitration policy configurable

‣  Interface to credit logic

‣  Wormhole router has single allocator

‣  VC router has two allocators •  Same module, controls both switch allocation and VC

allocation

69

Allocator

Page 70: OpenSoC Fabric - Unifempsoc.unife.it/~nocsymposium/images/slides/tutorial.pdf · OpenSoC Fabric An open source, ... index or array 23 ... • x (optional) create a literal from Scala

OpenSoC - Configuring

‣  OpenSoC configured at run time through Parameters class

•  Declared at top level, sub modules can add / change parameters tree

•  Hard parameters may not be changed by sub-modules

•  Soft parameters may be changed by sub-modules

‣  Not limited to just integer values

•  Leverage Scala to pass functions to parameterize module creation -  Example: Routing Function constructor passed as parameter to

router 70

Parameters

Page 71: OpenSoC Fabric - Unifempsoc.unife.it/~nocsymposium/images/slides/tutorial.pdf · OpenSoC Fabric An open source, ... index or array 23 ... • x (optional) create a literal from Scala

OpenSoC - Configuring

‣  All OpenSoC Modules take a Parameters class as a constructor argument

‣  Setting parameters: •  parms.child("MySwitch", Map( ("numInPorts"->Soft(8)),

("numOutPorts"->Soft(3) ))

‣  Getting a parameter: •  val numInPorts = parms.get[Int]("numInPorts")

71

Parameters

Page 72: OpenSoC Fabric - Unifempsoc.unife.it/~nocsymposium/images/slides/tutorial.pdf · OpenSoC Fabric An open source, ... index or array 23 ... • x (optional) create a literal from Scala

OpenSoC Data Formats

72

‣  Head Flit •  Packet ID

•  Is Tail

•  Vc Port

•  Packet Type

•  Destination -  Chisel Vec

Flits – All data widths inferred or described at runtime

‣  Body Flit •  Packet ID

•  Is Tail

•  Vc Port

•  Flit ID

•  Payload

Page 73: OpenSoC Fabric - Unifempsoc.unife.it/~nocsymposium/images/slides/tutorial.pdf · OpenSoC Fabric An open source, ... index or array 23 ... • x (optional) create a literal from Scala

OpenSoC Data Formats

73

Packets

Data Field Source Address

Dest Address Total Length Packet Length Additional Flags

PacketID Command Command Options Reserved for Debug

Payload Phase 0 …

Payload Phase N

Page 74: OpenSoC Fabric - Unifempsoc.unife.it/~nocsymposium/images/slides/tutorial.pdf · OpenSoC Fabric An open source, ... index or array 23 ... • x (optional) create a literal from Scala

74

OpenSoC Demo

Page 75: OpenSoC Fabric - Unifempsoc.unife.it/~nocsymposium/images/slides/tutorial.pdf · OpenSoC Fabric An open source, ... index or array 23 ... • x (optional) create a literal from Scala

75

Motivation 1 Chisel Overview 2 Scala Crash Course 3 Chisel Deep Dive 4

OpenSoC Walk Through 6 Using OpenSoC 7 Interactive Session 8 Future Work 9

Interactive Session 5 Conclusion 10

Page 76: OpenSoC Fabric - Unifempsoc.unife.it/~nocsymposium/images/slides/tutorial.pdf · OpenSoC Fabric An open source, ... index or array 23 ... • x (optional) create a literal from Scala

Build a Network

‣  Open VM ‣  Navigate to •  ~/opensoc-demo/opensoc/

‣  Two Tests to Run •  ./OpenSoC_CMesh_Random_C1.sh -  Packets go to a random destination

•  ./OpenSoC_CMesh_Neighbor_C1.sh -  Packets go to neighboring router

76

For a concentration of 1

Page 77: OpenSoC Fabric - Unifempsoc.unife.it/~nocsymposium/images/slides/tutorial.pdf · OpenSoC Fabric An open source, ... index or array 23 ... • x (optional) create a literal from Scala

Build a Network

‣  Open VM ‣  Navigate to •  ~/opensoc-demo/opensoc/

‣  Change concentration of network to 2 •  Edit src/main/scala/main.scala to update val C

‣  Test to Run •  ./OpenSoC_CMesh_Random_C2.sh -  Packets go to a random destination

77

For a concentration of 2

Page 78: OpenSoC Fabric - Unifempsoc.unife.it/~nocsymposium/images/slides/tutorial.pdf · OpenSoC Fabric An open source, ... index or array 23 ... • x (optional) create a literal from Scala

78

Motivation 1 Chisel Overview 2 Scala Crash Course 3 Chisel Deep Dive 4

OpenSoC Walk Through 6 Using OpenSoC 7 Interactive Session 8 Future Work 9

Interactive Session 5 Conclusion 10

Page 79: OpenSoC Fabric - Unifempsoc.unife.it/~nocsymposium/images/slides/tutorial.pdf · OpenSoC Fabric An open source, ... index or array 23 ... • x (optional) create a literal from Scala

Future additions

‣  A collection of topologies and routing functions ‣  An easy way to adjust router pipeline stages

‣  Validation against other RTL or simulators

‣  Standardized interfaces at the endpoints •  (e.g., AXI)

‣  More powerful synthetic traffic and trace replay support

‣  Power modeling in the C++ model 79

Towards a full set of features

Page 80: OpenSoC Fabric - Unifempsoc.unife.it/~nocsymposium/images/slides/tutorial.pdf · OpenSoC Fabric An open source, ... index or array 23 ... • x (optional) create a literal from Scala

80

Motivation 1 Chisel Overview 2 Scala Crash Course 3 Chisel Deep Dive 4

OpenSoC Walk Through 6 Using OpenSoC 7 Interactive Session 8 Future Work 9

Interactive Session 5 Conclusion 10

Page 81: OpenSoC Fabric - Unifempsoc.unife.it/~nocsymposium/images/slides/tutorial.pdf · OpenSoC Fabric An open source, ... index or array 23 ... • x (optional) create a literal from Scala

Conclusion

‣  This is an open-source community-driven infrastructure •  We are counting on your contributions

81

Page 82: OpenSoC Fabric - Unifempsoc.unife.it/~nocsymposium/images/slides/tutorial.pdf · OpenSoC Fabric An open source, ... index or array 23 ... • x (optional) create a literal from Scala

Acknowledgements

‣  UCB Chisel ‣  US Dept of Energy

‣  Ke Wen

‣  Columbia LRL

‣  John Bachan

‣  Dan Burke

‣  BWRC

82

Page 83: OpenSoC Fabric - Unifempsoc.unife.it/~nocsymposium/images/slides/tutorial.pdf · OpenSoC Fabric An open source, ... index or array 23 ... • x (optional) create a literal from Scala

83

More Information http://opensocfabric.org