package util
The util package provides extensions to core chisel for common hardware components and utility functions.
- Alphabetic
- By Inheritance
- util
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Type Members
-
class
Arbiter
[T <: Data] extends Module
Hardware module that is used to sequence n producers into 1 consumer.
Hardware module that is used to sequence n producers into 1 consumer. Priority is given to lower producer.
val arb = Module(new Arbiter(2, UInt())) arb.io.in(0) <> producer0.io.out arb.io.in(1) <> producer1.io.out consumer.io.in <> arb.io.out
Example: -
class
ArbiterIO
[T <: Data] extends Bundle
IO bundle definition for an Arbiter, which takes some number of ready-valid inputs and outputs (selects) at most one.
-
sealed
class
BitPat
extends AnyRef
Bit patterns are literals with masks, used to represent values with don't care bits.
Bit patterns are literals with masks, used to represent values with don't care bits. Equality comparisons will ignore don't care bits.
"b10101".U === BitPat("b101??") // evaluates to true.B "b10111".U === BitPat("b101??") // evaluates to true.B "b10001".U === BitPat("b101??") // evaluates to false.B
Example: -
class
Counter
extends AnyRef
A counter module
-
class
DecoupledIO
[+T <: Data] extends ReadyValidIO[T]
A concrete subclass of ReadyValidIO signaling that the user expects a "decoupled" interface: 'valid' indicates that the producer has put valid data in 'bits', and 'ready' indicates that the consumer is ready to accept the data this cycle.
A concrete subclass of ReadyValidIO signaling that the user expects a "decoupled" interface: 'valid' indicates that the producer has put valid data in 'bits', and 'ready' indicates that the consumer is ready to accept the data this cycle. No requirements are placed on the signaling of ready or valid.
- trait Enum extends AnyRef
- trait HasBlackBoxInline extends BlackBox
- trait HasBlackBoxResource extends BlackBox
-
class
IrrevocableIO
[+T <: Data] extends ReadyValidIO[T]
A concrete subclass of ReadyValidIO that promises to not change the value of 'bits' after a cycle where 'valid' is high and 'ready' is low.
A concrete subclass of ReadyValidIO that promises to not change the value of 'bits' after a cycle where 'valid' is high and 'ready' is low. Additionally, once 'valid' is raised it will never be lowered until after 'ready' has also been raised.
- class LockingArbiter [T <: Data] extends LockingArbiterLike[T]
- abstract class LockingArbiterLike [T <: Data] extends Module
- class LockingRRArbiter [T <: Data] extends LockingArbiterLike[T]
- class Pipe [T <: Data] extends Module
-
class
Queue
[T <: Data] extends Module
A hardware module implementing a Queue
A hardware module implementing a Queue
val q = Module(new Queue(UInt(), 16)) q.io.enq <> producer.io.out consumer.io.in <> q.io.deq
Example: -
class
QueueIO
[T <: Data] extends Bundle
An I/O Bundle for Queues
-
class
RRArbiter
[T <: Data] extends LockingRRArbiter[T]
Hardware module that is used to sequence n producers into 1 consumer.
Hardware module that is used to sequence n producers into 1 consumer. Producers are chosen in round robin order.
val arb = new RRArbiter(2, UInt()) arb.io.in(0) <> producer0.io.out arb.io.in(1) <> producer1.io.out consumer.io.in <> arb.io.out
Example: -
abstract
class
ReadyValidIO
[+T <: Data] extends Bundle
An I/O Bundle containing 'valid' and 'ready' signals that handshake the transfer of data stored in the 'bits' subfield.
An I/O Bundle containing 'valid' and 'ready' signals that handshake the transfer of data stored in the 'bits' subfield. The base protocol implied by the directionality is that the producer uses the interface as-is (outputs bits) while the consumer uses the flipped interface (inputs bits). The actual semantics of ready/valid are enforced via the use of concrete subclasses.
-
class
SwitchContext
[T <: Bits] extends AnyRef
Implementation details for switch.
-
class
Valid
[+T <: Data] extends Bundle
An Bundle containing data and a signal determining if it is valid
-
type
ValidIO[+T <: Data] = Valid[T]
Synonyms, moved from main package object - maintain scope.
Value Members
- val DecoupledIO: Decoupled.type
- val ValidIO: Valid.type
- object BitPat
-
object
Cat
Concatenates elements of the input, in order, together.
Concatenates elements of the input, in order, together.
Cat("b101".U, "b11".U) // equivalent to "b101 11".U Cat(myUIntWire0, myUIntWire1) Cat(Seq("b101".U, "b11".U)) // equivalent to "b101 11".U Cat(mySeqOfBits)
Example: - object Counter
-
object
Decoupled
This factory adds a decoupled handshaking protocol to a data bundle.
-
object
DeqIO
Consumer - drives (outputs) ready, inputs valid and bits.
-
object
EnqIO
Producer - drives (outputs) valid and bits, inputs ready.
- object Enum extends Enum
-
object
Fill
Create repetitions of the input using a tree fanout topology.
Create repetitions of the input using a tree fanout topology.
Fill(2, "b1000".U) // equivalent to "b1000 1000".U Fill(2, "b1001".U) // equivalent to "b1001 1001".U Fill(2, myUIntWire) // dynamic fill
Example: -
object
FillInterleaved
Creates repetitions of each bit of the input in order.
Creates repetitions of each bit of the input in order.
FillInterleaved(2, "b1 0 0 0".U) // equivalent to "b11 00 00 00".U FillInterleaved(2, "b1 0 0 1".U) // equivalent to "b11 00 00 11".U FillInterleaved(2, myUIntWire) // dynamic interleaved fill FillInterleaved(2, Seq(true.B, false.B, false.B, false.B)) // equivalent to "b11 00 00 00".U FillInterleaved(2, Seq(true.B, false.B, false.B, true.B)) // equivalent to "b11 00 00 11".U
Example: - object ImplicitConversions
-
object
Irrevocable
Factory adds an irrevocable handshaking protocol to a data bundle.
- object LFSR16
- object ListLookup
-
object
Log2
Returns the base-2 integer logarithm of an UInt.
Returns the base-2 integer logarithm of an UInt.
Log2(8.U) // evaluates to 3.U Log2(13.U) // evaluates to 3.U (truncation) Log2(myUIntWire)
- Note
The result is truncated, so e.g. Log2(13.U) === 3.U
Example: - object Lookup
-
object
Mux1H
Builds a Mux tree out of the input signal vector using a one hot encoded select signal.
Builds a Mux tree out of the input signal vector using a one hot encoded select signal. Returns the output of the Mux tree.
- Note
results undefined if multiple select signals are simultaneously high
-
object
MuxCase
Given an association of values to enable signals, returns the first value with an associated high enable signal.
-
object
MuxLookup
Creates a cascade of n Muxs to search for a key value.
-
object
OHToUInt
Returns the bit position of the sole high bit of the input bitvector.
Returns the bit position of the sole high bit of the input bitvector.
Inverse operation of UIntToOH.
- Note
assumes exactly one high bit, results undefined otherwise
-
object
Pipe
A hardware module that delays data coming down the pipeline by the number of cycles set by the latency parameter.
A hardware module that delays data coming down the pipeline by the number of cycles set by the latency parameter. Functionality is similar to ShiftRegister but this exposes a Pipe interface.
Example usage: val pipe = new Pipe(UInt()) pipe.io.enq <> produce.io.out consumer.io.in <> pipe.io.deq
-
object
PopCount
Returns the number of bits set (value is 1 or true) in the input signal.
Returns the number of bits set (value is 1 or true) in the input signal.
PopCount(Seq(true.B, false.B, true.B, true.B)) // evaluates to 3.U PopCount(Seq(false.B, false.B, true.B, false.B)) // evaluates to 1.U PopCount("b1011".U) // evaluates to 3.U PopCount("b0010".U) // evaluates to 1.U PopCount(myUIntWire) // dynamic count
Example: -
object
PriorityEncoder
Returns the bit position of the least-significant high bit of the input bitvector.
Returns the bit position of the least-significant high bit of the input bitvector.
Multiple bits may be high in the input.
-
object
PriorityEncoderOH
Returns a bit vector in which only the least-significant 1 bit in the input vector, if any, is set.
-
object
PriorityMux
Builds a Mux tree under the assumption that multiple select signals can be enabled.
Builds a Mux tree under the assumption that multiple select signals can be enabled. Priority is given to the first select signal.
Returns the output of the Mux tree.
-
object
Queue
Factory for a generic hardware queue.
Factory for a generic hardware queue.
- returns
output (dequeue) interface from the queue
consumer.io.in <> Queue(producer.io.out, 16)
Example: - object ReadyValidIO
- object RegEnable
-
object
Reverse
Returns the input in bit-reversed order.
Returns the input in bit-reversed order. Useful for little/big-endian conversion.
Reverse("b1101".U) // equivalent to "b1011".U Reverse("b1101".U(8.W)) // equivalent to "b10110000".U Reverse(myUIntWire) // dynamic reverse
Example: - object ShiftRegister
-
object
TransitName
The purpose of TransitName is to allow a library to 'move' a name call to a more appropriate place.
The purpose of TransitName is to allow a library to 'move' a name call to a more appropriate place. For example, a library factory function may create a module and return the io. The only user-exposed field is that given IO, which can't use any name supplied by the user. This can add a hook so that the supplied name then names the Module. See Queue companion object for working example
-
object
UIntToOH
Returns the one hot encoding of the input UInt.
-
object
Valid
Adds a valid protocol to any interface
-
object
is
Use to specify cases in a switch block, equivalent to a when block comparing to the condition variable.
-
object
isPow2
Check if an Integer is a power of 2
-
object
log2Ceil
Compute the log2 rounded up
-
object
log2Floor
Compute the log2 rounded down
-
object
switch
Conditional logic to form a switch block.
Conditional logic to form a switch block. See is for the case API.
switch (myState) { is (state1) { // some logic here that runs when myState === state1 } is (state2) { // some logic here that runs when myState === state2 } }
Example: - object unless
Deprecated Value Members
-
object
log2Down
Compute the log2 rounded down with min value of 1
Compute the log2 rounded down with min value of 1
- Annotations
- @deprecated
- Deprecated
(Since version chisel3) Use log2Floor instead
-
object
log2Up
Compute the log2 rounded up with min value of 1
Compute the log2 rounded up with min value of 1
- Annotations
- @deprecated
- Deprecated
(Since version chisel3) Use log2Ceil instead
This is the documentation for Chisel.
Package structure
The chisel3 package presents the public API of Chisel. It contains the concrete core types
UInt
,SInt
,Bool
,FixedPoint
,Clock
, andReg
, the abstract typesBits
,Aggregate
, andData
, and the aggregate typesBundle
andVec
.The Chisel package is a compatibility layer that attempts to provide chisel2 compatibility in chisel3.
Utility objects and methods are found in the
util
package.The
testers
package defines the basic interface for chisel testers.