1313
1414package fixedpoint
1515
16- import chisel3 .{ fromDoubleToLiteral => _ , fromIntToBinaryPoint => _ , _ }
16+ import chisel3 ._
1717import chisel3 .experimental .BundleLiterals .AddBundleLiteralConstructor
1818import chisel3 .experimental .OpaqueType
1919import chisel3 .internal .firrtl .{KnownWidth , UnknownWidth , Width }
@@ -91,8 +91,7 @@ object FixedPoint extends NumObject {
9191 data : Data ,
9292 widthOption : Option [Width ] = None
9393 )(
94- implicit sourceInfo : SourceInfo ,
95- compileOptions : CompileOptions
94+ implicit sourceInfo : SourceInfo
9695 ): FixedPoint = {
9796 val _new = Wire (
9897 FixedPoint (
@@ -110,12 +109,7 @@ object FixedPoint extends NumObject {
110109
111110 /** Align all FixedPoints in a (possibly heterogeneous) sequence by width and binary point
112111 */
113- private [fixedpoint] def dataAligned [T <: Data ](
114- in : Iterable [T ]
115- )(
116- implicit sourceInfo : SourceInfo ,
117- compileOptions : CompileOptions
118- ): Seq [T ] = {
112+ private [fixedpoint] def dataAligned [T <: Data ](in : Iterable [T ])(implicit sourceInfo : SourceInfo ): Seq [T ] = {
119113 val bps = in.collect {
120114 case el : FixedPoint =>
121115 el.requireKnownBP()
@@ -145,12 +139,8 @@ object FixedPoint extends NumObject {
145139 out.toSeq
146140 }
147141
148- private [fixedpoint] def dataAligned (
149- in : FixedPoint *
150- )(
151- implicit sourceInfo : SourceInfo ,
152- compileOptions : CompileOptions
153- ): Seq [FixedPoint ] = dataAligned(in)
142+ private [fixedpoint] def dataAligned (in : FixedPoint * )(implicit sourceInfo : SourceInfo ): Seq [FixedPoint ] =
143+ dataAligned(in)
154144
155145 class ImplicitsCls private [fixedpoint] {
156146
@@ -193,13 +183,7 @@ sealed class FixedPoint private[fixedpoint] (width: Width, private var _inferred
193183 private def requireKnownBP (message : String = " Unknown binary point is not supported in this operation" ): Unit =
194184 if (! binaryPoint.known) throw new ChiselException (message)
195185
196- private def additiveOp (
197- that : FixedPoint ,
198- f : (SInt , SInt ) => SInt
199- )(
200- implicit sourceInfo : SourceInfo ,
201- compileOptions : CompileOptions
202- ): FixedPoint = {
186+ private def additiveOp (that : FixedPoint , f : (SInt , SInt ) => SInt )(implicit sourceInfo : SourceInfo ): FixedPoint = {
203187 val Seq (_this, _that) = FixedPoint .dataAligned(this , that).map(WireDefault (_))
204188 FixedPoint .fromData(binaryPoint.max(that.binaryPoint), f(_this.data, _that.data))
205189 }
@@ -209,13 +193,7 @@ sealed class FixedPoint private[fixedpoint] (width: Width, private var _inferred
209193 f(_this.data, _that.data)
210194 }
211195
212- private def connectOp (
213- that : Data ,
214- c : (Data , Data ) => Unit
215- )(
216- implicit sourceInfo : SourceInfo ,
217- connectCompileOptions : CompileOptions
218- ): Unit = {
196+ private def connectOp (that : Data , c : (Data , Data ) => Unit )(implicit sourceInfo : SourceInfo ): Unit = {
219197 that match {
220198 case that : FixedPoint =>
221199 if (binaryPoint.known) {
@@ -232,62 +210,49 @@ sealed class FixedPoint private[fixedpoint] (width: Width, private var _inferred
232210 }
233211 }
234212
235- override def do_+ (that : FixedPoint )(implicit sourceInfo : SourceInfo , compileOptions : CompileOptions ): FixedPoint =
236- additiveOp(that, _ + _)
213+ override def do_+ (that : FixedPoint )(implicit sourceInfo : SourceInfo ): FixedPoint = additiveOp(that, _ + _)
237214
238- override def do_- (that : FixedPoint )(implicit sourceInfo : SourceInfo , compileOptions : CompileOptions ): FixedPoint =
239- additiveOp(that, _ - _)
215+ override def do_- (that : FixedPoint )(implicit sourceInfo : SourceInfo ): FixedPoint = additiveOp(that, _ - _)
240216
241- def do_+% (that : FixedPoint )(implicit sourceInfo : SourceInfo , compileOptions : CompileOptions ): FixedPoint =
242- additiveOp(that, _ +% _)
217+ def do_+% (that : FixedPoint )(implicit sourceInfo : SourceInfo ): FixedPoint = additiveOp(that, _ +% _)
243218
244- def do_+& (that : FixedPoint )(implicit sourceInfo : SourceInfo , compileOptions : CompileOptions ): FixedPoint =
245- additiveOp(that, _ +& _)
219+ def do_+& (that : FixedPoint )(implicit sourceInfo : SourceInfo ): FixedPoint = additiveOp(that, _ +& _)
246220
247- def do_-% (that : FixedPoint )(implicit sourceInfo : SourceInfo , compileOptions : CompileOptions ): FixedPoint =
248- additiveOp(that, _ -% _)
221+ def do_-% (that : FixedPoint )(implicit sourceInfo : SourceInfo ): FixedPoint = additiveOp(that, _ -% _)
249222
250- def do_-& (that : FixedPoint )(implicit sourceInfo : SourceInfo , compileOptions : CompileOptions ): FixedPoint =
251- additiveOp(that, _ -& _)
223+ def do_-& (that : FixedPoint )(implicit sourceInfo : SourceInfo ): FixedPoint = additiveOp(that, _ -& _)
252224
253- def do_unary_- (implicit sourceInfo : SourceInfo , compileOptions : CompileOptions ): FixedPoint =
254- FixedPoint .fromData(binaryPoint, - data)
225+ def do_unary_- (implicit sourceInfo : SourceInfo ): FixedPoint = FixedPoint .fromData(binaryPoint, - data)
255226
256- def do_unary_-% (implicit sourceInfo : SourceInfo , compileOptions : CompileOptions ): FixedPoint =
257- FixedPoint .fromData(binaryPoint, data.unary_-% )
227+ def do_unary_-% (implicit sourceInfo : SourceInfo ): FixedPoint = FixedPoint .fromData(binaryPoint, data.unary_-% )
258228
259- override def do_* (that : FixedPoint )(implicit sourceInfo : SourceInfo , compileOptions : CompileOptions ): FixedPoint =
229+ override def do_* (that : FixedPoint )(implicit sourceInfo : SourceInfo ): FixedPoint =
260230 FixedPoint .fromData(binaryPoint + that.binaryPoint, data * that.data)
261231
262- override def do_/ (that : FixedPoint )(implicit sourceInfo : SourceInfo , compileOptions : CompileOptions ): FixedPoint =
232+ override def do_/ (that : FixedPoint )(implicit sourceInfo : SourceInfo ): FixedPoint =
263233 throw new ChiselException (s " division is illegal on FixedPoint types " )
264234
265- override def do_% (that : FixedPoint )(implicit sourceInfo : SourceInfo , compileOptions : CompileOptions ): FixedPoint =
235+ override def do_% (that : FixedPoint )(implicit sourceInfo : SourceInfo ): FixedPoint =
266236 throw new ChiselException (s " mod is illegal on FixedPoint types " )
267237
268- override def do_< (that : FixedPoint )(implicit sourceInfo : SourceInfo , compileOptions : CompileOptions ): Bool =
269- comparativeOp(that, _ < _)
238+ override def do_< (that : FixedPoint )(implicit sourceInfo : SourceInfo ): Bool = comparativeOp(that, _ < _)
270239
271- override def do_<= (that : FixedPoint )(implicit sourceInfo : SourceInfo , compileOptions : CompileOptions ): Bool =
272- comparativeOp(that, _ <= _)
240+ override def do_<= (that : FixedPoint )(implicit sourceInfo : SourceInfo ): Bool = comparativeOp(that, _ <= _)
273241
274- override def do_> (that : FixedPoint )(implicit sourceInfo : SourceInfo , compileOptions : CompileOptions ): Bool =
275- comparativeOp(that, _ > _)
242+ override def do_> (that : FixedPoint )(implicit sourceInfo : SourceInfo ): Bool = comparativeOp(that, _ > _)
276243
277- override def do_>= (that : FixedPoint )(implicit sourceInfo : SourceInfo , compileOptions : CompileOptions ): Bool =
278- comparativeOp(that, _ >= _)
244+ override def do_>= (that : FixedPoint )(implicit sourceInfo : SourceInfo ): Bool = comparativeOp(that, _ >= _)
279245
280- override def do_abs (implicit sourceInfo : SourceInfo , compileOptions : CompileOptions ): FixedPoint =
281- FixedPoint .fromData(binaryPoint, data.abs)
246+ override def do_abs (implicit sourceInfo : SourceInfo ): FixedPoint = FixedPoint .fromData(binaryPoint, data.abs)
282247
283- def do_floor (implicit sourceInfo : SourceInfo , compileOptions : CompileOptions ): FixedPoint = {
248+ def do_floor (implicit sourceInfo : SourceInfo ): FixedPoint = {
284249 requireKnownBP()
285250 // Set the fractional part to zeroes
286251 val floored = Cat (data >> binaryPoint.get, 0 .U (binaryPoint.get.W .min(width)))
287252 FixedPoint .fromData(binaryPoint, floored, Some (width))
288253 }
289254
290- def do_ceil (implicit sourceInfo : SourceInfo , compileOptions : CompileOptions ): FixedPoint = {
255+ def do_ceil (implicit sourceInfo : SourceInfo ): FixedPoint = {
291256 requireKnownBP()
292257 // Get a number with the fractional part set to ones
293258 val almostOne = ((1 << binaryPoint.get) - 1 ).S
@@ -296,39 +261,30 @@ sealed class FixedPoint private[fixedpoint] (width: Width, private var _inferred
296261 FixedPoint .fromData(binaryPoint, ceiled, Some (width))
297262 }
298263
299- def do_round (implicit sourceInfo : SourceInfo , compileOptions : CompileOptions ): FixedPoint = {
264+ def do_round (implicit sourceInfo : SourceInfo ): FixedPoint = {
300265 requireKnownBP()
301266 // Add 0.5 to the number and then floor it
302267 val rounded = (this + 0.5 .F (1 .BP )).floor.setBinaryPoint(binaryPoint.get)
303268 FixedPoint .fromData(binaryPoint, rounded, Some (width))
304269 }
305270
306- def do_=== (that : FixedPoint )(implicit sourceInfo : SourceInfo , compileOptions : CompileOptions ): Bool =
307- comparativeOp(that, _ === _)
271+ def do_=== (that : FixedPoint )(implicit sourceInfo : SourceInfo ): Bool = comparativeOp(that, _ === _)
308272
309- def do_=/= (that : FixedPoint )(implicit sourceInfo : SourceInfo , compileOptions : CompileOptions ): Bool =
310- comparativeOp(that, _ =/= _)
273+ def do_=/= (that : FixedPoint )(implicit sourceInfo : SourceInfo ): Bool = comparativeOp(that, _ =/= _)
311274
312- def do_!= (that : FixedPoint )(implicit sourceInfo : SourceInfo , compileOptions : CompileOptions ): Bool =
313- comparativeOp(that, _ =/= _)
275+ def do_!= (that : FixedPoint )(implicit sourceInfo : SourceInfo ): Bool = comparativeOp(that, _ =/= _)
314276
315- def do_>> (that : Int )(implicit sourceInfo : SourceInfo , compileOptions : CompileOptions ): FixedPoint =
316- FixedPoint .fromData(binaryPoint, data >> that)
277+ def do_>> (that : Int )(implicit sourceInfo : SourceInfo ): FixedPoint = FixedPoint .fromData(binaryPoint, data >> that)
317278
318- def do_>> (that : BigInt )(implicit sourceInfo : SourceInfo , compileOptions : CompileOptions ): FixedPoint =
319- FixedPoint .fromData(binaryPoint, data >> that)
279+ def do_>> (that : BigInt )(implicit sourceInfo : SourceInfo ): FixedPoint = FixedPoint .fromData(binaryPoint, data >> that)
320280
321- def do_>> (that : UInt )(implicit sourceInfo : SourceInfo , compileOptions : CompileOptions ): FixedPoint =
322- FixedPoint .fromData(binaryPoint, data >> that)
281+ def do_>> (that : UInt )(implicit sourceInfo : SourceInfo ): FixedPoint = FixedPoint .fromData(binaryPoint, data >> that)
323282
324- def do_<< (that : Int )(implicit sourceInfo : SourceInfo , compileOptions : CompileOptions ): FixedPoint =
325- FixedPoint .fromData(binaryPoint, data << that)
283+ def do_<< (that : Int )(implicit sourceInfo : SourceInfo ): FixedPoint = FixedPoint .fromData(binaryPoint, data << that)
326284
327- def do_<< (that : BigInt )(implicit sourceInfo : SourceInfo , compileOptions : CompileOptions ): FixedPoint =
328- FixedPoint .fromData(binaryPoint, data << that)
285+ def do_<< (that : BigInt )(implicit sourceInfo : SourceInfo ): FixedPoint = FixedPoint .fromData(binaryPoint, data << that)
329286
330- def do_<< (that : UInt )(implicit sourceInfo : SourceInfo , compileOptions : CompileOptions ): FixedPoint =
331- FixedPoint .fromData(binaryPoint, data << that)
287+ def do_<< (that : UInt )(implicit sourceInfo : SourceInfo ): FixedPoint = FixedPoint .fromData(binaryPoint, data << that)
332288
333289 def +% (that : FixedPoint ): FixedPoint = macro SourceInfoTransform .thatArg
334290
@@ -366,18 +322,11 @@ sealed class FixedPoint private[fixedpoint] (width: Width, private var _inferred
366322
367323 def << (that : UInt ): FixedPoint = macro SourceInfoWhiteboxTransform .thatArg
368324
369- override def connect (that : Data )(implicit sourceInfo : SourceInfo , connectCompileOptions : CompileOptions ): Unit =
370- connectOp(that, _ := _)
325+ override def connect (that : Data )(implicit sourceInfo : SourceInfo ): Unit = connectOp(that, _ := _)
371326
372- override def bulkConnect (that : Data )(implicit sourceInfo : SourceInfo , connectCompileOptions : CompileOptions ): Unit =
373- connectOp(that, _ <> _)
327+ override def bulkConnect (that : Data )(implicit sourceInfo : SourceInfo ): Unit = connectOp(that, _ <> _)
374328
375- override def connectFromBits (
376- that : Bits
377- )(
378- implicit sourceInfo : SourceInfo ,
379- compileOptions : CompileOptions
380- ): Unit = {
329+ override def connectFromBits (that : Bits )(implicit sourceInfo : SourceInfo ): Unit = {
381330 this .data := that.asTypeOf(this .data)
382331 }
383332
@@ -397,17 +346,12 @@ sealed class FixedPoint private[fixedpoint] (width: Width, private var _inferred
397346
398347 final def asSInt : SInt = data.asSInt
399348
400- def do_asFixedPoint (
401- binaryPoint : BinaryPoint
402- )(
403- implicit sourceInfo : SourceInfo ,
404- compileOptions : CompileOptions
405- ): FixedPoint = {
349+ def do_asFixedPoint (binaryPoint : BinaryPoint )(implicit sourceInfo : SourceInfo ): FixedPoint = {
406350 requireKnownBP(s " cannot call $this.asFixedPoint(binaryPoint= $binaryPoint), you must specify a known binaryPoint " )
407351 FixedPoint .fromData(binaryPoint, data, Some (width))
408352 }
409353
410- def do_setBinaryPoint (that : Int )(implicit sourceInfo : SourceInfo , compileOptions : CompileOptions ): FixedPoint = {
354+ def do_setBinaryPoint (that : Int )(implicit sourceInfo : SourceInfo ): FixedPoint = {
411355 requireKnownBP(s " cannot set new binary point if current binary point is unknown " )
412356 val diff = that - binaryPoint.get
413357 FixedPoint .fromData(
@@ -424,10 +368,6 @@ sealed class FixedPoint private[fixedpoint] (width: Width, private var _inferred
424368
425369 def widthKnown : Boolean = data.widthKnown
426370
427- override def typeEquivalent (that : Data ): Boolean = {
428- this .getClass == that.getClass
429- }
430-
431371 override def litOption : Option [BigInt ] = data.litOption
432372
433373 override def litValue : BigInt = data.litValue
0 commit comments