Skip to content

Commit 7ec20f5

Browse files
authored
Move chisel3 compatible casts {as,to}{S,U}Int from Bits to Node. (ucb-bar#744)
Make their definitions available to Aggregates. Add them to Bundle keywords.
1 parent 7465d5b commit 7ec20f5

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

src/main/scala/Bits.scala

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,8 @@ abstract class Bits extends Data with proc {
7272
}
7373

7474
def fromInt(x: Int): this.type
75-
def toSInt(): SInt = chiselCast(this){SInt()}
76-
def toUInt(): UInt = chiselCast(this){UInt()}
7775
override def getNode: Node = if (procAssigned) this else super.getNode
7876

79-
// Chisel3 - rename these to make the reinterpret cast more explicit
80-
final def asUInt() = toUInt
81-
final def asSInt() = toSInt
82-
8377
// internal, non user exposed connectors
8478
private var assigned = false
8579
private def checkAssign(src: Node) = {

src/main/scala/Bundle.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ object Bundle {
3535
val keywords = Set("elements", "flip", "toString",
3636
"flatten", "binding", "asInput", "asOutput", "unary_$tilde",
3737
"unary_$bang", "unary_$minus", "clone", "cloneType", "toUInt", "toBits",
38-
"toBool", "toSInt", "asDirectionless")
38+
"toBool", "toSInt", "asDirectionless", "asUInt", "asSInt")
3939

4040
def apply[T <: Bundle](b: => T)(implicit p: Parameters): T = {
4141
Driver.parStack.push(p.push)

src/main/scala/Node.scala

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,9 +439,14 @@ abstract class Node extends Nameable {
439439
if (!isTypeNode || inputs.isEmpty) this
440440
else inputs(0).getNode
441441

442-
// TODO: change function name to toUInt?
443442
/** @return This node as a UInt */
444443
def toBits(): UInt = chiselCast(this){UInt()}
444+
def toSInt(): SInt = chiselCast(this){SInt()}
445+
def toUInt(): UInt = chiselCast(this){UInt()}
446+
447+
// Chisel3 - rename these to make the reinterpret cast more explicit
448+
final def asUInt() = toUInt()
449+
final def asSInt() = toSInt()
445450

446451
/** @return This node */
447452
def toNode: Node = this

0 commit comments

Comments
 (0)