1 of 39

Chisel and FIRRTL for next-generation SoC designs

Jack Koenig�SiFive�CWG TAC Member

1

4/19/22

© 2020 SiFive. All Rights Reserved.

2 of 39

Introduction�

What is the Chisel Working Group (CWG)?

2

4/19/22

© 2020 SiFive. All Rights Reserved.

3 of 39

What is Chisel?

  • Constructing Hardware In a Scala Embedded Language
  • Domain Specific Language where the domain is digital design
  • NOT high-level synthesis (HLS) nor behavioral synthesis
  • Write Scala program to construct and connect hardware objects
    • Parameterized types
    • Object-Oriented Programming
    • Functional Programming
    • Static Typing w/ Powerful Type Inference
  • Intended for writing reusable hardware generators (libraries)

3

4/19/22

© 2020 SiFive. All Rights Reserved.

4 of 39

No Loss of Expressibility: “Verilog-like” Chisel

FIR Filter - 3-point moving sum

What about >3 points?�What about weighted averages?

We want a generic FIR filter!

​

​

4

4/19/22

© 2020 SiFive. All Rights Reserved.

5 of 39

Massive Increase in Parameterizability: “Software-like” Chisel

FIR Filter - Parameterized by bitwidth and coeffients with no loss of expressibility or performance.

Meta-programming enables powerful parameterization.

5

4/19/22

© 2020 SiFive. All Rights Reserved.

6 of 39

Massive Increase in Parameterizability: “Software-like” Chisel

FIR Filter - Parameterized by bitwidth and coeffients with no loss of expressibility or performance.

Meta-programming enables powerful parameterization.

6

4/19/22

© 2020 SiFive. All Rights Reserved.

7 of 39

Platform-Specific or Application-Specific RTL Changes

7

4/19/22

IBM 45nm SOI

ST 28nm FDSOI

Zynq FPGA

​

​

Chip RTL

+ scan interface

+ snapshotting

+ interactive debug

+ clock-generators

+ SRAMs with init

+ specialized layout

+ SRAM macros

+ modified module hierarchy

+ specialized layout

© 2020 SiFive. All Rights Reserved.

8 of 39

Realization: We need a software stack, but for hardware

8

4/19/22

libraries

language

compiler

platforms

projects

x86

ARM

RISC-V

transforms

clang

Hwacha

Rocket

BOOM

rocketchip

chisel-utils

FIRRTL

Chisel Frontend

© 2020 SiFive. All Rights Reserved.

9 of 39

FIRRTL: An Extensible Hardware Compiler Framework

9

4/19/22

Modular Compiler Passes (Transforms)

Top

MyMux

...

...

Top

MyMux

...

...

Top

MyMux

...

...

Core

Transform

Custom

Transform

Metadata

Annotations

Metadata

Annotations

Metadata

Annotations

Robust Metadata/Annotations Support

© 2020 SiFive. All Rights Reserved.

10 of 39

Projects of the Chisel Working Group

  • Chisel 3
  • FIRRTL
  • ChiselTest (formerly Chisel Testers 2)
  • Treadle
  • Chisel Bootcamp
  • Chisel Template

​

  • Chisel IOTesters
  • DSP Tools
  • Diagrammer

​

​

10

4/19/22

© 2020 SiFive. All Rights Reserved.

11 of 39

Highlights

11

4/19/22

© 2020 SiFive. All Rights Reserved.

12 of 39

Chisel v3.5.0 – v3.5.2 Released!

  • Lightning Highlights
    • Vec literal support
    • Scala 2.13 support (2.11 EOL)
    • Decoder + minimizer API in chisel3.util (w/ Espresso integration)
    • Source locator compacting
    • Many performance improvements
      • Chisel ~40-50% faster, FIRRTL ~20% faster
    • New Utilities – Gray code, scanLeftOr
    • RTL-IL backend

​

12

4/19/22

See release notes on Github!

© 2020 SiFive. All Rights Reserved.

13 of 39

Chisel v3.5.0 – v3.5.2 Released!

  • Lightning Highlights
    • Vec literal support
    • Scala 2.13 support (2.11 EOL)
    • Decoder + minimizer API in chisel3.util (w/ Espresso integration)
    • Source locator compacting
    • Many performance improvements
      • Chisel ~40-50% faster, FIRRTL ~20% faster
    • New Utilities – Gray code, scanLeftOr
    • RTL-IL backend
  • Digital Design with Chisel 3rd ed. by Martin Schoeberl

​

​

13

4/19/22

See release notes on Github!

© 2020 SiFive. All Rights Reserved.

14 of 39

ChiselTest Improvements

  • Simpler peek/poke with Scala types
  • Improved Verilator simulation performance via JNA
  • Verilator backend now supports dumping FST instead of VCD
  • PeekPokeTester compatibility API
    • Helps migrate users off old chisel-iotesters
  • Simulation constructs can now be annotated
  • assert/assume/cover graduated out of experimental
  • Simulation binary caching
  • Support for bounded model checking (next slide)

​

14

4/19/22

© 2020 SiFive. All Rights Reserved.

15 of 39

Native Formal Verification Support

  • Formal verification is assumed to be difficult for users
  • Good tooling and sensible defaults can help
    • Similar to simulator-based flow
    • Safe past function
    • Automatic reset guarding (default but disableable)
  • Close integration with simulation testing flow
    • Same basic APIs
    • Same IDE and tooling integration
  • Automatically runs counter examples through a simulator to provide a waveform
  • Native FIRRTL -> SMTLib or btor2 output
  • Works with Z3 and CVC4

15

4/19/22

© 2020 SiFive. All Rights Reserved.

16 of 39

Native Formal Verification Support

  • Formal verification is assumed to be difficult for users
  • Good tooling and sensible defaults can help
    • Similar to simulator-based flow
    • Safe past function
    • Automatic reset guarding (default but disableable)
  • Close integration with simulation testing flow
    • Same basic APIs
    • Same IDE and tooling integration
  • Automatically runs counter examples through a simulator to provide a waveform
  • Native FIRRTL -> SMTLib or btor2 output
  • Works with Z3 and CVC4

16

4/19/22

© 2020 SiFive. All Rights Reserved.

17 of 39

Definition / Instance

  • Historically, Chisel elaborates every module instance and then deduplicates structurally equivalent modules
  • New experimental API for definining (and elaborating) a module once and instantiating multiple times
    • Definition – Elaborates implementation of module
    • Instance – Merely instantiates public API
  • Major performance optimization for very large or hierarchical designs
  • Composes with cross-module reference annotations
  • Experimental – undergoing active development

17

4/19/22

© 2020 SiFive. All Rights Reserved.

18 of 39

Definition / Instance

  • Historically, Chisel elaborates every module instance and then deduplicates structurally equivalent modules
  • New experimental API for definining (and elaborating) a module once and instantiating multiple times
    • Definition – Elaborates implementation of module
    • Instance – Merely instantiates public API
  • Major performance optimization for very large or hierarchical designs
  • Composes with cross-module reference annotations
  • Experimental – undergoing active development

​

18

4/19/22

© 2020 SiFive. All Rights Reserved.

19 of 39

Definition / Instance

  • Historically, Chisel elaborates every module instance and then deduplicates structurally equivalent modules
  • New experimental API for definining (and elaborating) a module once and instantiating multiple times
    • Definition – Elaborates implementation of module
    • Instance – Merely instantiates public API
  • Major performance optimization for very large or hierarchical designs
  • Composes with cross-module reference annotations
  • Experimental – undergoing active development

​

19

4/19/22

© 2020 SiFive. All Rights Reserved.

20 of 39

DataView

  • Often users want to manipulate hardware values as if they were a different type
    • AXI-style flat bus interface used as more structured hierarchy
  • Allows treating objects of one type as another
  • A superpowered union or cast, like View in SQL
  • Used to implement:

20

4/19/22

© 2020 SiFive. All Rights Reserved.

21 of 39

DataView

  • Often users want to manipulate hardware values as if they were a different type
    • AXI-style flat bus interface used as more structured hierarchy
  • Allows treating objects of one type as another
  • A superpowered union or cast, like View in SQL
  • Used to implement:
    • Seamless integration with Scala types

21

4/19/22

© 2020 SiFive. All Rights Reserved.

22 of 39

DataView

  • Often users want to manipulate hardware values as if they were a different type
    • AXI-style flat bus interface used as more structured hierarchy
  • Allows treating objects of one type as another
  • A superpowered union or cast, like View in SQL
  • Used to implement:
    • Seamless integration with Scala types
    • Bundle upcasting

22

4/19/22

© 2020 SiFive. All Rights Reserved.

23 of 39

DataView

  • Often users want to manipulate hardware values as if they were a different type
    • AXI-style flat bus interface used as more structured hierarchy
  • Allows treating objects of one type as another
  • A superpowered union or cast, like View in SQL
  • Used to implement:
    • Seamless integration with Scala types
    • Bundle upcasting
    • User-defined mappings between types

23

4/19/22

© 2020 SiFive. All Rights Reserved.

24 of 39

DataView

  • Often users want to manipulate hardware values as if they were a different type
    • AXI-style flat bus interface used as more structured hierarchy
  • Allows treating objects of one type as another
  • A superpowered union or cast, like View in SQL
  • Used to implement:
    • Seamless integration with Scala types
    • Bundle upcasting
    • User-defined mappings between types
    • Strip io_ prefix

24

4/19/22

New in 3.5.3

© 2020 SiFive. All Rights Reserved.

25 of 39

Realization: We need a software stack, but for hardware

25

4/19/22

libraries

language

compiler

platforms

projects

x86

ARM

RISC-V

transforms

clang

Hwacha

Rocket

BOOM

rocketchip

chisel-utils

FIRRTL

Chisel Frontend

© 2020 SiFive. All Rights Reserved.

26 of 39

It is a lot of work to build and maintain a software stack

26

4/19/22

libraries

language

compiler

platforms

projects

x86

ARM

RISC-V

transforms

clang

Hwacha

Rocket

BOOM

rocketchip

chisel-utils

FIRRTL

Chisel Frontend

Metadata /

Annotations

Custom

Infrastructure

© 2020 SiFive. All Rights Reserved.

27 of 39

It is a lot of work to build and maintain a software stack

27

4/19/22

libraries

language

compiler

platforms

projects

x86

ARM

RISC-V

transforms

clang

Hwacha

Rocket

BOOM

rocketchip

chisel-utils

FIRRTL

Chisel Frontend

Metadata /

Annotations

Shared

Infrastructure

Custom

Infrastructure

CIRCT

Multiple

Dialects

© 2020 SiFive. All Rights Reserved.

28 of 39

What is MLIR?

  • “Multi-Level IR”
  • A generalization of LLVM
    • Part of the LLVM project
  • Infrastructure for building new compilers
  • Suitable for building new IRs
  • Can handle multiple IRs at once
  • Written in C++
  • Extremely performant

​

28

4/19/22

© 2020 SiFive. All Rights Reserved.

29 of 39

CIRCT: Circuit IR for Compilers and Tools

  • What is CIRCT (pronounced “circuit”)?
  • An LLVM incubator project
  • Compiler infrastructure for generating Verilog
  • A collection of hardware dialects
    • FIRRTL Dialect
    • SystemVerilog Dialect*
    • RTL Dialects
      • Combinational
      • Sequential
      • Hardware
    • Timing Insensitive Dialects
      • Elastic Silicon Interconnect (ESI)
      • Handshake
  • A collection of tools for compiling circuits
    • e.g., firtool is a drop in replacement for firrtl

​

29

4/19/22

© 2020 SiFive. All Rights Reserved.

30 of 39

What does this mean for Chisel?

  • Next generation FIRRTL compiler
  • Faster compilation (5-10x)
  • Less memory (5-10x)
  • Better Verilog emission
  • Robust platform for new features
  • Starting in Chisel 3.6
    • Built-in support for CIRCT
  • Starting in Chisel 3.7
    • Closer integration with CIRCT
    • CIRCT-first features

​

​

​

​

​

30

4/19/22

7.6x

1.9x

4.3x

© 2020 SiFive. All Rights Reserved.

31 of 39

Community

31

4/19/22

© 2020 SiFive. All Rights Reserved.

32 of 39

Get Involved

32

4/19/22

www.chisel-lang.org

Chat with us on Gitter

Ask questions on StackOverflow

Watch talks on YouTube

Also check out CIRCT

circt.llvm.org

© 2020 SiFive. All Rights Reserved.

33 of 39

Extra / Old Slides

33

4/19/22

© 2020 SiFive. All Rights Reserved.

34 of 39

AutoCloneType2

34

4/19/22

  • cloneType is an implementation detail that leaks into the user API (since original Chisel)
  • Useless boilerplate
  • Original AutoCloneType works okay but has some limitations
    • Parameters must be defined as “vals”
    • Works in typical use cases but not all use cases
    • Slow
  • The Chisel compiler plugin now generates cloneType for all Bundles
  • Available in Chisel v3.4.3 (opt-in)
    • Improved in v3.4.4
    • Mandatory in v3.5.0

​

​

Before:

After:

© 2020 SiFive. All Rights Reserved.

35 of 39

Further Improved Website

35

4/19/22

4/19/22

35

Community page

www.chisel-lang.org

Now with a search bar!

Latest API Docs

Project-specific documentation

© 2020 SiFive. All Rights Reserved.

36 of 39

Further Improved Website

36

4/19/22

4/19/22

36

www.chisel-lang.org

Documentation examples are compiled and run!!!

© 2020 SiFive. All Rights Reserved.

37 of 39

Enhanced Signal Naming (from last time)

  • Historically Chisel has struggled with signal naming
  • Chisel 3.4 has much better naming

37

4/19/22

Old* Verilog

Chisel 3.4 Verilog

© 2020 SiFive. All Rights Reserved.

38 of 39

Refined Signal Naming

  • Optional “tap” output
  • What should the name of the port be?
    • port
    • tap_port
    • tap
    • tapPort
  • In 3.4.0, the name was ”tap_port”
  • In 3.4.1 on, the name is “tap”
  • Additional improvements to naming (especially when using recursion)
  • Now with ~5 months of use, it’s going great!

38

4/19/22

© 2020 SiFive. All Rights Reserved.

39 of 39

Improved Release Methodology

39

4/19/22

major

major

Backport

Backport

Backport

major

Backport

3.2.x

master

3.3.x

3.3.0

3.2.1

3.2.0

Automated Backporting + CI

3.2-SNAPSHOT

3.3-SNAPSHOT

3.5-SNAPSHOT

© 2020 SiFive. All Rights Reserved.