diff options
| author | Jack | 2022-01-12 04:27:19 +0000 |
|---|---|---|
| committer | Jack | 2022-01-12 04:27:19 +0000 |
| commit | 29df513e348cc809876893f650af8180f0190496 (patch) | |
| tree | 06daaea954b4e5af7113f06e4bdbb78b33515cb3 /src/main/scala/chisel3/util/random/GaloisLFSR.scala | |
| parent | 5242ce90659decb9058ee75db56e5c188029fbf9 (diff) | |
| parent | 747d16311bdf185d2e98e452b14cb5d8ccca004c (diff) | |
Merge branch 'master' into 3.5-release
Diffstat (limited to 'src/main/scala/chisel3/util/random/GaloisLFSR.scala')
| -rw-r--r-- | src/main/scala/chisel3/util/random/GaloisLFSR.scala | 38 |
1 files changed, 20 insertions, 18 deletions
diff --git a/src/main/scala/chisel3/util/random/GaloisLFSR.scala b/src/main/scala/chisel3/util/random/GaloisLFSR.scala index 68346e82..f452cf75 100644 --- a/src/main/scala/chisel3/util/random/GaloisLFSR.scala +++ b/src/main/scala/chisel3/util/random/GaloisLFSR.scala @@ -38,21 +38,21 @@ import chisel3._ * $paramUpdateSeed */ class GaloisLFSR( - width: Int, - taps: Set[Int], - seed: Option[BigInt] = Some(1), + width: Int, + taps: Set[Int], + seed: Option[BigInt] = Some(1), val reduction: LFSRReduce = XOR, - step: Int = 1, - updateSeed: Boolean = false) extends PRNG(width, seed, step, updateSeed) with LFSR { + step: Int = 1, + updateSeed: Boolean = false) + extends PRNG(width, seed, step, updateSeed) + with LFSR { def delta(s: Seq[Bool]): Seq[Bool] = { val first = s.head - (s.tail :+ first) - .zipWithIndex - .map { - case (a, i) if taps(i + 1) && (i + 1 != s.size) => reduction(a, first) - case (a, _) => a - } + (s.tail :+ first).zipWithIndex.map { + case (a, i) if taps(i + 1) && (i + 1 != s.size) => reduction(a, first) + case (a, _) => a + } } } @@ -93,11 +93,12 @@ object GaloisLFSR { * $paramReduction */ def apply( - width: Int, - taps: Set[Int], + width: Int, + taps: Set[Int], increment: Bool = true.B, - seed: Option[BigInt] = Some(1), - reduction: LFSRReduce = XOR): UInt = PRNG(new GaloisLFSR(width, taps, seed, reduction), increment) + seed: Option[BigInt] = Some(1), + reduction: LFSRReduce = XOR + ): UInt = PRNG(new GaloisLFSR(width, taps, seed, reduction), increment) /** Return a pseudorandom [[UInt]] generated using a maximal period [[GaloisLFSR]] * $paramWidth @@ -106,9 +107,10 @@ object GaloisLFSR { * $paramReduction */ def maxPeriod( - width: Int, + width: Int, increment: Bool = true.B, - seed: Option[BigInt] = Some(1), - reduction: LFSRReduce = XOR): UInt = PRNG(new MaxPeriodGaloisLFSR(width, seed, reduction), increment) + seed: Option[BigInt] = Some(1), + reduction: LFSRReduce = XOR + ): UInt = PRNG(new MaxPeriodGaloisLFSR(width, seed, reduction), increment) } |
