Skip to content

Commit 06cb11a

Browse files
committed
Cross compilation fixes
1 parent acae90f commit 06cb11a

File tree

9 files changed

+28
-136
lines changed

9 files changed

+28
-136
lines changed

core/src/main/scala-2/chisel3/experimental/dataview/ChiselSubtypeOf.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ import scala.reflect.macros.blackbox.Context
2727
*/
2828
sealed trait ChiselSubtypeOf[A, B]
2929

30+
31+
// return an empty tree here instead of a quasiquote for scala3 compatibility
3032
object ChiselSubtypeOf {
3133
// TODO return an empty tree here instead of a quasiquote for scala3 compatibility
3234
def genChiselSubtypeOf[A: c.WeakTypeTag, B: c.WeakTypeTag](c: Context): c.Tree = {

core/src/main/scala/chisel3/BitsImpl.scala

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@ private[chisel3] trait BitsImpl extends Element { self: Bits =>
2323
// Only used for in a few cases, hopefully to be removed
2424
private[chisel3] def cloneTypeWidth(width: Width): this.type
2525

26-
def cloneType: this.type = cloneTypeWidth(width)
26+
def cloneType: this.type = cloneTypeWidth(this.width)
2727

2828
/** A non-ambiguous name of this `Bits` instance for use in generated Verilog names
2929
* Inserts the width directly after the typeName, e.g. UInt4, SInt1
3030
*/
31-
override def typeName: String = s"${simpleClassName(this.getClass)}$width"
31+
override def typeName: String = s"${simpleClassName(this.getClass)}${this.width}"
3232

3333
protected def _tailImpl(n: Int)(implicit sourceInfo: SourceInfo): UInt = {
34-
val w = width match {
34+
val w = this.width match {
3535
case KnownWidth(x) =>
3636
require(x >= n, s"Can't tail($n) for width $x < $n")
3737
Width(x - n)
@@ -99,7 +99,7 @@ private[chisel3] trait BitsImpl extends Element { self: Bits =>
9999
}
100100

101101
protected def _applyImpl(x: UInt)(implicit sourceInfo: SourceInfo): Bool =
102-
do_extract(x)
102+
extract(x)
103103

104104
protected def _applyImpl(x: Int, y: Int)(implicit sourceInfo: SourceInfo): UInt = {
105105
if ((x < y && !(x == -1 && y == 0)) || y < 0) {
@@ -330,15 +330,15 @@ private[chisel3] trait UIntImpl extends BitsImpl with Num[UInt] { self: UInt =>
330330
protected def _rotateLeftImpl(n: Int)(implicit sourceInfo: SourceInfo): UInt = width match {
331331
case _ if (n == 0) => this
332332
case KnownWidth(w) if (w <= 1) => this
333-
case KnownWidth(w) if n >= w => do_rotateLeft(n % w)
334-
case _ if (n < 0) => do_rotateRight(-n)
333+
case KnownWidth(w) if n >= w => rotateLeft(n % w)
334+
case _ if (n < 0) => rotateRight(-n)
335335
case _ => tail(n) ## head(n)
336336
}
337337

338338
protected def _rotateRightImpl(n: Int)(implicit sourceInfo: SourceInfo): UInt = width match {
339-
case _ if (n <= 0) => do_rotateLeft(-n)
339+
case _ if (n <= 0) => rotateLeft(-n)
340340
case KnownWidth(w) if (w <= 1) => this
341-
case KnownWidth(w) if n >= w => do_rotateRight(n % w)
341+
case KnownWidth(w) if n >= w => rotateRight(n % w)
342342
case _ => this(n - 1, 0) ## (this >> n)
343343
}
344344

core/src/main/scala/chisel3/ChiselEnumImpl.scala

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ private[chisel3] abstract class EnumTypeImpl(private[chisel3] val factory: Chise
7070
_wire := this.asUInt
7171
_wire
7272
}
73-
_padded.do_asTypeOf(that)
74-
case None => super.do_asTypeOf(that)
73+
_padded.asTypeOf(that)
74+
case None => super.asTypeOf(that)
7575
}
7676
}
7777

@@ -154,7 +154,7 @@ private[chisel3] abstract class EnumTypeImpl(private[chisel3] val factory: Chise
154154
}
155155

156156
// This function conducts a depth-wise search to find all enum-type fields within a vector or bundle (or vector of bundles)
157-
private def enumFields(d: Aggregate): Seq[Seq[String]] = d match {
157+
private def enumFields(d: Data): Seq[Seq[String]] = d match {
158158
case v: Vec[_] =>
159159
v.sample_element match {
160160
case b: Bundle => enumFields(b)
@@ -222,7 +222,15 @@ private[chisel3] abstract class EnumTypeImpl(private[chisel3] val factory: Chise
222222
for ((name, value) <- allNamesPadded) {
223223
when(this === value) {
224224
for ((r, c) <- result.zip(name)) {
225-
r := c.toChar.U
225+
// todo: this doesn't work in scala3
226+
// r := c.toChar.U
227+
// ^^^^^^^^^^
228+
// value U is not a member of Char.
229+
// An extension method was tried,
230+
// but could not be fully constructed:
231+
//
232+
// chisel3.fromLongToLiteral(c.toChar)
233+
// r := c.toChar.U
226234
}
227235
}
228236
}
@@ -355,7 +363,8 @@ private[chisel3] trait ChiselEnumImpl { self: ChiselEnum =>
355363
// This is an enum type that can be connected directly to UInts. It is used as a "glue" to cast non-literal UInts
356364
// to enums.
357365
private[chisel3] class UnsafeEnum(override val width: Width) extends EnumType(UnsafeEnum, selfAnnotating = false) {
358-
override def cloneType: this.type = new UnsafeEnum(width).asInstanceOf[this.type]
366+
367+
override def _cloneType: Data = new UnsafeEnum(width)
359368
}
360369
private object UnsafeEnum extends ChiselEnum
361370

core/src/main/scala/chisel3/experimental/dataview/DataView.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import chisel3.reflect.DataMirror.internal.chiselTypeClone
77
import chisel3.experimental.{HWTuple10, HWTuple2, HWTuple3, HWTuple4, HWTuple5, HWTuple6, HWTuple7, HWTuple8, HWTuple9}
88
import chisel3.experimental.{ChiselSubtypeOf, SourceInfo, UnlocatableSourceInfo}
99

10-
import scala.reflect.runtime.universe.WeakTypeTag
1110
import annotation.implicitNotFound
1211

1312
/** Mapping between a target type `T` and a view type `V`

core/src/main/scala/chisel3/experimental/dataview/package.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ package object dataview {
7373

7474
/** View a [[Bundle]] or [[Record]] as a parent type (upcast) */
7575
def viewAsSupertype[V <: Record](proto: V)(implicit ev: ChiselSubtypeOf[T, V], sourceInfo: SourceInfo): V = {
76-
implicit val dataView = PartialDataView.supertype[T, V](_ => proto)
76+
implicit val dataView: DataView[T, V] = PartialDataView.supertype[T, V](_ => proto)
7777
target.viewAs[V]
7878
}
7979
}

core/src/main/scala/chisel3/experimental/hierarchy/InstantiateImpl.scala

Lines changed: 0 additions & 104 deletions
This file was deleted.

core/src/main/scala/chisel3/experimental/package.scala

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,6 @@ package object experimental {
9191
@deprecated("FlatIO has moved to package chisel3", "Chisel 6.0")
9292
val FlatIO = chisel3.FlatIO
9393

94-
class dump extends chisel3.internal.naming.dump
95-
class treedump extends chisel3.internal.naming.treedump
96-
9794
/** Generate prefixes from values of this type in the Chisel compiler plugin
9895
*
9996
* Users can mixin this trait to tell the Chisel compiler plugin to include the names of
@@ -132,7 +129,8 @@ package object experimental {
132129
object BundleLiterals {
133130
implicit class AddBundleLiteralConstructor[T <: Record](x: T) {
134131
def Lit(elems: (T => (Data, Data))*)(implicit sourceInfo: SourceInfo): T = {
135-
x._makeLit(elems: _*)
132+
val fs = elems.map(_.asInstanceOf[Data => (Data, Data)])
133+
x._makeLit(fs: _*).asInstanceOf[T]
136134
}
137135
}
138136
}

core/src/main/scala/chisel3/package.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import scala.annotation.{nowarn, tailrec}
1212
/** This package contains the main chisel3 API.
1313
*/
1414
package object chisel3 {
15-
import internal.chiselRuntimeDeprecated
1615
import experimental.{DeprecatedSourceInfo, UnlocatableSourceInfo}
1716
import internal.firrtl.ir.Port
1817
import internal.Builder

core/src/main/scala/chisel3/properties/Property.scala

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import chisel3.internal.binding._
1010
import chisel3.internal.firrtl.{ir, Converter}
1111
import chisel3.experimental.{prefix, requireIsHardware, Analog, SourceInfo}
1212
import chisel3.experimental.hierarchy.Instance
13-
import scala.reflect.runtime.universe.{typeOf, TypeTag}
1413
import scala.annotation.{implicitAmbiguous, implicitNotFound}
1514
import chisel3.experimental.BaseModule
1615
import chisel3.internal.NamedComponent
@@ -278,18 +277,8 @@ sealed trait Property[T] extends Element { self =>
278277

279278
/** Clone type by simply constructing a new Property[T].
280279
*/
281-
override def cloneType: this.type = new Property[T] {
280+
override def _cloneType: Data = new Property[T] {
282281
val tpe = self.tpe
283-
}.asInstanceOf[this.type]
284-
285-
/** Clone type with extra information preserved.
286-
*
287-
* The only extra information present on a Property type is directionality.
288-
*/
289-
private[chisel3] override def cloneTypeFull: this.type = {
290-
val clone = this.cloneType
291-
clone.specifiedDirection = specifiedDirection
292-
clone
293282
}
294283

295284
/** Get the IR PropertyType for this Property.

0 commit comments

Comments
 (0)