blob: fc6c5edc42ef55355111e72605b1919056c142e5 (
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
37
38
39
40
41
|
// See LICENSE for license details.
package chiselTests
import org.scalatest._
import chisel3._
import chisel3.testers.BasicTester
import chisel3.util._
class LastAssignTester() extends BasicTester {
val cnt = Counter(2)
val test = Wire(UInt(width=4))
assert(test === 7.U) // allow read references before assign references
test := 13.U
assert(test === 7.U) // output value should be position-independent
test := 7.U
assert(test === 7.U) // this obviously should work
when(cnt.value === 1.U) {
stop()
}
}
class ReassignmentTester() extends BasicTester {
val test = 15.U
test := 7.U
}
class MultiAssignSpec extends ChiselFlatSpec {
"The last assignment" should "be used when multiple assignments happen" in {
assertTesterPasses{ new LastAssignTester }
}
intercept[chisel3.internal.ChiselException] {
// "Reassignments to non-wire types" should "be disallowed" in {
assertTesterFails{ new ReassignmentTester }
}
}
|