Skip to content

Commit 28cd6f9

Browse files
authored
Merge pull request #118 from ucb-bar/fix-issue-117-weak-test
Fix issue 117 weak test
2 parents 8ebdfa5 + daa9c98 commit 28cd6f9

File tree

3 files changed

+52
-8
lines changed

3 files changed

+52
-8
lines changed

build.sbt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ scalacOptions ++= Seq("-deprecation", "-feature", "-unchecked", "-language:refle
3939
// Provide a managed dependency on X if -DXVersion="" is supplied on the command line.
4040
// The following are the default development versions, not the "release" versions.
4141
val defaultVersions = Map(
42-
"chisel3" -> "3.1-SNAPSHOT",
43-
"chisel-iotesters" -> "1.2-SNAPSHOT"
42+
"chisel3" -> "3.2-SNAPSHOT",
43+
"chisel-iotesters" -> "1.3-SNAPSHOT"
4444
)
4545

4646
libraryDependencies ++= (Seq("chisel3","chisel-iotesters").map {

src/test/scala/examples/AdderTests.scala

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,20 @@ package examples
44
import chisel3.iotesters.{PeekPokeTester, Driver, ChiselFlatSpec}
55

66
class AdderTests(c: Adder) extends PeekPokeTester(c) {
7-
for (t <- 0 until 4) {
8-
val rnd0 = rnd.nextInt(c.n)
9-
val rnd1 = rnd.nextInt(c.n)
10-
val rnd2 = rnd.nextInt(1)
7+
for (t <- 0 until (1 << (c.n + 1))) {
8+
val rnd0 = rnd.nextInt(1 << c.n)
9+
val rnd1 = rnd.nextInt(1 << c.n)
10+
val rnd2 = rnd.nextInt(2)
1111

1212
poke(c.io.A, rnd0)
1313
poke(c.io.B, rnd1)
1414
poke(c.io.Cin, rnd2)
1515
step(1)
1616
val rsum = rnd0 + rnd1 + rnd2
1717
val mask = BigInt("1"*c.n, 2)
18+
1819
expect(c.io.Sum, rsum & mask)
19-
expect(c.io.Cout, rsum % 1)
20+
expect(c.io.Cout, ((1 << c.n) & rsum) >> c.n)
2021
}
2122
}
2223

src/test/scala/examples/StackTests.scala

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@ import scala.collection.mutable.HashMap
77
import scala.collection.mutable.{Stack => ScalaStack}
88
import scala.util.Random
99

10-
class StackTests(c: Stack) extends PeekPokeTester(c) {
10+
class StackTestsOrig(c: Stack) extends PeekPokeTester(c) {
1111
var nxtDataOut = 0
1212
var dataOut = 0
1313
val stack = new ScalaStack[Int]()
1414

1515
for (t <- 0 until 16) {
16+
println(s"Tick $t")
1617
val enable = rnd.nextInt(2)
1718
val push = rnd.nextInt(2)
1819
val pop = rnd.nextInt(2)
@@ -38,6 +39,48 @@ class StackTests(c: Stack) extends PeekPokeTester(c) {
3839
expect(c.io.dataOut, dataOut)
3940
}
4041
}
42+
class StackTests(c: Stack) extends PeekPokeTester(c) {
43+
var nxtDataOut = 0
44+
var dataOut = 0
45+
val stack = new ScalaStack[Int]()
46+
47+
poke(c.io.push, 0)
48+
poke(c.io.pop, 1)
49+
poke(c.io.dataIn, 232)
50+
poke(c.io.en, 1)
51+
52+
step(1)
53+
54+
println(s"dataOut ${peek(c.io.dataOut)}")
55+
56+
poke(c.io.push, 1)
57+
poke(c.io.pop, 1)
58+
poke(c.io.dataIn, 90)
59+
poke(c.io.en, 1)
60+
61+
step(1)
62+
step(1)
63+
64+
println(s"dataOut ${peek(c.io.dataOut)}")
65+
66+
poke(c.io.push, 1)
67+
poke(c.io.pop, 1)
68+
poke(c.io.dataIn, 33)
69+
poke(c.io.en, 1)
70+
71+
step(1)
72+
step(1)
73+
74+
println(s"dataOut ${peek(c.io.dataOut)}")
75+
76+
poke(c.io.push, 0)
77+
poke(c.io.pop, 1)
78+
poke(c.io.dataIn, 22)
79+
poke(c.io.en, 1)
80+
81+
println(s"dataOut ${peek(c.io.dataOut)}")
82+
// expect(c.io.dataOut, dataOut)
83+
}
4184

4285
class StackTester extends ChiselFlatSpec {
4386
behavior of "Stack"

0 commit comments

Comments
 (0)