diff options
| author | ducky | 2016-01-21 12:04:24 -0800 |
|---|---|---|
| committer | Andrew Waterman | 2016-05-04 02:11:09 -0700 |
| commit | 623a301df1f5a1954f8e4a64ef97c99c3900da28 (patch) | |
| tree | bc9c24679d590f4f2c5d291f9449de7eacd16cc3 /src/test/scala/chiselTests/MultiAssign.scala | |
| parent | cd951e193ed6a52c5146583a826e3cae5374d07b (diff) | |
Multiple assign tester
Closes #90
Diffstat (limited to 'src/test/scala/chiselTests/MultiAssign.scala')
| -rw-r--r-- | src/test/scala/chiselTests/MultiAssign.scala | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/test/scala/chiselTests/MultiAssign.scala b/src/test/scala/chiselTests/MultiAssign.scala new file mode 100644 index 00000000..2f464123 --- /dev/null +++ b/src/test/scala/chiselTests/MultiAssign.scala @@ -0,0 +1,38 @@ +// See LICENSE for license details. + +package chiselTests + +import org.scalatest._ +import Chisel._ +import Chisel.testers.BasicTester + +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 } + } +} |
