-
Notifications
You must be signed in to change notification settings - Fork 577
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…3571) Co-authored-by: Jiuyang Liu <liu@jiuyang.me> Co-authored-by: Megan Wachs <megan@sifive.com> Co-authored-by: Jack Koenig <koenig@sifive.com> (cherry picked from commit 3382cab) Co-authored-by: Vladimir Milovanović <barun@eecs.berkeley.edu>
- Loading branch information
1 parent
a21b1d8
commit 1de1174
Showing
4 changed files
with
137 additions
and
0 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
integration-tests/src/test/scala/chiselTest/ShiftRegisterMemSpec.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package chiselTests | ||
|
||
import chisel3._ | ||
import chisel3.testers.BasicTester | ||
import chisel3.util.{Counter, ShiftRegister} | ||
import org.scalacheck.{Gen, Shrink} | ||
|
||
class ShiftMemTester(n: Int, dp_mem: Boolean) extends BasicTester { | ||
val (cntVal, done) = Counter(true.B, n) | ||
val start = 23.U | ||
val sr = ShiftRegister.mem(cntVal + start, n, true.B, dp_mem, Some("simple_sr")) | ||
when(RegNext(done)) { | ||
assert(sr === start) | ||
stop() | ||
} | ||
} | ||
|
||
class ShiftRegisterMemSpec extends ChiselPropSpec { | ||
|
||
property("ShiftRegister with dual-port SRAM should shift") { | ||
forAll(Gen.choose(0, 4)) { (shift: Int) => assertTesterPasses { new ShiftMemTester(shift, true) } } | ||
} | ||
|
||
property("ShiftRegister with single-port SRAM should shift") { | ||
forAll(Gen.choose(0, 6).suchThat(_ % 2 == 0)) { (shift: Int) => | ||
assertTesterPasses { new ShiftMemTester(shift, false) } | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters