Skip to content

Commit c1ad4e4

Browse files
authored
make FixedIOBaseModule work with D/I (#4216)
1 parent 65936c6 commit c1ad4e4

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

src/main/scala/chisel3/FixedIOModule.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,20 @@
22

33
package chisel3
44

5+
import chisel3.experimental.hierarchy.{instantiable, public}
56
import chisel3.experimental.{BaseModule, ExtModule, Param}
67

78
/** A module or external module whose IO is generated from a specific generator.
89
* This module may have no additional IO created other than what is specified
910
* by its `ioGenerator` abstract member.
1011
*/
12+
@instantiable
1113
sealed trait FixedIOBaseModule[A <: Data] extends BaseModule {
1214

1315
/** A generator of IO */
1416
protected def ioGenerator: A
1517

18+
@public
1619
final val io = FlatIO(ioGenerator)
1720
endIOCreation()
1821

src/test/scala/chiselTests/FixedIOModuleSpec.scala

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import circt.stage.ChiselStage
77
import scala.collection.immutable.ListMap
88
import chisel3.reflect.DataMirror.internal.chiselTypeClone
99
import chisel3.experimental.SourceInfo
10+
import chisel3.experimental.hierarchy.{instantiable, Definition, Instance, Instantiate}
1011
import chisel3.probe.Probe
1112

1213
class FixedIOModuleSpec extends ChiselFlatSpec with Utils with MatchesAndOmits {
@@ -255,4 +256,21 @@ class FixedIOModuleSpec extends ChiselFlatSpec with Utils with MatchesAndOmits {
255256
)()
256257
}
257258

259+
"FixedIOModule" should "work with D/I API" in {
260+
261+
class Foo(width: Int) extends FixedIORawModule[UInt](UInt(width.W)) {
262+
io :<>= DontCare
263+
}
264+
265+
class Bar extends RawModule {
266+
val fooDef = Definition(new Foo(8))
267+
val foo1 = Instance(fooDef)
268+
val foo2 = Instance(fooDef)
269+
foo1.io :<>= DontCare
270+
foo2.io :<>= DontCare
271+
}
272+
273+
matchesAndOmits(ChiselStage.emitCHIRRTL(new Bar))("module Foo :")()
274+
}
275+
258276
}

0 commit comments

Comments
 (0)