summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPaul Rigge2016-12-13 15:10:05 -0800
committerPaul Rigge2016-12-13 15:10:19 -0800
commit316d749df58421b52a72344c27137284d1413131 (patch)
tree99be3bea7b8e76f778c0202637cd02e24af20fb3 /src
parent53e9794ea4471d0da29d688cefdc462a9be98b63 (diff)
Checkpoint
Diffstat (limited to 'src')
-rw-r--r--src/main/scala/chisel3/package.scala1
-rw-r--r--src/test/scala/chiselTests/FixedPointSpec.scala22
2 files changed, 14 insertions, 9 deletions
diff --git a/src/main/scala/chisel3/package.scala b/src/main/scala/chisel3/package.scala
index 25d3ec3a..f20bb453 100644
--- a/src/main/scala/chisel3/package.scala
+++ b/src/main/scala/chisel3/package.scala
@@ -216,6 +216,7 @@ package object chisel3 { // scalastyle:ignore package.object.name
implicit class fromBooleanToLiteral(val x: Boolean) extends chisel3.core.fromBooleanToLiteral(x)
implicit class fromDoubleToLiteral(val x: Double) extends chisel3.core.fromDoubleToLiteral(x)
implicit class fromIntToWidth(val x: Int) extends chisel3.core.fromIntToWidth(x)
+ implicit class fromIntToBinaryPoint(val x: Int) extends chisel3.core.fromIntToBinaryPoint(x)
implicit class fromUIntToBitPatComparable(val x: UInt) {
import scala.language.experimental.macros
diff --git a/src/test/scala/chiselTests/FixedPointSpec.scala b/src/test/scala/chiselTests/FixedPointSpec.scala
index b3ea30b5..478e1716 100644
--- a/src/test/scala/chiselTests/FixedPointSpec.scala
+++ b/src/test/scala/chiselTests/FixedPointSpec.scala
@@ -7,7 +7,7 @@ import chisel3.testers.BasicTester
import org.scalatest._
//scalastyle:off magic.number
-class FixedPointSpec extends FlatSpec with Matchers {
+class FixedPointLiteralSpec extends FlatSpec with Matchers {
behavior of "fixed point utilities"
they should "allow conversion between doubles and the bigints needed to represent them" in {
@@ -17,22 +17,22 @@ class FixedPointSpec extends FlatSpec with Matchers {
initialDouble should be(finalDouble)
}
+}
- behavior of "fixed point"
-
- they should "allow fromBits from now fixed point types" in {
+class FixedPointFromBitsTester extends BasicTester {
val uint = 3.U
val sint = -3.S
- val fp_tpe = FixedPoint(width = 4, binaryPoint = 1)
+ val fp_tpe = FixedPoint(4.W, 1.BP)
val uint_result = FixedPoint.fromDouble(1.5, width = 4, binaryPoint = 1)
val sint_result = FixedPoint.fromDouble(-1.5, width = 4, binaryPoint = 1)
val uint2fp = fp_tpe.fromBits(uint)
val sint2fp = fp_tpe.fromBits(sint)
- uint2fp should be (uint_result)
- sint2fp should be (sint_result)
- }
+ assert(uint2fp === uint_result)
+ assert(sint2fp === sint_result)
+
+ stop()
}
class SBP extends Module {
@@ -50,8 +50,12 @@ class SBPTester extends BasicTester {
stop()
}
-class SBPSpec extends ChiselPropSpec {
+
+class FixedPointSpec extends ChiselPropSpec {
property("should allow set binary point") {
assertTesterPasses { new SBPTester }
}
+ property("should allow fromBits") {
+ assertTesterPasses { new FixedPointFromBitsTester }
+ }
}