summaryrefslogtreecommitdiff
path: root/chiselFrontend/src/main/scala/chisel3/core/Data.scala
diff options
context:
space:
mode:
authorJim Lawson2016-08-16 11:08:32 -0700
committerJim Lawson2016-08-16 11:08:32 -0700
commita264157a47f56216cebf2d98c1c8118c344dad5f (patch)
tree1724fe2900ce336822e73f9cae8280b8474f62ab /chiselFrontend/src/main/scala/chisel3/core/Data.scala
parent4ab2aa0e9209000fb0ba1299ac18db2e033f708f (diff)
parentddb7278760029be9d960ba8bf2b06ac8a8aac767 (diff)
Merge branch 'master' into sdtwigg_connectwrap_renamechisel3
Diffstat (limited to 'chiselFrontend/src/main/scala/chisel3/core/Data.scala')
-rw-r--r--chiselFrontend/src/main/scala/chisel3/core/Data.scala12
1 files changed, 9 insertions, 3 deletions
diff --git a/chiselFrontend/src/main/scala/chisel3/core/Data.scala b/chiselFrontend/src/main/scala/chisel3/core/Data.scala
index 9115d1ba..bf68773f 100644
--- a/chiselFrontend/src/main/scala/chisel3/core/Data.scala
+++ b/chiselFrontend/src/main/scala/chisel3/core/Data.scala
@@ -117,8 +117,9 @@ abstract class Data extends HasId {
}
private[chisel3] def lref: Node = Node(this)
private[chisel3] def ref: Arg = if (isLit) litArg.get else lref
- private[chisel3] def cloneTypeWidth(width: Width): this.type
+ private[core] def cloneTypeWidth(width: Width): this.type
private[chisel3] def toType: String
+ private[core] def width: Width
def cloneType: this.type
def chiselCloneType: this.type = {
@@ -136,8 +137,13 @@ abstract class Data extends HasId {
def litValue(): BigInt = litArg.get.num
def isLit(): Boolean = litArg.isDefined
- private[core] def width: Width
+ /** Returns the width, in bits, if currently known.
+ * @throws java.util.NoSuchElementException if the width is not known. */
final def getWidth: Int = width.get
+ /** Returns whether the width is currently known. */
+ final def isWidthKnown: Boolean = width.known
+ /** Returns Some(width) if the width is known, else None. */
+ final def widthOption: Option[Int] = if (isWidthKnown) Some(getWidth) else None
// While this being in the Data API doesn't really make sense (should be in
// Aggregate, right?) this is because of an implementation limitation:
@@ -241,7 +247,7 @@ object Clock {
sealed class Clock extends Element(Width(1)) {
def cloneType: this.type = Clock().asInstanceOf[this.type]
private[chisel3] override def flatten: IndexedSeq[Bits] = IndexedSeq()
- private[chisel3] def cloneTypeWidth(width: Width): this.type = cloneType
+ private[core] def cloneTypeWidth(width: Width): this.type = cloneType
private[chisel3] def toType = "Clock"
override def connect (that: Data)(implicit sourceInfo: SourceInfo): Unit = that match {