@@ -549,7 +549,20 @@ class DefinitionSpec extends AnyFunSpec with Matchers with FileCheck {
549549 |""" .stripMargin
550550 )
551551 }
552- it(" (3.k): should work on unimplemented vals in abstract classes/traits" ) {
552+ it(" (3.k): should expose public constructor vals" ) {
553+ @ instantiable
554+ class Foo (@ public val x : Int , @ public val y : Int = 0 ) extends Module
555+ class Top extends Module {
556+ val definition = Definition (new Foo (1 ))
557+ definition.x should be(1 )
558+ definition.y should be(0 )
559+ val instance = Instance (definition)
560+ instance.x should be(1 )
561+ instance.y should be(0 )
562+ }
563+ ChiselStage .emitCHIRRTL(new Top ) should include(" module Foo :" )
564+ }
565+ it(" (3.l): should work on unimplemented vals in abstract classes/traits" ) {
553566 class Top () extends Module {
554567 val i = Definition (new ConcreteHasBlah ())
555568 def f (d : Definition [HasBlah ]): Unit = {
@@ -566,7 +579,7 @@ class DefinitionSpec extends AnyFunSpec with Matchers with FileCheck {
566579 |""" .stripMargin
567580 )
568581 }
569- it(" (3.l ): should work on eithers" ) {
582+ it(" (3.m ): should work on eithers" ) {
570583 class Top () extends Module {
571584 val i = Definition (new HasEither ())
572585 i.x.map(x => mark(x, " xright" )).left.map(x => mark(x, " xleft" ))
@@ -584,7 +597,7 @@ class DefinitionSpec extends AnyFunSpec with Matchers with FileCheck {
584597 |""" .stripMargin
585598 )
586599 }
587- it(" (3.m ): should work on tuple2" ) {
600+ it(" (3.n ): should work on tuple2" ) {
588601 class Top () extends Module {
589602 val i = Definition (new HasTuple2 ())
590603 mark(i.xy._1, " x" )
@@ -602,7 +615,7 @@ class DefinitionSpec extends AnyFunSpec with Matchers with FileCheck {
602615 |""" .stripMargin
603616 )
604617 }
605- it(" (3.n ): should work on Mems/SyncReadMems" ) {
618+ it(" (3.o ): should work on Mems/SyncReadMems" ) {
606619 class Top () extends Module {
607620 val i = Definition (new HasMems ())
608621 mark(i.mem, " Mem" )
@@ -620,7 +633,7 @@ class DefinitionSpec extends AnyFunSpec with Matchers with FileCheck {
620633 |""" .stripMargin
621634 )
622635 }
623- it(" (3.o ): should not create memory ports" ) {
636+ it(" (3.p ): should not create memory ports" ) {
624637 class Top () extends Module {
625638 val i = Definition (new HasMems ())
626639 i.mem(0 ) := 100 .U // should be illegal!
@@ -631,7 +644,7 @@ class DefinitionSpec extends AnyFunSpec with Matchers with FileCheck {
631644 " Cannot create a memory port in a different module (Top) than where the memory is (HasMems)."
632645 )
633646 }
634- it(" (3.p ): should work on HasTarget" ) {
647+ it(" (3.q ): should work on HasTarget" ) {
635648 class Top () extends Module {
636649 val i = Definition (new HasHasTarget )
637650 mark(i.x, " x" )
@@ -645,7 +658,7 @@ class DefinitionSpec extends AnyFunSpec with Matchers with FileCheck {
645658 |""" .stripMargin
646659 )
647660 }
648- it(" (3.q ): should work on Tuple5 with a Module in it" ) {
661+ it(" (3.r ): should work on Tuple5 with a Module in it" ) {
649662 class Top () extends Module {
650663 val defn = Definition (new HasTuple5 ())
651664 val (3 , w : UInt , " hi" , inst : Instance [AddOne ], l) = defn.tup
0 commit comments