From ebe7a0fb5774ec4bec919f9d3acd987d084d91b4 Mon Sep 17 00:00:00 2001 From: ducky Date: Thu, 17 Nov 2016 13:50:50 -0800 Subject: better style --- chiselFrontend/src/main/scala/chisel3/core/package.scala | 2 +- src/main/scala/chisel3/compatibility.scala | 10 +++++----- src/main/scala/chisel3/util/ImplicitConversions.scala | 2 ++ 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/chiselFrontend/src/main/scala/chisel3/core/package.scala b/chiselFrontend/src/main/scala/chisel3/core/package.scala index 4a032523..7c11d446 100644 --- a/chiselFrontend/src/main/scala/chisel3/core/package.scala +++ b/chiselFrontend/src/main/scala/chisel3/core/package.scala @@ -128,4 +128,4 @@ package chisel3 { def W: Width = Width(x) // scalastyle:ignore method.name } } -} \ No newline at end of file +} diff --git a/src/main/scala/chisel3/compatibility.scala b/src/main/scala/chisel3/compatibility.scala index fbe37f50..ff627c1e 100644 --- a/src/main/scala/chisel3/compatibility.scala +++ b/src/main/scala/chisel3/compatibility.scala @@ -90,15 +90,15 @@ package object Chisel { // scalastyle:ignore package.object.name def width(width: Width): SInt = apply(width) /** Create an SInt literal with inferred width. */ - def apply(value: BigInt): SInt = value.S + def apply(value: BigInt): SInt = value.asSInt /** Create an SInt literal with fixed width. */ - def apply(value: BigInt, width: Int): SInt = value.S(width.W) + def apply(value: BigInt, width: Int): SInt = value.asSInt(width.W) /** Create an SInt literal with specified width. */ - def apply(value: BigInt, width: Width): SInt = value.S(width) + def apply(value: BigInt, width: Width): SInt = value.asSInt(width) - def Lit(value: BigInt): SInt = value.S - def Lit(value: BigInt, width: Int): SInt = value.S(width.W) + def Lit(value: BigInt): SInt = value.asSInt + def Lit(value: BigInt, width: Int): SInt = value.asSInt(width.W) /** Create a SInt with a specified width - compatibility with Chisel2. */ def apply(dir: Option[Direction] = None, width: Int): SInt = apply(width.W) diff --git a/src/main/scala/chisel3/util/ImplicitConversions.scala b/src/main/scala/chisel3/util/ImplicitConversions.scala index 7f715ad4..c2ba710d 100644 --- a/src/main/scala/chisel3/util/ImplicitConversions.scala +++ b/src/main/scala/chisel3/util/ImplicitConversions.scala @@ -5,6 +5,8 @@ package chisel3.util import chisel3._ object ImplicitConversions { + // The explicit fromIntToLiteral resolves an ambiguous conversion between fromIntToLiteral and + // UInt.asUInt. implicit def intToUInt(x: Int): UInt = chisel3.core.fromIntToLiteral(x).asUInt implicit def booleanToBool(x: Boolean): Bool = x.asBool } -- cgit v1.2.3