diff options
| author | Jim Lawson | 2016-07-28 17:00:12 -0700 |
|---|---|---|
| committer | Jim Lawson | 2016-07-28 17:00:12 -0700 |
| commit | ac5bc19b5b4a3cc631900acf9dc04386a5c5cddc (patch) | |
| tree | b9676849fc449249c63156bf0fd36840b9be3a23 /chiselFrontend/src/main/scala/chisel3/core | |
| parent | 138329479914ac37b49a5a44841dc1de2929dca5 (diff) | |
Add missing factory constructors.
Diffstat (limited to 'chiselFrontend/src/main/scala/chisel3/core')
| -rw-r--r-- | chiselFrontend/src/main/scala/chisel3/core/Bits.scala | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/chiselFrontend/src/main/scala/chisel3/core/Bits.scala b/chiselFrontend/src/main/scala/chisel3/core/Bits.scala index 6df85c6a..9ef46402 100644 --- a/chiselFrontend/src/main/scala/chisel3/core/Bits.scala +++ b/chiselFrontend/src/main/scala/chisel3/core/Bits.scala @@ -526,6 +526,8 @@ private[core] sealed trait UIntFactory { def apply(value: BigInt, width: Int): UInt = Lit(value, Width(width)) /** Create a UInt literal with inferred width. */ def apply(n: String): UInt = Lit(n) + /** Create a UInt literal with fixed width. */ + def apply(n: String, width: Int): UInt = Lit(parse(n), width) /** Create a UInt literal with specified width. */ def apply(value: BigInt, width: Width): UInt = Lit(value, width) def Lit(value: BigInt, width: Int): UInt = Lit(value, Width(width)) @@ -544,13 +546,13 @@ private[core] sealed trait UIntFactory { } /** Create a UInt with a specified width - compatibility with Chisel2. */ - def apply(dummy: Option[Direction] = None, width: Int): UInt = apply(Width(width)) + def apply(dir: Option[Direction] = None, width: Int): UInt = apply(Width(width)) /** Create a UInt literal with inferred width.- compatibility with Chisel2. */ def apply(value: BigInt): UInt = apply(value, Width()) /** Create a UInt with a specified direction and width - compatibility with Chisel2. */ - def apply(direction: Direction, width: Int): UInt = { + def apply(dir: Direction, width: Int): UInt = { val result = apply(Width(width)) - direction match { + dir match { case Direction.Input => Input(result) case Direction.Output => Output(result) case Direction.Unspecified => result @@ -710,10 +712,12 @@ object SInt { result.binding = LitBinding() result } + /** Create a SInt with a specified width - compatibility with Chisel2. */ + def apply(dir: Option[Direction] = None, width: Int): SInt = apply(Width(width)) /** Create a SInt with a specified direction and width - compatibility with Chisel2. */ - def apply(direction: Direction, width: Int): SInt = { + def apply(dir: Direction, width: Int): SInt = { val result = apply(Width(width)) - direction match { + dir match { case Direction.Input => Input(result) case Direction.Output => Output(result) case Direction.Unspecified => result @@ -781,9 +785,9 @@ object Bool { result } /** Create a UInt with a specified direction and width - compatibility with Chisel2. */ - def apply(direction: Direction): Bool = { + def apply(dir: Direction): Bool = { val result = apply() - direction match { + dir match { case Direction.Input => Input(result) case Direction.Output => Output(result) case Direction.Unspecified => result |
