diff options
| author | ducky | 2015-10-21 14:42:50 -0700 |
|---|---|---|
| committer | ducky | 2015-10-21 15:26:55 -0700 |
| commit | 57c760c22177ca7e41888729d5036daf35c739ed (patch) | |
| tree | 2722ab57c0d38fc9c94cd4e190a4c18d7272f4d4 /src | |
| parent | f7b496d14087c9838e3ed02413bb924f61a8d774 (diff) | |
Scalastyle fixes involving changing code
Diffstat (limited to 'src')
| -rw-r--r-- | src/main/scala/Chisel/Core.scala | 17 | ||||
| -rw-r--r-- | src/main/scala/Chisel/FP.scala | 13 | ||||
| -rw-r--r-- | src/main/scala/Chisel/Utils.scala | 23 |
3 files changed, 38 insertions, 15 deletions
diff --git a/src/main/scala/Chisel/Core.scala b/src/main/scala/Chisel/Core.scala index 872f4a2a..486f0ff3 100644 --- a/src/main/scala/Chisel/Core.scala +++ b/src/main/scala/Chisel/Core.scala @@ -168,7 +168,7 @@ object Reg { } object Mem { - @deprecated("Chisel3 Mem argument order should be size, t - this will be removed by Chisel3 official release", "now") + @deprecated("Mem argument order should be size, t; this will be removed by the official release", "chisel3") def apply[T <: Data](t: T, size: Int): Mem[T] = apply(size, t) /** Creates a combinational-read, sequential-write [[Mem]]. @@ -234,7 +234,7 @@ sealed abstract class MemBase[T <: Data](t: T, val length: Int) extends HasId wi sealed class Mem[T <: Data](t: T, length: Int) extends MemBase(t, length) object SeqMem { - @deprecated("Chisel3 SeqMem argument order should be size, t - this will be removed by Chisel3 official release", "now") + @deprecated("SeqMem argument order should be size, t; this will be removed by the official release", "chisel3") def apply[T <: Data](t: T, size: Int): SeqMem[T] = apply(size, t) /** Creates a sequential-read, sequential-write [[SeqMem]]. @@ -269,7 +269,7 @@ object Vec { */ def apply[T <: Data](n: Int, gen: T): Vec[T] = new Vec(gen.cloneType, n) - @deprecated("Chisel3 vec argument order should be n, gen - this will be removed by Chisel3 official release", "now") + @deprecated("Vec argument order should be size, t; this will be removed by the official release", "chisel3") def apply[T <: Data](gen: T, n: Int): Vec[T] = new Vec(gen.cloneType, n) /** Creates a new [[Vec]] composed of elements of the input Seq of [[Data]] @@ -1190,7 +1190,13 @@ class Bundle extends Aggregate(NO_DIR) { } ArrayBuffer(nameMap.toSeq:_*) sortWith {case ((an, a), (bn, b)) => (a._id > b._id) || ((a eq b) && (an > bn))} } - private[Chisel] def toType = s"{${namedElts.reverse.map(e => (if (e._2.isFlip) "flip " else "") + e._2.getRef.name + " : " + e._2.toType).reduce(_ + ", " + _)}}" + private[Chisel] def toType = { + def eltPort(elt: Data): String = { + val flipStr = if (elt.isFlip) "flip " else "" + s"${flipStr}${elt.getRef.name} : ${elt.toType}" + } + s"{${namedElts.reverse.map(e => eltPort(e._2)).mkString(", ")}}" + } private[Chisel] lazy val flatten = namedElts.flatMap(_._2.flatten) private[Chisel] def addElt(name: String, elt: Data): Unit = namedElts += name -> elt @@ -1214,7 +1220,8 @@ class Bundle extends Aggregate(NO_DIR) { constructor.newInstance(_parent.get).asInstanceOf[this.type] } catch { case _: java.lang.reflect.InvocationTargetException => - Builder.error(s"Parameterized Bundle ${this.getClass} needs cloneType method. You are probably using an anonymous Bundle object that captures external state and hence is un-cloneTypeable") + Builder.error(s"Parameterized Bundle ${this.getClass} needs cloneType method. You are probably using " + + "an anonymous Bundle object that captures external state and hence is un-cloneTypeable") this } case _: java.lang.reflect.InvocationTargetException | _: java.lang.IllegalArgumentException => diff --git a/src/main/scala/Chisel/FP.scala b/src/main/scala/Chisel/FP.scala index 252ffdcb..f997ac8f 100644 --- a/src/main/scala/Chisel/FP.scala +++ b/src/main/scala/Chisel/FP.scala @@ -15,6 +15,8 @@ case class DblLit(num: Double) extends Arg { } object Flo { + val Width = 32 + def apply(x: Float): Flo = new Flo(NO_DIR, Some(FloLit(x))) def apply(x: Double): Flo = Flo(x.toFloat) def apply(dir: Direction = null): Flo = new Flo(dir) @@ -61,14 +63,15 @@ sealed abstract class FloBase[T <: Data](dir: Direction, width: Width) extends E def toUInt = toBits } -class Flo(dir: Direction = NO_DIR, val value:Option[FloLit] = None) extends FloBase[Flo](dir, Width(32)) with Num[Flo] { +class Flo(dir: Direction = NO_DIR, val value:Option[FloLit] = None) + extends FloBase[Flo](dir, Width(Flo.Width)) with Num[Flo] { type T = Flo; def floLitValue: Float = value.get.num def cloneTypeWidth(width: Width): this.type = cloneType override def fromBits(n: Bits): this.type = pushOp(DefPrim(cloneType, BitsToFlo, this.ref)).asInstanceOf[this.type] override def toBits: UInt = - pushOp(DefPrim(UInt(width=32), FloToBits, this.ref)) + pushOp(DefPrim(UInt(width=Flo.Width), FloToBits, this.ref)) private[Chisel] def toType = "Flo" def cloneType: this.type = new Flo(dir).asInstanceOf[this.type] @@ -106,6 +109,8 @@ class Flo(dir: Direction = NO_DIR, val value:Option[FloLit] = None) extends FloB import java.lang.Double.doubleToLongBits object Dbl { + val Width = 64 + def apply(x: Float): Dbl = Dbl(x.toDouble); def apply(x: Double): Dbl = new Dbl(NO_DIR, Some(DblLit(x))) def apply(dir: Direction = NO_DIR): Dbl = new Dbl(dir) @@ -141,14 +146,14 @@ object DblPrimOp { } import DblPrimOp._ -class Dbl(dir: Direction, val value: Option[DblLit] = None) extends FloBase[Dbl](dir, Width(64)) with Num[Dbl] { +class Dbl(dir: Direction, val value: Option[DblLit] = None) extends FloBase[Dbl](dir, Width(Dbl.Width)) with Num[Dbl] { type T = Dbl; def dblLitValue: Double = value.get.num def cloneTypeWidth(width: Width): this.type = cloneType override def fromBits(n: Bits): this.type = pushOp(DefPrim(cloneType, BitsToDbl, this.ref)).asInstanceOf[this.type] override def toBits: UInt = - pushOp(DefPrim(UInt(width=64), DblToBits, this.ref)) + pushOp(DefPrim(UInt(width=Dbl.Width), DblToBits, this.ref)) private[Chisel] def toType = "Dbl" def cloneType: this.type = new Dbl(dir).asInstanceOf[this.type] diff --git a/src/main/scala/Chisel/Utils.scala b/src/main/scala/Chisel/Utils.scala index 61bf28a8..a7a18193 100644 --- a/src/main/scala/Chisel/Utils.scala +++ b/src/main/scala/Chisel/Utils.scala @@ -9,14 +9,17 @@ import scala.reflect.runtime.universe._ import scala.reflect.macros.blackbox._ object Enum { + /** Returns a sequence of Bits subtypes with values from 0 until n. Helper method. */ + private def createValues[T <: Bits](nodeType: T, n: Int): Seq[T] = (0 until n).map(x => nodeType.fromInt(x)) + /** create n enum values of given type */ - def apply[T <: Bits](nodeType: T, n: Int): List[T] = Range(0, n).map(x => nodeType.fromInt(x)).toList + def apply[T <: Bits](nodeType: T, n: Int): List[T] = createValues(nodeType, n).toList /** create enum values of given type and names */ - def apply[T <: Bits](nodeType: T, l: Symbol *): Map[Symbol, T] = (l.toList zip (Range(0, l.length).map(x => nodeType.fromInt(x)))).toMap + def apply[T <: Bits](nodeType: T, l: Symbol *): Map[Symbol, T] = (l zip createValues(nodeType, l.length)).toMap /** create enum values of given type and names */ - def apply[T <: Bits](nodeType: T, l: List[Symbol]): Map[Symbol, T] = (l zip (Range(0, l.length).map(x => nodeType.fromInt(x)))).toMap + def apply[T <: Bits](nodeType: T, l: List[Symbol]): Map[Symbol, T] = (l zip createValues(nodeType, l.length)).toMap } /** Compute the log2 rounded up with min value of 1 */ @@ -156,9 +159,17 @@ class SwitchContext[T <: Bits](cond: T) { * It is equivalent to a [[Chisel.when$ when]] block comparing to the condition * Use outside of a switch statement is illegal */ object is { // Begin deprecation of non-type-parameterized is statements. - def apply(v: Iterable[Bits])(block: => Unit) { Builder.error("The 'is' keyword may not be used outside of a switch.") } - def apply(v: Bits)(block: => Unit) { Builder.error("The 'is' keyword may not be used outside of a switch.") } - def apply(v: Bits, vr: Bits*)(block: => Unit) { Builder.error("The 'is' keyword may not be used outside of a switch.") } + def apply(v: Iterable[Bits])(block: => Unit) { + Builder.error("The 'is' keyword may not be used outside of a switch.") + } + + def apply(v: Bits)(block: => Unit) { + Builder.error("The 'is' keyword may not be used outside of a switch.") + } + + def apply(v: Bits, vr: Bits*)(block: => Unit) { + Builder.error("The 'is' keyword may not be used outside of a switch.") + } } /** Conditional logic to form a switch block |
