Git Product home page Git Product logo

chisel3's Introduction

Chisel 3


Upcoming Events

The 3rd Chisel Community Conference (hosted by CHIPS Alliance) is happening on January 29--30, 2020!

We're accepting talk proposals for through December 12th. (Acceptances are rolling, so if you have travel/visa requirements, get your submissions in!)

Make sure to register and attend to meet some other Chisel-ers and FIRRTL-ers!


Join the chat at https://gitter.im/freechipsproject/chisel3 CircleCI GitHub tag (latest SemVer)

Chisel is a hardware design language that facilitates advanced circuit generation and design reuse for both ASIC and FPGA digital logic designs. Chisel adds hardware construction primitives to the Scala programming language, providing designers with the power of a modern programming language to write complex, parameterizable circuit generators that produce synthesizable Verilog. This generator methodology enables the creation of re-usable components and libraries, such as the FIFO queue and arbiters in the Chisel Standard Library, raising the level of abstraction in design while retaining fine-grained control.

For more information on the benefits of Chisel see: "What benefits does Chisel offer over classic Hardware Description Languages?"

Chisel is powered by FIRRTL (Flexible Intermediate Representation for RTL), a hardware compiler framework that performs optimizations of Chisel-generated circuits and supports custom user-defined circuit transformations.

What does Chisel code look like?

Consider an FIR filter that implements a convolution operation, as depicted in this block diagram:

While Chisel provides similar base primitives as synthesizable Verilog, and could be used as such:

// 3-point moving average implemented in the style of a FIR filter
class MovingAverage3(bitWidth: Int) extends Module {
  val io = IO(new Bundle {
    val in = Input(UInt(bitWidth.W))
    val out = Output(UInt(bitWidth.W))
  })

  val z1 = RegNext(io.in)
  val z2 = RegNext(z1)

  io.out := (io.in * 1.U) + (z1 * 1.U) + (z2 * 1.U)
}

the power of Chisel comes from the ability to create generators, such as n FIR filter that is defined by the list of coefficients:

// Generalized FIR filter parameterized by the convolution coefficients
class FirFilter(bitWidth: Int, coeffs: Seq[UInt]) extends Module {
  val io = IO(new Bundle {
    val in = Input(UInt(bitWidth.W))
    val out = Output(UInt(bitWidth.W))
  })
  // Create the serial-in, parallel-out shift register
  val zs = Reg(Vec(coeffs.length, UInt(bitWidth.W)))
  zs(0) := io.in
  for (i <- 1 until coeffs.length) {
    zs(i) := zs(i-1)
  }

  // Do the multiplies
  val products = VecInit.tabulate(coeffs.length)(i => zs(i) * coeffs(i))

  // Sum up the products
  io.out := products.reduce(_ + _)
}

and use and re-use them across designs:

val movingAverage3Filter = FirFilter(8.W, Seq(1.U, 1.U, 1.U))  // same 3-point moving average filter as before
val delayFilter = FirFilter(8.W, Seq(0.U, 1.U))  // 1-cycle delay as a FIR filter
val triangleFilter = FirFilter(8.W, Seq(1.U, 2.U, 3.U, 2.U, 1.U))  // 5-point FIR filter with a triangle impulse response

Getting Started

Bootcamp Interactive Tutorial

The online Chisel Bootcamp is the recommended way to get started with and learn Chisel. No setup is required (it runs in the browser), nor does it assume any prior knowledge of Scala.

Build Your Own Chisel Projects

See the setup instructions for how to set up your environment to run Chisel locally.

When you're ready to build your own circuits in Chisel, we recommend starting from the Chisel Template repository, which provides a pre-configured project, example design, and testbench. Follow the chisel-template readme to get started.

If you insist on setting up your own project, the magic SBT lines are:

resolvers ++= Seq(
  Resolver.sonatypeRepo("snapshots"),
  Resolver.sonatypeRepo("releases")
)
libraryDependencies += "edu.berkeley.cs" %% "chisel3" % "3.2-SNAPSHOT"
libraryDependencies += "edu.berkeley.cs" %% "chisel-testers2" % "0.1-SNAPSHOT"

Design Verification

These simulation-based verification tools are available for Chisel:

  • iotesters, specifically PeekPokeTester, provides constructs (peek, poke, expect) similar to a non-synthesizable Verilog testbench.
  • testers2 is an in-development replacement for PeekPokeTester, providing the same base constructs but with a streamlined interface and concurrency support with fork and join.

Documentation

Useful Resources

  • Cheat Sheet, a 2-page reference of the base Chisel syntax and libraries
  • Wiki, which contains various feature-specific tutorials and frequently-asked questions.
  • ScalaDoc, a listing, description, and examples of the functionality exposed by Chisel
  • Gitter, where you can ask questions or discuss anything Chisel
  • Website

If you are migrating from Chisel2, see the migration guide.

Data Types Overview

These are the base data types for defining circuit components:

Image

Developer Documentation

This section describes how to get started developing Chisel itself, including how to test your version locally against other projects that pull in Chisel using sbt's managed dependencies.

Compiling and Testing Chisel

In the chisel3 repository directory compile the Chisel library:

sbt compile

If the compilation succeeded, you can then run the included unit tests by invoking:

sbt test

Running Projects Against Local Chisel

To use the development version of Chisel (master branch), you will need to build from source and publishLocal. The repository version can be found in the build.sbt file. As of the time of writing it was:

version := "3.2-SNAPSHOT"

To publish your version of Chisel to the local Ivy (sbt's dependency manager) repository, run:

sbt publishLocal

The compiled version gets placed in ~/.ivy2/local/edu.berkeley.cs/. If you need to un-publish your local copy of Chisel, remove the directory generated in ~/.ivy2/local/edu.berkeley.cs/.

In order to have your projects use this version of Chisel, you should update the libraryDependencies setting in your project's build.sbt file to:

libraryDependencies += "edu.berkeley.cs" %% "chisel3" % "3.2-SNAPSHOT"

Chisel3 Architecture Overview

The Chisel3 compiler consists of these main parts:

  • The frontend, chisel3.*, which is the publicly visible "API" of Chisel and what is used in Chisel RTL. These just add data to the...
  • The Builder, chisel3.internal.Builder, which maintains global state (like the currently open Module) and contains commands, generating...
  • The intermediate data structures, chisel3.firrtl.*, which are syntactically very similar to Firrtl. Once the entire circuit has been elaborated, the top-level object (a Circuit) is then passed to...
  • The Firrtl emitter, chisel3.firrtl.Emitter, which turns the intermediate data structures into a string that can be written out into a Firrtl file for further processing.

Also included is:

  • The standard library of circuit generators, chisel3.util.*. These contain commonly used interfaces and constructors (like Decoupled, which wraps a signal with a ready-valid pair) as well as fully parameterizable circuit generators (like arbiters and multiplexors).
  • Driver utilities, chisel3.Driver, which contains compilation and test functions that are invoked in the standard Verilog generation and simulation testing infrastructure. These can also be used as part of custom flows.

Which version should I use?

The chisel eco-system (chisel3, firttl, dsptools, firrtl-interpreter, treadle, diagrammer) use a form of semantic versioning: major versions are identified by two leading numbers, separated by a dot (i.e., 3.2), minor versions by a single number following the major version, separated by a dot. We maintain API compatibility within a major version (i.e., 3.2.12 should be API-compatible with 3.2.0), but do not guarantee API compatibility between major versions (i.e., APIs may change between 3.1.8 and 3.2.0). We may introduce new definitions or add additional parameters to existing definitions in a minor release, but we do our best to maintain compatibility with previous minor releases of a major release - code that worked in 3.2.0 should continue to work un-modified in 3.2.10.

We encourage chisel users (rather than chisel developers), to use release versions of chisel. The chisel web site (and GitHub repository) should indicate the current release version. If you encounter an issue with a released version of chisel, please file an issue on GitHub mentioning the chisel version and provide a simple test case (if possible). Try to reproduce the issue with the associated latest minor release (to verify that the issue hasn't been addressed).

If you're developing a chisel library (or chisel itself), you'll probably want to work closer to the tip of the development trunk. By default, the master branches of the chisel repositories are configured to build and publish their version of the code as Z.Y-SNAPSHOT. We try to publish an updated SNAPSHOT every two weeks. There is no guarantee of API compatibility between SNAPSHOT versions, but we publish date-stamped Z.Y-yyyymmdd-SNAPSHOT versions which will not change. The code in Z.Y-SNAPSHOT should match the code in the most recent Z.Y-yyyymmdd-SNAPSHOT version, the differences being the chisel library dependencies: Z.Y-SNAPSHOTs depend on V.U-SNAPSHOTs and Z.Y-yyyymmdd-SNAPSHOTs will depend on V.U-yyyymmdd-SNAPSHOTs. NOTE: Prior to the v3.2-20191030-SNAPSHOT version, we used Z.Y-mmddyy-SNAPSHOT to tag and name published SNAPSHOTs.

If you're developing a library (or another chisel tool), you should probably work with date-stamped SNAPSHOTs until your library or tool is ready to be published (to ensure a consistent API). Prior to publishing, you should verify your code against generic (no date-stamp) SNAPSHOTs, or locally published clones of the current master branches of chisel dependencies.

chisel3's People

Contributors

ucbjrl avatar ducky64 avatar seldridge avatar jackkoenig avatar aswaterman avatar chick avatar hcook avatar palmer-dabbelt avatar jackbackrack avatar edwardcwang avatar grebe avatar azidar avatar donggyukim avatar albert-magyar avatar schoeberl avatar terpstra avatar colinschmidt avatar hngenc avatar shunshou avatar martoni avatar colin4124 avatar stevobailey avatar kammoh avatar zhemao avatar mehnadnerd avatar albertchen-sifive avatar yep avatar zhuanhao-wu avatar gitter-badger avatar sequencer avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.