-
Notifications
You must be signed in to change notification settings - Fork 609
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enrich ShiftRegister with SyncReadMem-based implementation. (#2891)
Co-authored-by: Jiuyang Liu <[email protected]> Co-authored-by: Megan Wachs <[email protected]> Co-authored-by: Jack Koenig <[email protected]>
- Loading branch information
1 parent
5d361fe
commit 3382cab
Showing
4 changed files
with
139 additions
and
0 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
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,34 @@ | ||
// 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 { | ||
|
||
implicit val nonNegIntShrinker: Shrink[Int] = Shrink.shrinkIntegral[Int].suchThat(_ >= 0) | ||
|
||
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