Packages

p

chisel3

package chisel3

This package contains the main chisel3 API.

Source
package.scala
Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. chisel3
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Type Members

  1. sealed abstract class ActualDirection extends AnyRef

    Resolved directions for both leaf and container nodes, only visible after a node is bound (since higher-level specifications like Input and Output can override directions).

  2. sealed abstract class Aggregate extends Data

    An abstract class for data types that solely consist of (are an aggregate of) other Data objects.

  3. class AliasedAggregateFieldException extends ChiselException
  4. sealed class AsyncReset extends Element with Reset

    Data type representing asynchronous reset signals

    Data type representing asynchronous reset signals

    These signals are similar to Clocks in that they must be glitch-free for proper circuit operation. Regs defined with the implicit reset being an AsyncReset will be asychronously reset registers.

  5. class AutoClonetypeException extends ChiselException
  6. trait BackendCompilationUtilities extends firrtl.util.BackendCompilationUtilities

    The Driver provides methods to invoke the chisel3 compiler and the firrtl compiler.

    The Driver provides methods to invoke the chisel3 compiler and the firrtl compiler. By default firrtl is automatically run after chisel. an ExecutionOptionsManager is needed to manage options. It can parser command line arguments or coordinate multiple chisel toolchain tools options.

    Examples:
    1. val optionsManager = new ExecutionOptionsManager("chisel3")
          with HasFirrtlOptions
          with HasChiselExecutionOptions {
        commonOptions = CommonOption(targetDirName = "my_target_dir")
        chiselOptions = ChiselExecutionOptions(runFirrtlCompiler = false)
      }
      chisel3.Driver.execute(optionsManager, () => new Dut)

      or via command line arguments

    2. ,
    3. args = "--no-run-firrtl --target-dir my-target-dir".split(" +")
      chisel3.execute(args, () => new DUT)
  7. case class BiConnectException(message: String) extends ChiselException with Product with Serializable
  8. case class Binary(bits: Bits) extends FirrtlFormat with Product with Serializable

    Format bits as Binary

  9. class BindingException extends ChiselException
  10. sealed abstract class Bits extends Element with ToBoolable

    A data type for values represented by a single bitvector.

    A data type for values represented by a single bitvector. This provides basic bitwise operations.

  11. abstract class BlackBox extends BaseBlackBox

    Defines a black box, which is a module that can be referenced from within Chisel, but is not defined in the emitted Verilog.

    Defines a black box, which is a module that can be referenced from within Chisel, but is not defined in the emitted Verilog. Useful for connecting to RTL modules defined outside Chisel.

    Example:
    1. Some design require a differential input clock to clock the all design. With the xilinx FPGA for example, a Verilog template named IBUFDS must be integrated to use differential input:

      IBUFDS #(.DIFF_TERM("TRUE"),
               .IOSTANDARD("DEFAULT")) ibufds (
       .IB(ibufds_IB),
       .I(ibufds_I),
       .O(ibufds_O)
      );

      To instantiate it, a BlackBox can be used like following:

      import chisel3._
      import chisel3.experimental._
      
      // Example with Xilinx differential buffer IBUFDS
      class IBUFDS extends BlackBox(Map("DIFF_TERM" -> "TRUE", // Verilog parameters
                                        "IOSTANDARD" -> "DEFAULT"
                           )) {
        val io = IO(new Bundle {
          val O = Output(Clock()) // IO names will be the same
          val I = Input(Clock())  // (without 'io_' in prefix)
          val IB = Input(Clock()) //
        })
      }
    Note

    The parameters API is experimental and may change

  12. sealed class Bool extends UInt with Reset

    A data type for booleans, defined as a single bit indicating true or false.

  13. trait BoolFactory extends AnyRef
  14. abstract class Bundle extends Record

    Base class for data types defined as a bundle of other data types.

    Base class for data types defined as a bundle of other data types.

    Usage: extend this class (either as an anonymous or named class) and define members variables of Data subtypes to be elements in the Bundle.

    Example of an anonymous IO bundle

    class MyModule extends Module {
      val io = IO(new Bundle {
        val in = Input(UInt(64.W))
        val out = Output(SInt(128.W))
      })
    }

    Or as a named class

    class Packet extends Bundle {
      val header = UInt(16.W)
      val addr   = UInt(16.W)
      val data   = UInt(32.W)
    }
    class MyModule extends Module {
       val io = IO(new Bundle {
         val inPacket = Input(new Packet)
         val outPacket = Output(new Packet)
       })
       val reg = Reg(new Packet)
       reg <> inPacket
       outPacket <> reg
    }
  15. case class Character(bits: Bits) extends FirrtlFormat with Product with Serializable

    Format bits as Character

  16. type ChiselException = chisel3.internal.ChiselException
  17. case class ChiselExecutionFailure(message: String) extends ChiselExecutionResult with Product with Serializable

    Getting one of these indicates failure of some sort.

    Getting one of these indicates failure of some sort.

    message

    A clue might be provided here.

  18. case class ChiselExecutionOptions(runFirrtlCompiler: Boolean = true, printFullStackTrace: Boolean = false) extends ComposableOptions with Product with Serializable

    Options that are specific to chisel.

    Options that are specific to chisel.

    runFirrtlCompiler

    when true just run chisel, when false run chisel then compile its output with firrtl

    Note

    this extends FirrtlExecutionOptions which extends CommonOptions providing easy access to down chain options

  19. trait ChiselExecutionResult extends AnyRef

    This family provides return values from the chisel3 and possibly firrtl compile steps

  20. case class ChiselExecutionSuccess(circuitOption: Option[Circuit], emitted: String, firrtlResultOption: Option[FirrtlExecutionResult]) extends ChiselExecutionResult with Product with Serializable

    circuitOption

    Optional circuit, has information like circuit name

    emitted

    The emitted Chirrrl text

    firrtlResultOption

    Optional Firrtl result, @see freechipsproject/firrtl for details

  21. sealed class Clock extends Element
  22. trait CompileOptions extends AnyRef
  23. abstract class Data extends HasId with NamedComponent with SourceInfoDoc

    This forms the root of the type system for wire data types.

    This forms the root of the type system for wire data types. The data value must be representable as some number (need not be known at Chisel compile time) of bits, and must have methods to pack / unpack structured data to / from bits.

  24. case class Decimal(bits: Bits) extends FirrtlFormat with Product with Serializable

    Format bits as Decimal

  25. abstract class Element extends Data

    Element is a leaf data type: it cannot contain other Data objects.

    Element is a leaf data type: it cannot contain other Data objects. Example uses are for representing primitive data types, like integers and bits.

  26. case class ExpectedChiselTypeException(message: String) extends BindingException with Product with Serializable

    A function expected a Chisel type but got a hardware object

  27. case class ExpectedHardwareException(message: String) extends BindingException with Product with Serializable

    A function expected a hardware object but got a Chisel type

  28. sealed abstract class FirrtlFormat extends Printable

    Superclass for Firrtl format specifiers for Bits

  29. case class FullName(data: Data) extends Printable with Product with Serializable

    Put full name within parent namespace (eg.

    Put full name within parent namespace (eg. bundleName.field)

  30. trait HasChiselExecutionOptions extends AnyRef
  31. case class Hexadecimal(bits: Bits) extends FirrtlFormat with Product with Serializable

    Format bits as Hexidecimal

  32. trait IgnoreSeqInBundle extends AnyRef

    Mix-in for Bundles that have arbitrary Seqs of Chisel types that aren't involved in hardware construction.

    Mix-in for Bundles that have arbitrary Seqs of Chisel types that aren't involved in hardware construction.

    Used to avoid raising an error/exception when a Seq is a public member of the bundle. This is useful if we those public Seq fields in the Bundle are unrelated to hardware construction.

  33. type InstanceId = chisel3.internal.InstanceId
  34. sealed class Mem[T <: Data] extends MemBase[T]

    A combinational/asynchronous-read, sequential/synchronous-write memory.

    A combinational/asynchronous-read, sequential/synchronous-write memory.

    Writes take effect on the rising clock edge after the request. Reads are combinational (requests will return data on the same cycle). Read-after-write hazards are not an issue.

    Note

    when multiple conflicting writes are performed on a Mem element, the result is undefined (unlike Vec, where the last assignment wins)

  35. sealed abstract class MemBase[T <: Data] extends HasId with NamedComponent with SourceInfoDoc
  36. case class MixedDirectionAggregateException(message: String) extends BindingException with Product with Serializable

    An aggregate had a mix of specified and unspecified directionality children

  37. type Module = LegacyModule
  38. abstract class ModuleAspect extends RawModule

    Used by Chisel Aspects to inject Chisel code into modules, after they have been elaborated.

    Used by Chisel Aspects to inject Chisel code into modules, after they have been elaborated. This is an internal API - don't use!

    It adds itself as an aspect to the module, which allows proper checking of connection and binding legality.

  39. case class MonoConnectException(message: String) extends ChiselException with Product with Serializable
  40. abstract class MultiIOModule extends RawModule

    Abstract base class for Modules, which behave much like Verilog modules.

    Abstract base class for Modules, which behave much like Verilog modules. These may contain both logic and state which are written in the Module body (constructor). This abstract base class includes an implicit clock and reset.

    Note

    Module instantiations must be wrapped in a Module() call.

  41. case class Name(data: Data) extends Printable with Product with Serializable

    Put innermost name (eg.

    Put innermost name (eg. field of bundle)

  42. trait Num[T <: Data] extends AnyRef

    Abstract trait defining operations available on numeric-like hardware data types.

    Abstract trait defining operations available on numeric-like hardware data types.

    T

    the underlying type of the number

  43. case class PString(str: String) extends Printable with Product with Serializable

    Wrapper for printing Scala Strings

  44. sealed abstract class Printable extends AnyRef

    Superclass of things that can be printed in the resulting circuit

    Superclass of things that can be printed in the resulting circuit

    Usually created using the custom string interpolator p"...". Printable string interpolation is similar to String interpolation in Scala For example:

    printf(p"The value of wire = $wire\n")

    This is equivalent to writing:

    printf(p"The value of wire = %d\n", wire)

    All Chisel data types have a method .toPrintable that gives a default pretty print that can be accessed via p"...". This works even for aggregate types, for example:

    val myVec = VecInit(5.U, 10.U, 13.U)
    printf(p"myVec = $myVec\n")
    // myVec = Vec(5, 10, 13)
    
    val myBundle = Wire(new Bundle {
      val foo = UInt()
      val bar = UInt()
    })
    myBundle.foo := 3.U
    myBundle.bar := 11.U
    printf(p"myBundle = $myBundle\n")
    // myBundle = Bundle(a -> 3, b -> 11)

    Users can override the default behavior of .toPrintable in custom Bundle and Record types.

  45. implicit final class PrintableHelper extends AnyVal

    Implicit for custom Printable string interpolator

  46. case class Printables(pables: Iterable[Printable]) extends Printable with Product with Serializable
  47. abstract class RawModule extends BaseModule

    Abstract base class for Modules that contain Chisel RTL.

    Abstract base class for Modules that contain Chisel RTL. This abstract base class is a user-defined module which does not include implicit clock and reset and supports multiple IO() declarations.

  48. case class RebindingException(message: String) extends BindingException with Product with Serializable

    Attempted to re-bind an already bound (directionality or hardware) object

  49. abstract class Record extends Aggregate

    Base class for Aggregates based on key values pairs of String and Data

    Base class for Aggregates based on key values pairs of String and Data

    Record should only be extended by libraries and fairly sophisticated generators. RTL writers should use Bundle. See Record#elements for an example.

  50. sealed trait Reset extends Element with ToBoolable
  51. final class ResetType extends Element with Reset

    "Abstract" Reset Type inferred in FIRRTL to either AsyncReset or Bool

    "Abstract" Reset Type inferred in FIRRTL to either AsyncReset or Bool

    Note

    This shares a common interface with AsyncReset and Bool but is not their actual super type due to Bool inheriting from abstract class UInt

  52. sealed class SInt extends Bits with Num[SInt]

    A data type for signed integers, represented as a binary bitvector.

    A data type for signed integers, represented as a binary bitvector. Defines arithmetic operations between other integer types.

  53. trait SIntFactory extends AnyRef
  54. trait SourceInfoDoc extends AnyRef

    Provides ScalaDoc information for "hidden" do_* methods

    Provides ScalaDoc information for "hidden" do_* methods

    Mix this into classes/objects that have do_* methods to get access to the shared SourceInfoTransformMacro ScalaDoc group and the lengthy groupdesc below.

  55. sealed abstract class SpecifiedDirection extends AnyRef

    User-specified directions.

  56. sealed class SyncReadMem[T <: Data] extends MemBase[T]

    A sequential/synchronous-read, sequential/synchronous-write memory.

    A sequential/synchronous-read, sequential/synchronous-write memory.

    Writes take effect on the rising clock edge after the request. Reads return data on the rising edge after the request. Read-after-write behavior (when a read and write to the same address are requested on the same cycle) is undefined.

    Note

    when multiple conflicting writes are performed on a Mem element, the result is undefined (unlike Vec, where the last assignment wins)

  57. sealed class UInt extends Bits with Num[UInt]

    A data type for unsigned integers, represented as a binary bitvector.

    A data type for unsigned integers, represented as a binary bitvector. Defines arithmetic operations between other integer types.

  58. trait UIntFactory extends AnyRef
  59. sealed class Vec[T <: Data] extends Aggregate with VecLike[T]

    A vector (array) of Data elements.

    A vector (array) of Data elements. Provides hardware versions of various collection transformation functions found in software array implementations.

    Careful consideration should be given over the use of Vec vs Seq or some other Scala collection. In general Vec only needs to be used when there is a need to express the hardware collection in a Reg or IO Bundle or when access to elements of the array is indexed via a hardware signal.

    Example of indexing into a Vec using a hardware address and where the Vec is defined in an IO Bundle

    val io = IO(new Bundle {
      val in = Input(Vec(20, UInt(16.W)))
      val addr = UInt(5.W)
      val out = Output(UInt(16.W))
    })
    io.out := io.in(io.addr)
    T

    type of elements

    Note

    • when multiple conflicting assignments are performed on a Vec element, the last one takes effect (unlike Mem, where the result is undefined)
    • Vecs, unlike classes in Scala's collection library, are propagated intact to FIRRTL as a vector type, which may make debugging easier
  60. trait VecFactory extends SourceInfoDoc
  61. trait VecLike[T <: Data] extends IndexedSeq[T] with HasId with SourceInfoDoc

    A trait for Vecs containing common hardware generators for collection operations.

  62. final class WhenContext extends AnyRef

    A WhenContext may represent a when, and elsewhen, or an otherwise.

    A WhenContext may represent a when, and elsewhen, or an otherwise. Since FIRRTL does not have an "elsif" statement, alternatives must be mapped to nested if-else statements inside the alternatives of the preceeding condition. In order to emit proper FIRRTL, it is necessary to keep track of the depth of nesting of the FIRRTL whens. Due to the "thin frontend" nature of Chisel3, it is not possible to know if a when or elsewhen has a succeeding elsewhen or otherwise; therefore, this information is added by preprocessing the command queue.

  63. trait WireFactory extends AnyRef
  64. implicit class fromBigIntToLiteral extends AnyRef

    These implicit classes allow one to convert scala.Int|scala.BigInt to Chisel.UInt|Chisel.SInt by calling .asUInt|.asSInt on them, respectively.

    These implicit classes allow one to convert scala.Int|scala.BigInt to Chisel.UInt|Chisel.SInt by calling .asUInt|.asSInt on them, respectively. The versions .asUInt(width)|.asSInt(width) are also available to explicitly mark a width for the new literal.

    Also provides .asBool to scala.Boolean and .asUInt to String

    Note that, for stylistic reasons, one should avoid extracting immediately after this call using apply, ie. 0.asUInt(1)(0) due to potential for confusion (the 1 is a bit length and the 0 is a bit extraction position). Prefer storing the result and then extracting from it.

    Implementation note: the empty parameter list (like U()) is necessary to prevent interpreting calls that have a non-Width parameter as a chained apply, otherwise things like 0.asUInt(16) (instead of 16.W) compile without error and produce undesired results.

  65. implicit class fromBooleanToLiteral extends AnyRef
  66. implicit class fromDoubleToLiteral extends chisel3.experimental.FixedPoint.Implicits.fromDoubleToLiteral
  67. implicit class fromIntToBinaryPoint extends chisel3.experimental.FixedPoint.Implicits.fromIntToBinaryPoint
  68. implicit class fromIntToLiteral extends fromBigIntToLiteral
  69. implicit class fromIntToWidth extends AnyRef
  70. implicit class fromLongToLiteral extends fromBigIntToLiteral
  71. implicit class fromStringToLiteral extends AnyRef

Value Members

  1. val DontCare: InternalDontCare.type
  2. val WireInit: WireDefault.type
  3. def getDataElements(a: Aggregate): Seq[Element]
  4. def getModulePorts(m: Module): Seq[Port]
  5. implicit def string2Printable(str: String): Printable
  6. object ActualDirection
  7. object AsyncReset
  8. object Bits extends UIntFactory
  9. object Bool extends BoolFactory
  10. object BuildInfo extends Product with Serializable

    This object was generated by sbt-buildinfo.

  11. object Clock
  12. object CompileOptions
  13. object Driver extends BackendCompilationUtilities
  14. object ExplicitCompileOptions
  15. object FirrtlFormat
  16. object Flipped
  17. object Input

    Input, Output, and Flipped are used to define the directions of Module IOs.

    Input, Output, and Flipped are used to define the directions of Module IOs.

    Note that they currently clone their source argument, including its bindings.

    Thus, an error will be thrown if these are used on bound Data

  18. object Mem
  19. object Module extends SourceInfoDoc
  20. object Mux extends SourceInfoDoc
  21. object Output
  22. object Percent extends Printable with Product with Serializable

    Represents escaped percents

  23. object Printable
  24. object Reg

    Utility for constructing hardware registers

    Utility for constructing hardware registers

    The width of a Reg (inferred or not) is copied from the type template

    val r0 = Reg(UInt()) // width is inferred
    val r1 = Reg(UInt(8.W)) // width is set to 8
    
    val r2 = Reg(Vec(4, UInt())) // width is inferred
    val r3 = Reg(Vec(4, UInt(8.W))) // width of each element is set to 8
    
    class MyBundle {
      val unknown = UInt()
      val known   = UInt(8.W)
    }
    val r4 = Reg(new MyBundle)
    // Width of r4.unknown is inferred
    // Width of r4.known is set to 8
  25. object RegInit

    Utility for constructing hardware registers with an initialization value.

    Utility for constructing hardware registers with an initialization value.

    The register is set to the initialization value when the current implicit reset is high

    The two forms of RegInit differ in how the type and width of the resulting Reg are specified.

    Single Argument

    The single argument form uses the argument to specify both the type and reset value. For non-literal Bits, the width of the Reg will be inferred. For literal Bits and all non-Bits arguments, the type will be copied from the argument. See the following examples for more details:

    1. Literal Bits initializer: width will be set to match

    val r1 = RegInit(1.U) // width will be inferred to be 1
    val r2 = RegInit(1.U(8.W)) // width is set to 8

    2. Non-Literal Element initializer - width will be inferred

    val x = Wire(UInt())
    val y = Wire(UInt(8.W))
    val r1 = RegInit(x) // width will be inferred
    val r2 = RegInit(y) // width will be inferred

    3. Aggregate initializer - width will be set to match the aggregate

    class MyBundle {
      val unknown = UInt()
      val known   = UInt(8.W)
    }
    val w1 = Reg(new MyBundle)
    val w2 = RegInit(w1)
    // Width of w2.unknown is inferred
    // Width of w2.known is set to 8

    Double Argument

    The double argument form allows the type of the Reg and the default connection to be specified independently.

    The width inference semantics for RegInit with two arguments match those of Reg. The first argument to RegInit is the type template which defines the width of the Reg in exactly the same way as the only argument to Wire.

    More explicitly, you can reason about RegInit with multiple arguments as if it were defined as:

    def RegInit[T <: Data](t: T, init: T): T = {
      val x = Reg(t)
      x := init
      x
    }
  26. object RegNext
  27. object Reset
  28. object SInt extends SIntFactory
  29. object SpecifiedDirection
  30. object SyncReadMem
  31. object UInt extends UIntFactory
  32. object Vec extends VecFactory
  33. object VecInit extends SourceInfoDoc
  34. object Wire extends WireFactory

    Utility for constructing hardware wires

    Utility for constructing hardware wires

    The width of a Wire (inferred or not) is copied from the type template

    val w0 = Wire(UInt()) // width is inferred
    val w1 = Wire(UInt(8.W)) // width is set to 8
    
    val w2 = Wire(Vec(4, UInt())) // width is inferred
    val w3 = Wire(Vec(4, UInt(8.W))) // width of each element is set to 8
    
    class MyBundle {
      val unknown = UInt()
      val known   = UInt(8.W)
    }
    val w4 = Wire(new MyBundle)
    // Width of w4.unknown is inferred
    // Width of w4.known is set to 8
  35. object WireDefault

    Utility for constructing hardware wires with a default connection

    Utility for constructing hardware wires with a default connection

    The two forms of WireDefault differ in how the type and width of the resulting Wire are specified.

    Single Argument

    The single argument form uses the argument to specify both the type and default connection. For non-literal Bits, the width of the Wire will be inferred. For literal Bits and all non-Bits arguments, the type will be copied from the argument. See the following examples for more details:

    1. Literal Bits initializer: width will be set to match

    val w1 = WireDefault(1.U) // width will be inferred to be 1
    val w2 = WireDefault(1.U(8.W)) // width is set to 8

    2. Non-Literal Element initializer - width will be inferred

    val x = Wire(UInt())
    val y = Wire(UInt(8.W))
    val w1 = WireDefault(x) // width will be inferred
    val w2 = WireDefault(y) // width will be inferred

    3. Aggregate initializer - width will be set to match the aggregate

    class MyBundle {
      val unknown = UInt()
      val known   = UInt(8.W)
    }
    val w1 = Wire(new MyBundle)
    val w2 = WireDefault(w1)
    // Width of w2.unknown is inferred
    // Width of w2.known is set to 8

    Double Argument

    The double argument form allows the type of the Wire and the default connection to be specified independently.

    The width inference semantics for WireDefault with two arguments match those of Wire. The first argument to WireDefault is the type template which defines the width of the Wire in exactly the same way as the only argument to Wire.

    More explicitly, you can reason about WireDefault with multiple arguments as if it were defined as:

    def WireDefault[T <: Data](t: T, init: T): T = {
      val x = Wire(t)
      x := init
      x
    }
    Note

    The Default in WireDefault refers to a default connection. This is in contrast to RegInit where the Init refers to a value on reset.

  36. object assert
  37. object chiselTypeOf

    Returns the chisel type of a hardware object, allowing other hardware to be constructed from it.

  38. object dontTouch

    Marks that a signal should not be removed by Chisel and Firrtl optimization passes

    Marks that a signal should not be removed by Chisel and Firrtl optimization passes

    Example:
    1. class MyModule extends Module {
        val io = IO(new Bundle {
          val a = Input(UInt(32.W))
          val b = Output(UInt(32.W))
        })
        io.b := io.a
        val dead = io.a +% 1.U // normally dead would be pruned by DCE
        dontTouch(dead) // Marking it as such will preserve it
      }
    Note

    Calling this on Data creates an annotation that Chisel emits to a separate annotations file. This file must be passed to FIRRTL independently of the .fir file. The execute methods in chisel3.Driver will pass the annotations to FIRRTL automatically.

  39. object printf

    Prints a message in simulation

    Prints a message in simulation

    See apply methods for use

  40. object stop
  41. object when
  42. object withClock
  43. object withClockAndReset
  44. object withReset

Inherited from AnyRef

Inherited from Any

Ungrouped