Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests for async reset regs of non-UInt types #1414

Merged
merged 1 commit into from
Apr 16, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions src/test/scala/chiselTests/AsyncResetSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,54 @@ class AsyncResetSpec extends ChiselFlatSpec {
assertTesterPasses(new AsyncResetQueueTester)
}

it should "support SInt regs" in {
assertTesterPasses(new BasicTester {
// Also check that it traces through wires
val initValue = Wire(SInt())
val reg = withReset(reset.asAsyncReset)(RegNext(initValue, 27.S))
jackkoenig marked this conversation as resolved.
Show resolved Hide resolved
initValue := -43.S
val (count, done) = Counter(true.B, 4)
when (count === 0.U) {
chisel3.assert(reg === 27.S)
} .otherwise {
chisel3.assert(reg === -43.S)
}
when (done) { stop() }
})
}

it should "support Fixed regs" in {
import chisel3.experimental.{withReset => _, _}
assertTesterPasses(new BasicTester {
val reg = withReset(reset.asAsyncReset)(RegNext(-6.0.F(2.BP), 3.F(2.BP)))
val (count, done) = Counter(true.B, 4)
when (count === 0.U) {
chisel3.assert(reg === 3.F(2.BP))
} .otherwise {
chisel3.assert(reg === -6.0.F(2.BP))
}
when (done) { stop() }
})
}

it should "support Interval regs" in {
import chisel3.experimental.{withReset => _, _}
assertTesterPasses(new BasicTester {
val reg = withReset(reset.asAsyncReset) {
val x = RegInit(Interval(range"[0,13]"), 13.I)
x := 7.I
x
}
val (count, done) = Counter(true.B, 4)
when (count === 0.U) {
chisel3.assert(reg === 13.I)
} .otherwise {
chisel3.assert(reg === 7.I)
}
when (done) { stop() }
})
}

it should "allow literals cast to Bundles as reset values" in {
class MyBundle extends Bundle {
val x = UInt(16.W)
Expand Down