chisel3.util.random

Members list

Type members

Classlikes

class FibonacciLFSR(width: Int, taps: Set[Int], seed: Option[BigInt] = ..., val reduction: LFSRReduce = ..., step: Int = ..., updateSeed: Boolean = ...) extends PRNG, LFSR

Fibonacci Linear Feedback Shift Register (LFSR) generator.

Fibonacci Linear Feedback Shift Register (LFSR) generator.

A Fibonacci LFSR can be generated by defining a width and a set of tap points (corresponding to a polynomial). An optional initial seed and a reduction operation (XOR, the default, or XNOR) can be used to augment the generated hardware. The resulting hardware has support for a run-time programmable seed (via PRNGIO.seed) and conditional increment (via PRNGIO.increment).

$seedExplanation

In the example below, a 4-bit Fibonacci LFSR is constructed. Tap points are defined as four and three (using LFSR convention of indexing from one). This results in the hardware configuration shown in the diagram.

val lfsr4 = Module(new FibonacciLFSR(4, Set(4, 3))
//                 +---+
// +-------------->|XOR|-------------------------------------------------------+
// |               +---+                                                       |
// |   +-------+     ^     +-------+           +-------+           +-------+   |
// |   |       |     |     |       |           |       |           |       |   |
// +---+  x^4  |<----+-----|  x^3  |<----------|  x^2  |<----------|  x^1  |<--+
//     |       |           |       |           |       |           |       |
//     +-------+           +-------+           +-------+           +-------+

If you require a maximal period Fibonacci LFSR of a specific width, you can use MaxPeriodFibonacciLFSR. If you only require a pseudorandom UInt you can use the FibonacciLFSR companion object.

Attributes

See also

https://en.wikipedia.org/wiki/Linear-feedback_shift_register#Fibonacci_LFSRs $paramWidth $paramTaps $paramSeed $paramReduction $paramStep $paramUpdateSeed

Companion
object
Source
FibonacciLFSR.scala
Supertypes
trait LFSR
class PRNG
class Module
class RawModule
class BaseModule
trait Selectable
trait Selectable
trait InstanceId
class Object
trait Matchable
class Any
Show all
Known subtypes
object FibonacciLFSR

Utility for generating a pseudorandom UInt from a FibonacciLFSR.

Utility for generating a pseudorandom UInt from a FibonacciLFSR.

For example, to generate a pseudorandom 8-bit UInt that changes every cycle, you can use:

val pseudoRandomNumber = FibonacciLFSR.maxPeriod(8)

Attributes

Companion
class
Source
FibonacciLFSR.scala
Supertypes
class Object
trait Matchable
class Any
Self type
class GaloisLFSR(width: Int, taps: Set[Int], seed: Option[BigInt] = ..., val reduction: LFSRReduce = ..., step: Int = ..., updateSeed: Boolean = ...) extends PRNG, LFSR

Galois Linear Feedback Shift Register (LFSR) generator.

Galois Linear Feedback Shift Register (LFSR) generator.

A Galois LFSR can be generated by defining a width and a set of tap points. Optionally, an initial seed and a reduction operation (XOR, the default, or XNOR) can be used to augment the generated hardware. The resulting hardware has support for a run-time programmable seed (via PRNGIO.seed) and conditional increment (via PRNGIO.increment).

If the user specifies a seed, then a compile-time check is added that they are not initializing the LFSR to a state which will cause it to lock up. If the user does not set a seed, then the least significant bit of the state will be set or reset based on the choice of reduction operator.

In the example below, a 4-bit LFSR Galois LFSR is constructed. The tap points are defined as four and three (using LFSR convention of indexing from one). This results in the hardware configuration shown in the diagram.

val lfsr4 = Module(new GaloisLFSR(4, Set(4, 3))
// +-----------------+---------------------------------------------------------+
// |                 |                                                         |
// |   +-------+     v     +-------+           +-------+           +-------+   |
// |   |       |   +---+   |       |           |       |           |       |   |
// +-->|  x^4  |-->|XOR|-->|  x^3  |---------->|  x^2  |---------->|  x^1  |---+
//     |       |   +---+   |       |           |       |           |       |
//     +-------+           +-------+           +-------+           +-------+

If you require a maximal period Galois LFSR of a specific width, you can use MaxPeriodGaloisLFSR. If you only require a pseudorandom UInt you can use the GaloisLFSR companion object.

Value parameters

reduction

the reduction operation (either XOR or XNOR)

seed

an initial value for internal LFSR state. If None, then the LFSR state LSB will be set to a known safe value on reset (to prevent lock up).

step

the number of state updates per cycle

taps

a set of tap points to use when constructing the LFSR

updateSeed

if true, when loading the seed the state will be updated as if the seed were the current state, if false, the state will be set to the seed

width

the width of the LFSR

Attributes

See also
Companion
object
Source
GaloisLFSR.scala
Supertypes
trait LFSR
class PRNG
class Module
class RawModule
class BaseModule
trait Selectable
trait Selectable
trait InstanceId
class Object
trait Matchable
class Any
Show all
Known subtypes
object GaloisLFSR

Utility for generating a pseudorandom UInt from a GaloisLFSR.

Utility for generating a pseudorandom UInt from a GaloisLFSR.

For example, to generate a pseudorandom 8-bit UInt that changes every cycle, you can use:

val pseudoRandomNumber = GaloisLFSR.maxPeriod(8)

Attributes

Companion
class
Source
GaloisLFSR.scala
Supertypes
class Object
trait Matchable
class Any
Self type
GaloisLFSR.type
trait LFSR extends PRNG

Trait that defines a Linear Feedback Shift Register (LFSR).

Trait that defines a Linear Feedback Shift Register (LFSR).

$seedExplanation

Attributes

See also
Companion
object
Source
LFSR.scala
Supertypes
class PRNG
class Module
class RawModule
class BaseModule
trait Selectable
trait Selectable
trait InstanceId
class Object
trait Matchable
class Any
Show all
Known subtypes
object LFSR

Utilities related to psuedorandom number generation using Linear Feedback Shift Registers (LFSRs).

Utilities related to psuedorandom number generation using Linear Feedback Shift Registers (LFSRs).

For example, to generate a pseudorandom 16-bit UInt that changes every cycle, you can use:

val pseudoRandomNumber = LFSR(16)

Attributes

Companion
trait
Source
LFSR.scala
Supertypes
class Object
trait Matchable
class Any
Self type
LFSR.type
sealed trait LFSRReduce extends (Bool, Bool) => Bool

A reduction operation for an LFSR.

A reduction operation for an LFSR.

Attributes

See also
Source
LFSR.scala
Supertypes
trait (Bool, Bool) => Bool
class Object
trait Matchable
class Any
Known subtypes
object XNOR
object XOR
class MaxPeriodFibonacciLFSR(width: Int, seed: Option[BigInt] = ..., reduction: LFSRReduce = ...) extends FibonacciLFSR

A maximal period Fibonacci Linear Feedback Shift Register (LFSR) generator. The maximal period taps are sourced from LFSR.tapsMaxPeriod.

A maximal period Fibonacci Linear Feedback Shift Register (LFSR) generator. The maximal period taps are sourced from LFSR.tapsMaxPeriod.

val lfsr8 = Module(new MaxPeriodFibonacciLFSR(8))

$paramWidth $paramSeed $paramReduction

Attributes

Source
FibonacciLFSR.scala
Supertypes
trait LFSR
class PRNG
class Module
class RawModule
class BaseModule
trait Selectable
trait Selectable
trait InstanceId
class Object
trait Matchable
class Any
Show all
class MaxPeriodGaloisLFSR(width: Int, seed: Option[BigInt] = ..., reduction: LFSRReduce = ...) extends GaloisLFSR

A maximal period Galois Linear Feedback Shift Register (LFSR) generator. The maximal period taps are sourced from LFSR.tapsMaxPeriod.

A maximal period Galois Linear Feedback Shift Register (LFSR) generator. The maximal period taps are sourced from LFSR.tapsMaxPeriod.

val lfsr8 = Module(new MaxPeriodGaloisLFSR(8))

Value parameters

reduction

the reduction operation (either XOR or XNOR)

seed

an initial value for internal LFSR state. If None, then the LFSR state LSB will be set to a known safe value on reset (to prevent lock up).

width

the width of the LFSR

Attributes

Source
GaloisLFSR.scala
Supertypes
class GaloisLFSR
trait LFSR
class PRNG
class Module
class RawModule
class BaseModule
trait Selectable
trait Selectable
trait InstanceId
class Object
trait Matchable
class Any
Show all
abstract class PRNG(val width: Int, val seed: Option[BigInt], step: Int = ..., updateSeed: Boolean = ...) extends Module

An abstract class representing a Pseudo Random Number Generator (PRNG)

An abstract class representing a Pseudo Random Number Generator (PRNG)

Value parameters

seed

the initial state of the PRNG

step

the number of state updates per cycle

updateSeed

if true, when loading the seed the state will be updated as if the seed were the current state, if false, the state will be set to the seed

width

the width of the PRNG

Attributes

Companion
object
Source
PRNG.scala
Supertypes
class Module
class RawModule
class BaseModule
trait Selectable
trait Selectable
trait InstanceId
class Object
trait Matchable
class Any
Show all
Known subtypes
object PRNG

Helper utilities related to the construction of Pseudo Random Number Generators (PRNGs)

Helper utilities related to the construction of Pseudo Random Number Generators (PRNGs)

Attributes

Companion
class
Source
PRNG.scala
Supertypes
class Object
trait Matchable
class Any
Self type
PRNG.type
class PRNGIO(val n: Int) extends Bundle

Pseudo Random Number Generators (PRNG) interface

Pseudo Random Number Generators (PRNG) interface

Value parameters

n

the width of the LFSR

Attributes

Source
PRNG.scala
Supertypes
class Bundle
class Record
trait Selectable
trait Aggregate
class Data
trait InstanceId
class Object
trait Matchable
class Any
Show all
object XNOR extends LFSRReduce

Not XOR (exclusive or) reduction operation

Not XOR (exclusive or) reduction operation

Attributes

Source
LFSR.scala
Supertypes
trait LFSRReduce
trait (Bool, Bool) => Bool
class Object
trait Matchable
class Any
Self type
XNOR.type
object XOR extends LFSRReduce

XOR (exclusive or) reduction operation

XOR (exclusive or) reduction operation

Attributes

Source
LFSR.scala
Supertypes
trait LFSRReduce
trait (Bool, Bool) => Bool
class Object
trait Matchable
class Any
Self type
XOR.type