summaryrefslogtreecommitdiff
path: root/src/main/scala/Chisel/util/LFSR.scala
blob: 839b1d1f8fe31faaa2beea7b894510fce62381dd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// See LICENSE for license details.

/** LFSRs in all shapes and sizes.
  */

package Chisel

// scalastyle:off magic.number
/** linear feedback shift register
  */
object LFSR16
{
  def apply(increment: Bool = Bool(true)): UInt =
  {
    val width = 16
    val lfsr = Reg(init=UInt(1, width))
    when (increment) { lfsr := Cat(lfsr(0)^lfsr(2)^lfsr(3)^lfsr(5), lfsr(width-1,1)) }
    lfsr
  }
}
// scalastyle:on magic.number