summaryrefslogtreecommitdiff
path: root/chiselFrontend
diff options
context:
space:
mode:
authorducky2016-11-17 13:31:23 -0800
committerducky2016-11-21 13:31:12 -0800
commitd89b54acc5a41dcc7498d97af314e58f6cd891c8 (patch)
tree56a6079adff466d91ab3a054d506c8a65b138c07 /chiselFrontend
parentc270598ddb8cbfa32f8c86cc5187c89d00e6ded0 (diff)
Refactor some code
Diffstat (limited to 'chiselFrontend')
-rw-r--r--chiselFrontend/src/main/scala/chisel3/core/package.scala14
1 files changed, 6 insertions, 8 deletions
diff --git a/chiselFrontend/src/main/scala/chisel3/core/package.scala b/chiselFrontend/src/main/scala/chisel3/core/package.scala
index 3defb4f9..4a032523 100644
--- a/chiselFrontend/src/main/scala/chisel3/core/package.scala
+++ b/chiselFrontend/src/main/scala/chisel3/core/package.scala
@@ -76,21 +76,19 @@ package chisel3 {
implicit class fromStringToLiteral(val x: String) {
/** String to UInt parse, recommended style for constants.
*/
- def U: UInt = UInt.Lit(fromStringToLiteral.parse(x), fromStringToLiteral.parsedWidth(x)) // scalastyle:ignore method.name
+ def U: UInt = UInt.Lit(parse(x), parsedWidth(x)) // scalastyle:ignore method.name
/** String to UInt parse with specified width, recommended style for constants.
*/
- def U(width: Width): UInt = UInt.Lit(fromStringToLiteral.parse(x), width) // scalastyle:ignore method.name
+ def U(width: Width): UInt = UInt.Lit(parse(x), width) // scalastyle:ignore method.name
/** String to UInt parse, recommended style for variables.
*/
- def asUInt: UInt = UInt.Lit(fromStringToLiteral.parse(x), fromStringToLiteral.parsedWidth(x))
+ def asUInt: UInt = UInt.Lit(parse(x), parsedWidth(x))
/** String to UInt parse with specified width, recommended style for variables.
*/
- def asUInt(width: Width): UInt = UInt.Lit(fromStringToLiteral.parse(x), width)
- }
+ def asUInt(width: Width): UInt = UInt.Lit(parse(x), width)
- object fromStringToLiteral {
- def parse(n: String) = {
+ protected def parse(n: String) = {
val (base, num) = n.splitAt(1)
val radix = base match {
case "x" | "h" => 16
@@ -102,7 +100,7 @@ package chisel3 {
BigInt(num.filterNot(_ == '_'), radix)
}
- def parsedWidth(n: String) =
+ protected def parsedWidth(n: String) =
if (n(0) == 'b') {
Width(n.length-1)
} else if (n(0) == 'h') {