Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import chisel3.experimental.BaseModule
import chisel3.experimental.hierarchy.{instantiable, public, Definition, Instance}
import chisel3.testing.scalatest.FileCheck
import chiselTests.experimental.ExtensionMethods.ChiselStageHelpers
import firrtl.annoSeqToSeq
import circt.stage.ChiselStage
import org.scalatest.funspec.AnyFunSpec
import org.scalatest.matchers.should.Matchers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ object Examples {
out := in + 1.U
}
@instantiable
class AddOneBlackBox extends ExtModule {
class AddOneBlackBox extends ExtModule with IsInstantiable {
@public val io = FlatIO(new Bundle {
val in = Input(UInt(32.W))
val out = Output(UInt(32.W))
Expand Down Expand Up @@ -126,7 +126,7 @@ object Examples {
io.out := io.in
}
@instantiable
class WireContainer {
class WireContainer extends IsInstantiable {
@public val innerWire = Wire(UInt(32.W))
}
@instantiable
Expand All @@ -138,7 +138,7 @@ object Examples {
out := wireContainer.innerWire
}
@instantiable
class AddOneContainer {
class AddOneContainer extends IsInstantiable {
@public val i0 = Module(new AddOne)
}
@instantiable
Expand All @@ -150,7 +150,7 @@ object Examples {
out := moduleContainer.i0.out
}
@instantiable
class AddOneInstanceContainer {
class AddOneInstanceContainer extends IsInstantiable {
val definition = Definition(new AddOne)
@public val i0 = Instance(definition)
}
Expand All @@ -163,7 +163,7 @@ object Examples {
out := instanceContainer.i0.out
}
@instantiable
class AddOneContainerContainer {
class AddOneContainerContainer extends IsInstantiable {
@public val container = new AddOneContainer
}
@instantiable
Expand All @@ -175,7 +175,7 @@ object Examples {
out := containerContainer.container.i0.out
}
@instantiable
class Viewer(val y: AddTwo, markPlease: Boolean) {
class Viewer(val y: AddTwo, markPlease: Boolean) extends IsInstantiable {
@public val x = y
if (markPlease) mark(x.i0.innerWire, "first")
}
Expand Down Expand Up @@ -296,14 +296,14 @@ object Examples {
}

@instantiable
class LeafInstantiable(val bundle: Data) {
@public val bundle = bundle
class LeafInstantiable(val _bundle: Data) extends IsInstantiable {
@public val bundle = _bundle
}

@instantiable
class NestedInstantiable(val in: LeafInstantiable, val out: LeafInstantiable) {
@public val in = in
@public val out = out
class NestedInstantiable(val _in: LeafInstantiable, val _out: LeafInstantiable) extends IsInstantiable {
@public val in = _in
@public val out = _out
}

@instantiable
Expand All @@ -314,7 +314,7 @@ object Examples {

@public val leafOut = new LeafInstantiable(out)
@public val leafIn = new LeafInstantiable(in)
@public val nested = new NestedInstantiable(in = leafIn, out = leafOut)
@public val nested = new NestedInstantiable(_in = leafIn, _out = leafOut)

}
@instantiable
Expand Down Expand Up @@ -450,11 +450,11 @@ object Examples {

// For test 9.c in DefinitionSpec - testing .toDefinition on Instance from imported Definition
@instantiable
class BarForImport extends RawModule {
class BarForImport extends RawModule with IsInstantiable {
@public val a = WireInit(false.B)
}
@instantiable
class FooForImport extends RawModule {
class FooForImport extends RawModule with IsInstantiable {
@public val bar = Module(new BarForImport)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import chisel3.testing.scalatest.FileCheck
import chisel3.util.{DecoupledIO, Valid}
import chisel3.experimental.{attach, Analog}
import chisel3.stage.{ChiselGeneratorAnnotation, DesignAnnotation}
import firrtl.annoSeqToSeq
import circt.stage.ChiselStage
import org.scalatest.funspec.AnyFunSpec
import org.scalatest.matchers.should.Matchers
Expand Down Expand Up @@ -639,7 +640,7 @@ class InstanceSpec extends AnyFunSpec with Matchers with Utils with FileCheck {
@public override val overriddenVal = 12
@public final val finalVal = 12
@public lazy val lazyValue = 12
@public val value = value
@public override val value = value
@public final override lazy val x: Int = 3
@public override final lazy val y: Int = 4
}
Expand Down Expand Up @@ -1317,7 +1318,9 @@ class InstanceSpec extends AnyFunSpec with Matchers with Utils with FileCheck {
}
ChiselStage.emitCHIRRTL(new Top)
}
it("(9.b): it should not work on inner classes") {
// Due to the differences between ClassTag in Scala 3 and TypeTag
// in Scala 2, isA should work on inner classes in Scala 3
ignore("(9.b): it should not work on inner classes") {
class InnerClass extends Module
class Top extends Module {
val d = Definition(new InnerClass)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import chisel3.stage.{ChiselCircuitAnnotation, ChiselGeneratorAnnotation, Design
import chisel3.testing.{FileCheck, HasTestingDirectory}
import chisel3.testing.scalatest.TestingDirectory
import circt.stage.{CIRCTTarget, CIRCTTargetAnnotation, ChiselStage}
import firrtl.AnnotationSeq
import firrtl.{annoSeqToSeq, seqToAnnoSeq, AnnotationSeq}
import java.nio.file.Paths
import org.scalatest.funspec.AnyFunSpec
import org.scalatest.matchers.should.Matchers
Expand Down
Loading