diff options
| author | chick | 2016-11-09 15:57:06 -0800 |
|---|---|---|
| committer | ducky | 2016-11-21 12:48:10 -0800 |
| commit | bb1cb894f6f1c88e0d60de1501e86d68de7c0f76 (patch) | |
| tree | 1b308a6e4de6635012c6f91ae32699ee6132fbfe /chiselFrontend/src/main/scala/chisel3/core | |
| parent | dd28ef5d95e49c2822f9e37e8011ceab69cad532 (diff) | |
first attack on creating a range api for chisel3
Diffstat (limited to 'chiselFrontend/src/main/scala/chisel3/core')
| -rw-r--r-- | chiselFrontend/src/main/scala/chisel3/core/Bits.scala | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/chiselFrontend/src/main/scala/chisel3/core/Bits.scala b/chiselFrontend/src/main/scala/chisel3/core/Bits.scala index 4a09c70e..83733089 100644 --- a/chiselFrontend/src/main/scala/chisel3/core/Bits.scala +++ b/chiselFrontend/src/main/scala/chisel3/core/Bits.scala @@ -563,6 +563,10 @@ private[core] sealed trait UIntFactory { result.binding = LitBinding() result } + /** Create a UInt with the specified range */ + def apply(range: Range): UInt = { + width(range.getWidth) + } /** Create a UInt with a specified width - compatibility with Chisel2. */ // NOTE: This resolves UInt(width = 32) @@ -728,6 +732,11 @@ object SInt { /** 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) + } + 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. */ |
