diff options
| author | ducky | 2016-11-16 18:54:44 -0800 |
|---|---|---|
| committer | ducky | 2016-11-21 13:31:12 -0800 |
| commit | 9e32a39bda3fba11e6b0990e6ad5e7e17b5d8364 (patch) | |
| tree | 7153cd0aae8e6a614b8ba9079dbdb07f0e6a778b /chiselFrontend | |
| parent | e0b277a40693476247a68e7c52672b547d7ceb17 (diff) | |
Refactor SInt WIP
Diffstat (limited to 'chiselFrontend')
| -rw-r--r-- | chiselFrontend/src/main/scala/chisel3/core/Bits.scala | 36 |
1 files changed, 4 insertions, 32 deletions
diff --git a/chiselFrontend/src/main/scala/chisel3/core/Bits.scala b/chiselFrontend/src/main/scala/chisel3/core/Bits.scala index 70da27fc..7e467b88 100644 --- a/chiselFrontend/src/main/scala/chisel3/core/Bits.scala +++ b/chiselFrontend/src/main/scala/chisel3/core/Bits.scala @@ -555,7 +555,7 @@ trait UIntFactory { object UInt extends UIntFactory object Bits extends UIntFactory -sealed class SInt private (width: Width, lit: Option[SLit] = None) +sealed class SInt private[core] (width: Width, lit: Option[SLit] = None) extends Bits(width, lit) with Num[SInt] { private[core] override def cloneTypeWidth(w: Width): this.type = @@ -659,37 +659,23 @@ sealed class SInt private (width: Width, lit: Option[SLit] = None) } } -object SInt { +trait SIntFactory { /** Create an SInt type with inferred width. */ def apply(): SInt = apply(Width()) /** Create a SInt type or port with fixed width. */ def apply(width: Width): SInt = new SInt(width) - /** Create a SInt type or port with fixed width. */ - def width(width: Int): SInt = apply(Width(width)) - /** Create an SInt type with specified width. */ - def width(width: Width): SInt = new SInt(width) - - /** Create an SInt literal with inferred width. */ - def apply(value: BigInt): SInt = Lit(value) - /** Create an SInt literal with fixed width. */ - def apply(value: BigInt, width: Int): SInt = Lit(value, width) - - /** Create an SInt literal with specified width. */ - def apply(value: BigInt, width: Width): SInt = Lit(value, width) /** Create a SInt with the specified range */ def apply(range: Range): SInt = { - width(range.getWidth) + apply(range.getWidth) } /** Create a SInt with the specified range */ def apply(range: (NumericBound[Int], NumericBound[Int])): SInt = { apply(KnownSIntRange(range._1, range._2)) } - def Lit(value: BigInt): SInt = Lit(value, Width()) - def Lit(value: BigInt, width: Int): SInt = Lit(value, Width(width)) /** Create an SInt literal with specified width. */ - def Lit(value: BigInt, width: Width): SInt = { + protected def Lit(value: BigInt, width: Width): SInt = { val lit = SLit(value, width) val result = new SInt(lit.width, Some(lit)) @@ -697,20 +683,6 @@ 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(dir: Direction, width: Int): SInt = apply(dir, Width(width)) - /** Create a SInt with a specified direction, but unspecified width - compatibility with Chisel2. */ - def apply(dir: Direction): SInt = apply(dir, Width()) - def apply(dir: Direction, wWidth: Width): SInt = { - val result = apply(wWidth) - dir match { - case Direction.Input => Input(result) - case Direction.Output => Output(result) - case Direction.Unspecified => result - } - } } // REVIEW TODO: Why does this extend UInt and not Bits? Does defining airth |
