1
0

Fuzzer: use different LFSR seeds based on simulator seed

This commit is contained in:
Wesley W. Terpstra 2017-03-11 02:53:11 -08:00
parent bb6108abd5
commit d2da33e4b1

View File

@ -34,16 +34,11 @@ class IDMapGenerator(numIds: Int) extends Module {
object LFSR64 object LFSR64
{ {
private var counter = 0 def apply(increment: Bool = Bool(true)): UInt =
private def next: Int = {
counter += 1
counter
}
def apply(increment: Bool = Bool(true), seed: Int = next): UInt =
{ {
val wide = 64 val wide = 64
val lfsr = RegInit(UInt((seed * 0xDEADBEEFCAFEBAB1L) >>> 1, width = wide)) val undef = Reg(UInt(width = wide)) // random value based on simulation seed
val lfsr = RegInit(Mux(undef === UInt(0), UInt(1), undef))
val xor = lfsr(0) ^ lfsr(1) ^ lfsr(3) ^ lfsr(4) val xor = lfsr(0) ^ lfsr(1) ^ lfsr(3) ^ lfsr(4)
when (increment) { lfsr := Cat(xor, lfsr(wide-1,1)) } when (increment) { lfsr := Cat(xor, lfsr(wide-1,1)) }
lfsr lfsr