diff options
| author | Richard Lin | 2017-04-13 22:59:00 -0700 |
|---|---|---|
| committer | GitHub | 2017-04-13 22:59:00 -0700 |
| commit | e07248b8f6022fafdb84f5d1c0ebe3fc90a5475a (patch) | |
| tree | f2bb938fd35651b4fc7b88cbcd20e163cc75dd2e /src/test/scala/chiselTests/RawModuleSpec.scala | |
| parent | 97902cdc53eec52aa0cd806b8cb49a0e3f2fb769 (diff) | |
Module Hierarchy Refactor (#469)
Diffstat (limited to 'src/test/scala/chiselTests/RawModuleSpec.scala')
| -rw-r--r-- | src/test/scala/chiselTests/RawModuleSpec.scala | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/src/test/scala/chiselTests/RawModuleSpec.scala b/src/test/scala/chiselTests/RawModuleSpec.scala new file mode 100644 index 00000000..180a1c04 --- /dev/null +++ b/src/test/scala/chiselTests/RawModuleSpec.scala @@ -0,0 +1,65 @@ +// See LICENSE for license details. + +package chiselTests + +import chisel3._ +import chisel3.experimental.{RawModule, withClockAndReset} +import chisel3.testers.BasicTester + +class UnclockedPlusOne extends RawModule { + val in = IO(Input(UInt(32.W))) + val out = IO(Output(UInt(32.W))) + + out := in + 1.asUInt +} + +class RawModuleTester extends BasicTester { + val plusModule = Module(new UnclockedPlusOne) + plusModule.in := 42.U + assert(plusModule.out === 43.U) + stop() +} + +class PlusOneModule extends Module { + val io = IO(new Bundle { + val in = Input(UInt(32.W)) + val out = Output(UInt(32.W)) + }) + io.out := io.in + 1.asUInt +} + +class RawModuleWithImpliitModule extends RawModule { + val in = IO(Input(UInt(32.W))) + val out = IO(Output(UInt(32.W))) + val clk = IO(Input(Clock())) + val rst = IO(Input(Bool())) + + withClockAndReset(clk, rst) { + val plusModule = Module(new PlusOneModule) + plusModule.io.in := in + out := plusModule.io.out + } +} + +class ImplicitModuleInRawModuleTester extends BasicTester { + val plusModule = Module(new RawModuleWithImpliitModule) + plusModule.clk := clock + plusModule.rst := reset + plusModule.in := 42.U + assert(plusModule.out === 43.U) + stop() +} + +class RawModuleSpec extends ChiselFlatSpec { + "RawModule" should "elaborate" in { + elaborate { new RawModuleWithImpliitModule } + } + + "RawModule" should "work" in { + assertTesterPasses({ new RawModuleTester }) + } + + "ImplicitModule in a withClock block in a RawModule" should "work" in { + assertTesterPasses({ new ImplicitModuleInRawModuleTester }) + } +}
\ No newline at end of file |
