summaryrefslogtreecommitdiff
path: root/src/main/scala/chisel3/util/LFSR.scala
diff options
context:
space:
mode:
authorJim Lawson2016-07-06 10:01:23 -0700
committerJim Lawson2016-07-18 15:17:56 -0700
commitc5f9ea3133ef363ff8944e17d94fea79767b6bed (patch)
treecc80a6df1eb58f0feaf9f138eb7fe261ccda4ea2 /src/main/scala/chisel3/util/LFSR.scala
parent53813f61b7dfe246d214ab966739d01c65c8ecb0 (diff)
Rename "Chisel" to "chisel3" (only git mv).
Diffstat (limited to 'src/main/scala/chisel3/util/LFSR.scala')
-rw-r--r--src/main/scala/chisel3/util/LFSR.scala22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/main/scala/chisel3/util/LFSR.scala b/src/main/scala/chisel3/util/LFSR.scala
new file mode 100644
index 00000000..839b1d1f
--- /dev/null
+++ b/src/main/scala/chisel3/util/LFSR.scala
@@ -0,0 +1,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
+