summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorducky2016-11-17 13:06:57 -0800
committerducky2016-11-21 13:31:12 -0800
commit73906fcc796b259c81d5df7733968b77fbb81ba8 (patch)
tree5f85e2e3cbf4753ddb4e8fa1014c465fa7005555
parent54d3f8dc054e55dfbd01d1aa034169a3dabe89f2 (diff)
All remaining automatable regex re-styles
-rw-r--r--src/main/scala/chisel3/package.scala5
-rw-r--r--src/test/scala/chiselTests/BitwiseOps.scala4
-rw-r--r--src/test/scala/chiselTests/ComplexAssign.scala2
-rw-r--r--src/test/scala/chiselTests/MemorySearch.scala2
-rw-r--r--src/test/scala/chiselTests/OptionBundle.scala4
-rw-r--r--src/test/scala/chiselTests/Risc.scala2
-rw-r--r--src/test/scala/chiselTests/Vec.scala2
7 files changed, 11 insertions, 10 deletions
diff --git a/src/main/scala/chisel3/package.scala b/src/main/scala/chisel3/package.scala
index 8b5b8a46..5b02be34 100644
--- a/src/main/scala/chisel3/package.scala
+++ b/src/main/scala/chisel3/package.scala
@@ -41,8 +41,9 @@ package object chisel3 { // scalastyle:ignore package.object.name
* UInt\(width\s*=\s*(\d+|[_a-zA-Z][_0-9a-zA-Z]*)\) => UInt($1.W)
* (UInt|SInt|Bits).width\((\d+|[_a-zA-Z][_0-9a-zA-Z]*)\) => $1($2.W)
* (U|S)Int\((-?\d+|0[xX][0-9a-fA-F]+)\) => $2.$1
- * UInt\((\d+|0[xX][0-9a-fA-F]+),\s*(?:width)?\s*=\s*(\d+)\) => $1.U($2.W)
- * (UInt|SInt)\(([_a-zA-Z][_0-9a-zA-Z]*)\) => $2.as$1
+ * UInt\((\d+|0[xX][0-9a-fA-F]+),\s*(?:width\s*=)?\s*(\d+|[_a-zA-Z][_0-9a-zA-Z]*)\) => $1.U($2.W)
+ * (UInt|SInt|Bool)\(([_a-zA-Z][_0-9a-zA-Z]*)\) => $2.as$1
+ * (UInt|SInt)\(([_a-zA-Z][_0-9a-zA-Z]*),\s*(?:width\s*=)?\s*(\d+|[_a-zA-Z][_0-9a-zA-Z]*)\) => $2.as$1($3.W)
*/
trait UIntFactory extends chisel3.core.UIntFactory {
/** Create a UInt literal with inferred width. */
diff --git a/src/test/scala/chiselTests/BitwiseOps.scala b/src/test/scala/chiselTests/BitwiseOps.scala
index 08999a1b..b8efaccf 100644
--- a/src/test/scala/chiselTests/BitwiseOps.scala
+++ b/src/test/scala/chiselTests/BitwiseOps.scala
@@ -9,8 +9,8 @@ import chisel3.testers.BasicTester
class BitwiseOpsTester(w: Int, _a: Int, _b: Int) extends BasicTester {
val mask = (1 << w) - 1
- val a = UInt(_a, w)
- val b = UInt(_b, w)
+ val a = _a.asUInt(w.W)
+ val b = _b.asUInt(w.W)
assert(~a === UInt(mask & ~_a))
assert((a & b) === UInt(_a & _b))
assert((a | b) === UInt(_a | _b))
diff --git a/src/test/scala/chiselTests/ComplexAssign.scala b/src/test/scala/chiselTests/ComplexAssign.scala
index f7484501..a13ec959 100644
--- a/src/test/scala/chiselTests/ComplexAssign.scala
+++ b/src/test/scala/chiselTests/ComplexAssign.scala
@@ -36,7 +36,7 @@ class ComplexAssignTester(enList: List[Boolean], re: Int, im: Int) extends Basic
val dut = Module(new ComplexAssign(32))
dut.io.in.re := re.asUInt
dut.io.in.im := im.asUInt
- dut.io.e := Vec(enList.map(Bool(_)))(cnt)
+ dut.io.e := Vec(enList.map(_.asBool))(cnt)
val re_correct = dut.io.out.re === Mux(dut.io.e, dut.io.in.re, 0.U)
val im_correct = dut.io.out.im === Mux(dut.io.e, dut.io.in.im, 0.U)
assert(re_correct && im_correct)
diff --git a/src/test/scala/chiselTests/MemorySearch.scala b/src/test/scala/chiselTests/MemorySearch.scala
index befbf010..4cbedf58 100644
--- a/src/test/scala/chiselTests/MemorySearch.scala
+++ b/src/test/scala/chiselTests/MemorySearch.scala
@@ -14,7 +14,7 @@ class MemorySearch extends Module {
})
val vals = Array(0, 4, 15, 14, 2, 5, 13)
val index = Reg(init = 0.U(3.W))
- val elts = Vec(vals.map(UInt(_,4)))
+ val elts = Vec(vals.map(_.asUInt(4.W)))
// val elts = Mem(UInt(32.W), 8) TODO ????
val elt = elts(index)
val end = !io.en && ((elt === io.target) || (index === 7.U))
diff --git a/src/test/scala/chiselTests/OptionBundle.scala b/src/test/scala/chiselTests/OptionBundle.scala
index d1b9152d..2ac661ea 100644
--- a/src/test/scala/chiselTests/OptionBundle.scala
+++ b/src/test/scala/chiselTests/OptionBundle.scala
@@ -26,8 +26,8 @@ class OptionBundleModule(hasIn: Boolean) extends Module {
class SomeOptionBundleTester(expected: Boolean) extends BasicTester {
val mod = Module(new OptionBundleModule(true))
- mod.io.in.get := Bool(expected)
- assert(mod.io.out === Bool(expected))
+ mod.io.in.get := expected.asBool
+ assert(mod.io.out === expected.asBool)
stop()
}
diff --git a/src/test/scala/chiselTests/Risc.scala b/src/test/scala/chiselTests/Risc.scala
index ae99df59..744e3631 100644
--- a/src/test/scala/chiselTests/Risc.scala
+++ b/src/test/scala/chiselTests/Risc.scala
@@ -73,7 +73,7 @@ class RiscTester(c: Risc) extends Tester(c) {
step(1)
}
def I (op: UInt, rc: Int, ra: Int, rb: Int) = {
- // val cr = Cat(op, UInt(rc, 8), UInt(ra, 8), UInt(rb, 8)).litValue()
+ // val cr = Cat(op, rc.asUInt(8.W), ra.asUInt(8.W), rb.asUInt(8.W)).litValue()
val cr = op.litValue() << 24 | rc << 16 | ra << 8 | rb
println("I = " + cr) // scalastyle:ignore regex
cr
diff --git a/src/test/scala/chiselTests/Vec.scala b/src/test/scala/chiselTests/Vec.scala
index 90e337a8..c621c1e1 100644
--- a/src/test/scala/chiselTests/Vec.scala
+++ b/src/test/scala/chiselTests/Vec.scala
@@ -11,7 +11,7 @@ import chisel3.util._
//import chisel3.core.ExplicitCompileOptions.Strict
class ValueTester(w: Int, values: List[Int]) extends BasicTester {
- val v = Vec(values.map(UInt(_, width = w))) // TODO: does this need a Wire? Why no error?
+ val v = Vec(values.map(_.asUInt(w.W))) // TODO: does this need a Wire? Why no error?
for ((a,b) <- v.zip(values)) {
assert(a === b.asUInt)
}