Skip to content

Commit 1b4df2d

Browse files
Add FixedIOModule (#4874)
1 parent 136294d commit 1b4df2d

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed

src/main/scala-2/chisel3/FixedIOModule.scala

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,14 @@ sealed trait FixedIOBaseModule[A <: Data] extends BaseModule {
2828
*/
2929
class FixedIORawModule[A <: Data](final val ioGenerator: A) extends RawModule with FixedIOBaseModule[A]
3030

31+
/** A Chisel module whose IO (in addition to [[clock]] and [[reset]]) is determined
32+
* by an IO generator. This module cannot have additional IO created by modules that
33+
* extend it.
34+
*
35+
* @param ioGenerator
36+
*/
37+
class FixedIOModule[A <: Data](final val ioGenerator: A) extends Module with FixedIOBaseModule[A]
38+
3139
/** A Chisel blackbox whose IO is determined by an IO generator. This module
3240
* cannot have additional IO created by modules that extend it.
3341
*

src/main/scala-3/chisel3/FixedIOModule.scala

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,14 @@ sealed trait FixedIOBaseModule[A <: Data] extends BaseModule {
2525
*/
2626
class FixedIORawModule[A <: Data](final val ioGenerator: A) extends RawModule with FixedIOBaseModule[A]
2727

28+
/** A Chisel module whose IO (in addition to [[clock]] and [[reset]]) is determined
29+
* by an IO generator. This module cannot have additional IO created by modules that
30+
* extend it.
31+
*
32+
* @param ioGenerator
33+
*/
34+
class FixedIOModule[A <: Data](final val ioGenerator: A) extends Module with FixedIOBaseModule[A]
35+
2836
/** A Chisel blackbox whose IO is determined by an IO generator. This module
2937
* cannot have additional IO created by modules that extend it.
3038
*

src/test/scala-2/chiselTests/FixedIOModuleSpec.scala

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,4 +320,20 @@ class FixedIOModuleSpec extends AnyFlatSpec with Matchers with FileCheck {
320320
ChiselStage.emitCHIRRTL(new Bar) should include("module Foo :")
321321
}
322322

323+
"FixedIOModule" should "create a module with flattened IO with clock and reset" in {
324+
class Foo(width: Int) extends FixedIOModule[UInt](UInt(width.W)) {
325+
override def resetType = Module.ResetType.Synchronous
326+
io :<>= DontCare
327+
}
328+
329+
ChiselStage
330+
.emitCHIRRTL(new Foo(8))
331+
.fileCheck()(
332+
"""| CHECK: module Foo :
333+
| CHECK: input clock : Clock
334+
| CHECK: input reset : UInt<1>
335+
| CHECK: output io : UInt<8>
336+
|""".stripMargin
337+
)
338+
}
323339
}

0 commit comments

Comments
 (0)