summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJim Lawson2017-02-08 15:23:58 -0800
committerJack Koenig2017-02-08 15:23:58 -0800
commitf902b119069732910ca4b26ab45e0d6392464b3b (patch)
treedcdeb45660b1105598fa3aa0a85dc6ce41b4437f /src
parente23d24edbc35b68bf1002d169386e4c2007cf185 (diff)
Fix up deprecation warnings and clean up CompatibiltySpec code. (#471)
There was some dubious (certainly unclear) code organization in the CompatibiltySpec tests. The isPow2() test was randomly failing in Jenkins builds. This may address the problem.
Diffstat (limited to 'src')
-rw-r--r--src/test/scala/chiselTests/CompatibiltySpec.scala37
-rw-r--r--src/test/scala/chiselTests/MissingCloneBindingExceptionSpec.scala2
2 files changed, 21 insertions, 18 deletions
diff --git a/src/test/scala/chiselTests/CompatibiltySpec.scala b/src/test/scala/chiselTests/CompatibiltySpec.scala
index 20b64c55..dc55527c 100644
--- a/src/test/scala/chiselTests/CompatibiltySpec.scala
+++ b/src/test/scala/chiselTests/CompatibiltySpec.scala
@@ -37,28 +37,31 @@ class CompatibiltySpec extends ChiselFlatSpec with GeneratorDrivenPropertyChecks
it should "map utility objects into the package object" in {
{
val value: Int = Gen.choose(0, 2048).sample.get
- log2Up(value) shouldBe (1 max BigInt(value-1).bitLength)
- log2Ceil(value) shouldBe (BigInt(value-1).bitLength)
- log2Down(value) shouldBe ((1 max BigInt(value-1).bitLength) - (if (value > 0 && ((value & (value-1)) == 0)) 0 else 1))
- log2Floor(value) shouldBe (BigInt(value-1).bitLength - (if (value > 0 && ((value & (value-1)) == 0)) 0 else 1))
+ log2Up(value) shouldBe (1 max BigInt(value - 1).bitLength)
+ log2Ceil(value) shouldBe (BigInt(value - 1).bitLength)
+ log2Down(value) shouldBe ((1 max BigInt(value - 1).bitLength) - (if (value > 0 && ((value & (value - 1)) == 0)) 0 else 1))
+ log2Floor(value) shouldBe (BigInt(value - 1).bitLength - (if (value > 0 && ((value & (value - 1)) == 0)) 0 else 1))
if (value > 0) {
isPow2(1 << value) shouldBe true
isPow2((1 << value) - 1) shouldBe false
}
}
- {
- val value: Int = Gen.choose(1, Int.MaxValue).sample.get
- val binaryString = value.toBinaryString
- val maskPosition = Gen.choose(0, binaryString.length - 1).sample.get
- val bs = new StringBuilder(binaryString)
- bs(maskPosition) = '?'
- val bitPatString = bs.toString
- val bp = BitPat("b" + bitPatString)
- bp shouldBe a [BitPat]
- bp.getWidth shouldEqual binaryString.length
+ }
- }
+ it should "make BitPats available" in {
+ val value: Int = Gen.choose(1, Int.MaxValue).sample.get
+ val binaryString = value.toBinaryString
+ val maskPosition = Gen.choose(0, binaryString.length - 1).sample.get
+ val bs = new StringBuilder(binaryString)
+ bs(maskPosition) = '?'
+ val bitPatString = bs.toString
+ val bp = BitPat("b" + bitPatString)
+ bp shouldBe a [BitPat]
+ bp.getWidth shouldEqual binaryString.length
+
+ }
+ it should "successfully compile a complete module" in {
class Dummy extends Module {
// The following just checks that we can create objects with nothing more than the Chisel compatibility package.
val io = new Bundle
@@ -119,8 +122,8 @@ class CompatibiltySpec extends ChiselFlatSpec with GeneratorDrivenPropertyChecks
val valid = Bool(OUTPUT)
val out = Bits(OUTPUT, 32)
}
- val file = Mem(Bits(width = 32), 256)
- val code = Mem(Bits(width = 32), 256)
+ val file = Mem(256, Bits(width = 32))
+ val code = Mem(256, Bits(width = 32))
val pc = Reg(init=UInt(0, 8))
val add_op :: imm_op :: Nil = Enum(2)
diff --git a/src/test/scala/chiselTests/MissingCloneBindingExceptionSpec.scala b/src/test/scala/chiselTests/MissingCloneBindingExceptionSpec.scala
index 719484ac..bd1bade8 100644
--- a/src/test/scala/chiselTests/MissingCloneBindingExceptionSpec.scala
+++ b/src/test/scala/chiselTests/MissingCloneBindingExceptionSpec.scala
@@ -10,7 +10,7 @@ class MissingCloneBindingExceptionSpec extends ChiselFlatSpec with Matchers {
import chisel3._
class TestIO(w: Int) extends Bundle {
- val a = Vec(4, UInt(width = w)).asInput
+ val a = Vec(4, UInt(w.W)).asInput
//override def cloneType = (new TestIO(w)).asInstanceOf[this.type]
}