summaryrefslogtreecommitdiff
path: root/src/test/scala/chiselTests/IntegerMathSpec.scala
blob: 03b2b208b997e8130cc17c962c1108149b8ecee4 (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
// SPDX-License-Identifier: Apache-2.0

package chiselTests

import chisel3._
import chisel3.testers.BasicTester

class IntegerMathTester extends BasicTester {

  //TODO: Add more operators

  /* absolute values tests */

  val uint = 3.U(4.W)
  val sint = (-3).S
  val sintpos = 3.S
  val wrongSIntPos = 4.S

  assert(uint.abs() === uint)
  assert(sint.abs() === sintpos)
  assert(sintpos.abs() === sintpos)

  assert(sint.abs() =/= wrongSIntPos)

  stop()
}

class IntegerMathSpec extends ChiselPropSpec {
  property("All integer ops should return the correct result") {
    assertTesterPasses{ new IntegerMathTester }
  }
}