Skip to content

Commit

Permalink
chisel3.util.random.LFSR(16) (#2355)
Browse files Browse the repository at this point in the history
  • Loading branch information
ingallsj authored Mar 27, 2020
1 parent d1670c0 commit bb10dbe
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/main/scala/rocket/ICache.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import freechips.rocketchip.util.{DescribedSRAM, _}
import freechips.rocketchip.util.property._
import chisel3.internal.sourceinfo.SourceInfo
import chisel3.dontTouch
import chisel3.util.random.LFSR
import freechips.rocketchip.diplomaticobjectmodel.DiplomaticObjectModelAddressing
import freechips.rocketchip.diplomaticobjectmodel.model._

Expand Down Expand Up @@ -188,7 +189,7 @@ class ICacheModule(outer: ICache) extends LazyModuleImp(outer)

val repl_way = if (isDM) UInt(0) else {
// pick a way that is not used by the scratchpad
val v0 = LFSR16(refill_fire)(log2Up(nWays)-1,0)
val v0 = LFSR(16, refill_fire)(log2Up(nWays)-1,0)
var v = v0
for (i <- log2Ceil(nWays) - 1 to 0 by -1) {
val mask = nWays - (BigInt(1) << (i + 1))
Expand Down
3 changes: 2 additions & 1 deletion src/main/scala/tilelink/Arbiter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
package freechips.rocketchip.tilelink

import Chisel._
import chisel3.util.random.LFSR
import freechips.rocketchip.config.Parameters
import freechips.rocketchip.diplomacy._
import freechips.rocketchip.util._
Expand Down Expand Up @@ -97,7 +98,7 @@ class TestRobin(txns: Int = 128, timeout: Int = 500000)(implicit p: Parameters)
val sink = Wire(DecoupledIO(UInt(width=3)))
val count = RegInit(UInt(0, width=8))

val lfsr = LFSR16(Bool(true))
val lfsr = LFSR(16, Bool(true))
val valid = lfsr(0)
val ready = lfsr(15)

Expand Down
3 changes: 2 additions & 1 deletion src/main/scala/util/ECC.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
package freechips.rocketchip.util

import Chisel._
import chisel3.util.random.LFSR

abstract class Decoding
{
Expand Down Expand Up @@ -183,7 +184,7 @@ object ErrGen
// generate a 1-bit error with approximate probability 2^-f
def apply(width: Int, f: Int): UInt = {
require(width > 0 && f >= 0 && log2Up(width) + f <= 16)
UIntToOH(LFSR16()(log2Up(width)+f-1,0))(width-1,0)
UIntToOH(LFSR(16)(log2Up(width)+f-1,0))(width-1,0)
}
def apply(x: UInt, f: Int): UInt = x ^ apply(x.getWidth, f)
}
Expand Down
3 changes: 2 additions & 1 deletion src/main/scala/util/Misc.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package freechips.rocketchip.util

import Chisel._
import chisel3.util.random.LFSR
import freechips.rocketchip.config.Parameters
import scala.math._

Expand Down Expand Up @@ -154,7 +155,7 @@ object Random
}
def oneHot(mod: Int): UInt = oneHot(mod, randomizer)

private def randomizer = LFSR16()
private def randomizer = LFSR(16)
private def partition(value: UInt, slices: Int) =
Seq.tabulate(slices)(i => value < UInt(((i + 1) << value.getWidth) / slices))
}
Expand Down
3 changes: 2 additions & 1 deletion src/main/scala/util/Replacement.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package freechips.rocketchip.util

import Chisel._
import chisel3.util.random.LFSR

abstract class ReplacementPolicy {
def way: UInt
Expand All @@ -14,7 +15,7 @@ abstract class ReplacementPolicy {
class RandomReplacement(ways: Int) extends ReplacementPolicy {
private val replace = Wire(Bool())
replace := Bool(false)
val lfsr = LFSR16(replace)
val lfsr = LFSR(16, replace)

def way = Random(ways, lfsr)
def miss = replace := Bool(true)
Expand Down

0 comments on commit bb10dbe

Please sign in to comment.