diff options
| author | Richard Lin | 2016-11-21 13:44:26 -0800 |
|---|---|---|
| committer | GitHub | 2016-11-21 13:44:26 -0800 |
| commit | 3b4755716a74d4711efa3ce6799742479e17e80b (patch) | |
| tree | 56652eaa478d5dfd8cddfbe2795c0123d39d230d /src/test/scala/chiselTests/BlackBox.scala | |
| parent | cd6eb41275381a4399a8a88c886110d276bb805c (diff) | |
| parent | 81e5d00d18a5ba9ae33c10219a270148002fc672 (diff) | |
Merge pull request #372 from ucb-bar/onetrueliteral
Standardize the One True Way of specifying literals
Diffstat (limited to 'src/test/scala/chiselTests/BlackBox.scala')
| -rw-r--r-- | src/test/scala/chiselTests/BlackBox.scala | 54 |
1 files changed, 27 insertions, 27 deletions
diff --git a/src/test/scala/chiselTests/BlackBox.scala b/src/test/scala/chiselTests/BlackBox.scala index d8821134..d42cd791 100644 --- a/src/test/scala/chiselTests/BlackBox.scala +++ b/src/test/scala/chiselTests/BlackBox.scala @@ -37,11 +37,11 @@ class BlackBoxTester extends BasicTester { val blackBoxPos = Module(new BlackBoxInverter) val blackBoxNeg = Module(new BlackBoxInverter) - blackBoxPos.io.in := UInt(1) - blackBoxNeg.io.in := UInt(0) + blackBoxPos.io.in := 1.U + blackBoxNeg.io.in := 0.U - assert(blackBoxNeg.io.out === UInt(1)) - assert(blackBoxPos.io.out === UInt(0)) + assert(blackBoxNeg.io.out === 1.U) + assert(blackBoxPos.io.out === 0.U) stop() } @@ -56,15 +56,15 @@ class MultiBlackBoxTester extends BasicTester { val blackBoxPassPos = Module(new BlackBoxPassthrough) val blackBoxPassNeg = Module(new BlackBoxPassthrough) - blackBoxInvPos.io.in := UInt(1) - blackBoxInvNeg.io.in := UInt(0) - blackBoxPassPos.io.in := UInt(1) - blackBoxPassNeg.io.in := UInt(0) + blackBoxInvPos.io.in := 1.U + blackBoxInvNeg.io.in := 0.U + blackBoxPassPos.io.in := 1.U + blackBoxPassNeg.io.in := 0.U - assert(blackBoxInvNeg.io.out === UInt(1)) - assert(blackBoxInvPos.io.out === UInt(0)) - assert(blackBoxPassNeg.io.out === UInt(0)) - assert(blackBoxPassPos.io.out === UInt(1)) + assert(blackBoxInvNeg.io.out === 1.U) + assert(blackBoxInvPos.io.out === 0.U) + assert(blackBoxPassNeg.io.out === 0.U) + assert(blackBoxPassPos.io.out === 1.U) stop() } @@ -72,14 +72,14 @@ class BlackBoxWithClockTester extends BasicTester { val blackBox = Module(new BlackBoxRegister) val model = Reg(Bool()) - val (cycles, end) = Counter(Bool(true), 15) + val (cycles, end) = Counter(true.B, 15) val impetus = cycles(0) blackBox.io.clock := clock blackBox.io.in := impetus model := impetus - when(cycles > UInt(0)) { + when(cycles > 0.U) { assert(blackBox.io.out === model) } when(end) { stop() } @@ -89,25 +89,25 @@ class BlackBoxConstant(value: Int) extends BlackBox( Map("VALUE" -> value, "WIDTH" -> log2Up(value + 1))) { require(value >= 0, "value must be a UInt!") val io = IO(new Bundle { - val out = UInt(width = log2Up(value + 1)).asOutput + val out = UInt(log2Up(value + 1).W).asOutput }) } class BlackBoxStringParam(str: String) extends BlackBox(Map("STRING" -> str)) { val io = IO(new Bundle { - val out = UInt(width = 32) + val out = UInt(32.W) }) } class BlackBoxRealParam(dbl: Double) extends BlackBox(Map("REAL" -> dbl)) { val io = IO(new Bundle { - val out = UInt(width = 64) + val out = UInt(64.W) }) } class BlackBoxTypeParam(w: Int, raw: String) extends BlackBox(Map("T" -> RawParam(raw))) { val io = IO(new Bundle { - val out = UInt(width = w) + val out = UInt(w.W) }) } @@ -121,16 +121,16 @@ class BlackBoxWithParamsTester extends BasicTester { val blackBoxTypeParamBit = Module(new BlackBoxTypeParam(1, "bit")) val blackBoxTypeParamWord = Module(new BlackBoxTypeParam(32, "bit [31:0]")) - val (cycles, end) = Counter(Bool(true), 4) + val (cycles, end) = Counter(true.B, 4) - assert(blackBoxOne.io.out === UInt(1)) - assert(blackBoxFour.io.out === UInt(4)) - assert(blackBoxStringParamOne.io.out === UInt(1)) - assert(blackBoxStringParamTwo.io.out === UInt(2)) - assert(blackBoxRealParamOne.io.out === UInt(0x3ff0000000000000L)) - assert(blackBoxRealParamNeg.io.out === UInt(BigInt("bff0000000000000", 16))) - assert(blackBoxTypeParamBit.io.out === UInt(1)) - assert(blackBoxTypeParamWord.io.out === UInt("hdeadbeef", 32)) + assert(blackBoxOne.io.out === 1.U) + assert(blackBoxFour.io.out === 4.U) + assert(blackBoxStringParamOne.io.out === 1.U) + assert(blackBoxStringParamTwo.io.out === 2.U) + assert(blackBoxRealParamOne.io.out === 0x3ff0000000000000L.U) + assert(blackBoxRealParamNeg.io.out === BigInt("bff0000000000000", 16).U) + assert(blackBoxTypeParamBit.io.out === 1.U) + assert(blackBoxTypeParamWord.io.out === "hdeadbeef".U(32.W)) when(end) { stop() } } |
