diff options
| author | Paul Rigge | 2016-12-01 13:35:48 -0800 |
|---|---|---|
| committer | Paul Rigge | 2016-12-13 15:10:19 -0800 |
| commit | 32c3c0d46dcd24ae3430ec151eacab5049bf07a9 (patch) | |
| tree | 2df95c19fcbc860ed27060d5743f7ccf66b0ef1d | |
| parent | c5b39d05dc723daf4297c7b016de745ce4712460 (diff) | |
Have FixedPoint use asFixedPoint in fromBits.
| -rw-r--r-- | chiselFrontend/src/main/scala/chisel3/core/Bits.scala | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/chiselFrontend/src/main/scala/chisel3/core/Bits.scala b/chiselFrontend/src/main/scala/chisel3/core/Bits.scala index 035ac213..a769342d 100644 --- a/chiselFrontend/src/main/scala/chisel3/core/Bits.scala +++ b/chiselFrontend/src/main/scala/chisel3/core/Bits.scala @@ -911,6 +911,12 @@ sealed class FixedPoint private (width: Width, val binaryPoint: BinaryPoint, lit override def do_asUInt(implicit sourceInfo: SourceInfo): UInt = pushOp(DefPrim(sourceInfo, UInt(this.width), AsUIntOp, ref)) override def do_asSInt(implicit sourceInfo: SourceInfo): SInt = pushOp(DefPrim(sourceInfo, SInt(this.width), AsSIntOp, ref)) //TODO(chick): Consider "convert" as an arithmetic conversion to UInt/SInt + + override def do_fromBits(that: Bits)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): this.type = { + val res = Wire(this, null).asInstanceOf[this.type] + res := that.asFixedPoint(this.binaryPoint) + res + } } /** Use PrivateObject to force users to specify width and binaryPoint by name |
