@@ -826,4 +826,44 @@ class BoringUtilsTapSpec extends ChiselFlatSpec with ChiselRunners with Utils wi
826
826
val e = the[ChiselException ] thrownBy circt.stage.ChiselStage .emitCHIRRTL(new Top )
827
827
e.getMessage should include(" BoringUtils currently only support identity views" )
828
828
}
829
+
830
+ it should " reuse existing port in a closed module" in {
831
+ class Foo extends Module {
832
+ val io = IO (Output (UInt (32 .W )))
833
+ val ioProbe = IO (probe.RWProbe (UInt (32 .W )))
834
+ probe.define(ioProbe, probe.RWProbeValue (io))
835
+ io := 0 .U
836
+ }
837
+
838
+ class Bar extends Module {
839
+ val foo = Module (new Foo )
840
+ val ioNames = reflect.DataMirror .modulePorts(foo).map(_._1) // close foo
841
+ val io = IO (Output (UInt (32 .W )))
842
+ io := foo.io
843
+ }
844
+
845
+ class Baz extends Module {
846
+ val bar = Module (new Bar )
847
+ val reProbe = Wire (probe.RWProbe (UInt (32 .W )))
848
+ probe.define(reProbe, BoringUtils .rwTap(bar.foo.ioProbe))
849
+ probe.forceInitial(reProbe, 1 .U )
850
+ }
851
+
852
+ val chirrtl = circt.stage.ChiselStage .emitCHIRRTL(new Baz )
853
+ matchesAndOmits(chirrtl)(
854
+ " module Foo :" ,
855
+ " output io : UInt<32>" ,
856
+ " output ioProbe : RWProbe<UInt<32>>" ,
857
+ " define ioProbe = rwprobe(io)" ,
858
+ " module Bar :" ,
859
+ " inst foo of Foo" ,
860
+ " output bore : RWProbe<UInt<32>>" ,
861
+ " define bore = foo.ioProbe" ,
862
+ " module Baz :" ,
863
+ " inst bar of Bar" ,
864
+ " wire reProbe : RWProbe<UInt<32>>" ,
865
+ " define reProbe = bar.bore" ,
866
+ " force_initial(reProbe, UInt<32>(0h1))"
867
+ )()
868
+ }
829
869
}
0 commit comments