blob: c28e134421e91023b9bb35af8b4e3ff978ad6781 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
// SPDX-License-Identifier: Apache-2.0
package chiselTests
import chisel3._
import chisel3.stage.ChiselStage
import chisel3.testers.BasicTester
class ClockAsUIntTester extends BasicTester {
assert(true.B.asClock.asUInt === 1.U)
assert(true.B.asClock.asBool === true.B)
stop()
}
class WithClockAndNoReset extends RawModule {
val clock1 = IO(Input(Clock()))
val clock2 = IO(Input(Clock()))
val in = IO(Input(Bool()))
val out = IO(Output(Bool()))
val a = withClock(clock2) {
RegNext(in)
}
out := a
}
class ClockSpec extends ChiselPropSpec {
property("Bool.asClock.asUInt should pass a signal through unaltered") {
assertTesterPasses { new ClockAsUIntTester }
}
property("Should be able to use withClock in a module with no reset") {
val circuit = ChiselStage.emitChirrtl(new WithClockAndNoReset)
circuit.contains("reg a : UInt<1>, clock2") should be(true)
}
}
|