blob: c22a5e30c157429716ab42b3aec83068ef7d857c (
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
|
// 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 === UInt(7)) // allow read references before assign references
test := UInt(13)
assert(test === UInt(7)) // output value should be position-independent
test := UInt(7)
assert(test === UInt(7)) // this obviously should work
when(cnt.value === UInt(1)) {
stop()
}
}
class ReassignmentTester() extends BasicTester {
val test = UInt(15)
test := UInt(7)
}
class MultiAssignSpec extends ChiselFlatSpec {
"The last assignment" should "be used when multiple assignments happen" in {
assertTesterPasses{ new LastAssignTester }
}
"Reassignments to non-wire types" should "be disallowed" in {
assertTesterFails{ new ReassignmentTester }
}
}
|