chisel3.util.random
Members list
Type members
Classlikes
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 LFSRclass PRNGclass Moduletrait ImplicitResettrait ImplicitClockclass RawModuleclass BaseModuletrait Selectabletrait Selectabletrait IsInstantiabletrait InstanceIdclass Objecttrait Matchableclass AnyShow all
- Known subtypes
-
class MaxPeriodFibonacciLFSR
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 Objecttrait Matchableclass Any
- Self type
-
FibonacciLFSR.type
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
- 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 LFSRclass PRNGclass Moduletrait ImplicitResettrait ImplicitClockclass RawModuleclass BaseModuletrait Selectabletrait Selectabletrait IsInstantiabletrait InstanceIdclass Objecttrait Matchableclass AnyShow all
- Known subtypes
-
class MaxPeriodGaloisLFSR
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 Objecttrait Matchableclass Any
- Self type
-
GaloisLFSR.type
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 PRNGclass Moduletrait ImplicitResettrait ImplicitClockclass RawModuleclass BaseModuletrait Selectabletrait Selectabletrait IsInstantiabletrait InstanceIdclass Objecttrait Matchableclass AnyShow all
- Known subtypes
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 Objecttrait Matchableclass Any
- Self type
-
LFSR.type
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
-
class FibonacciLFSRtrait LFSRclass PRNGclass Moduletrait ImplicitResettrait ImplicitClockclass RawModuleclass BaseModuletrait Selectabletrait Selectabletrait IsInstantiabletrait InstanceIdclass Objecttrait Matchableclass AnyShow all
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
- 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 GaloisLFSRtrait LFSRclass PRNGclass Moduletrait ImplicitResettrait ImplicitClockclass RawModuleclass BaseModuletrait Selectabletrait Selectabletrait IsInstantiabletrait InstanceIdclass Objecttrait Matchableclass AnyShow all
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 Moduletrait ImplicitResettrait ImplicitClockclass RawModuleclass BaseModuletrait Selectabletrait Selectabletrait IsInstantiabletrait InstanceIdclass Objecttrait Matchableclass AnyShow all
- Known subtypes
-
class FibonacciLFSRclass MaxPeriodFibonacciLFSRclass GaloisLFSRclass MaxPeriodGaloisLFSRtrait LFSR
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 Objecttrait Matchableclass Any
- Self type
-
PRNG.type
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 Bundleclass Recordtrait Selectabletrait Aggregateclass Datatrait InstanceIdclass Objecttrait Matchableclass AnyShow all
Not XOR (exclusive or) reduction operation
Not XOR (exclusive or) reduction operation
Attributes
- Source
- LFSR.scala
- Supertypes
- Self type
-
XNOR.type
XOR (exclusive or) reduction operation