diff options
Diffstat (limited to 'src/main')
| -rw-r--r-- | src/main/scala/chisel3/internal/firrtl/Emitter.scala | 24 | ||||
| -rw-r--r-- | src/main/scala/chisel3/package.scala | 24 |
2 files changed, 42 insertions, 6 deletions
diff --git a/src/main/scala/chisel3/internal/firrtl/Emitter.scala b/src/main/scala/chisel3/internal/firrtl/Emitter.scala index 3fb18893..b8651828 100644 --- a/src/main/scala/chisel3/internal/firrtl/Emitter.scala +++ b/src/main/scala/chisel3/internal/firrtl/Emitter.scala @@ -2,6 +2,7 @@ package chisel3.internal.firrtl import chisel3._ +import chisel3.experimental._ import chisel3.internal.sourceinfo.{NoSourceInfo, SourceLine} private[chisel3] object Emitter { @@ -42,6 +43,16 @@ private class Emitter(circuit: Circuit) { firrtlLine + e.sourceInfo.makeMessage(" " + _) } + private def emitParam(name: String, p: Param): String = { + val str = p match { + case IntParam(value) => value.toString + case DoubleParam(value) => value.toString + case StringParam(str) => "\"" + str + "\"" + case RawParam(str) => "'" + str + "'" + } + s"parameter $name = $str" + } + // Map of Module FIRRTL definition to FIRRTL name, if it has been emitted already. private val defnMap = collection.mutable.HashMap[(String, String), Component]() @@ -61,12 +72,13 @@ private class Emitter(circuit: Circuit) { body ++= newline + emitPort(p) body ++= newline - m.id match { - case _: BlackBox => - // TODO: BlackBoxes should be empty, but funkiness in Module() means - // it's not for now. Eventually, this should assert out. - case _: Module => for (cmd <- m.commands) { - body ++= newline + emit(cmd, m) + m match { + case bb: DefBlackBox => + // Firrtl extmodule can overrule name + body ++= newline + s"defname = ${bb.id.desiredName}" + body ++= newline + (bb.params map { case (n, p) => emitParam(n, p) } mkString newline) + case mod: DefModule => for (cmd <- mod.commands) { + body ++= newline + emit(cmd, mod) } } body ++= newline diff --git a/src/main/scala/chisel3/package.scala b/src/main/scala/chisel3/package.scala index e0364868..3cdda971 100644 --- a/src/main/scala/chisel3/package.scala +++ b/src/main/scala/chisel3/package.scala @@ -179,4 +179,28 @@ package object chisel3 { // scalastyle:ignore package.object.name } def getModulePorts(m: Module): Seq[Port] = m.getPorts def getFirrtlDirection(d: Data): Direction = chisel3.core.Data.getFirrtlDirection(d) + + /** Package for experimental features, which may have their API changed, be removed, etc. + * + * Because its contents won't necessarily have the same level of stability and support as + * non-experimental, you must explicitly import this package to use its contents. + */ + object experimental { + type Param = chisel3.core.Param + type IntParam = chisel3.core.IntParam + val IntParam = chisel3.core.IntParam + type DoubleParam = chisel3.core.DoubleParam + val DoubleParam = chisel3.core.DoubleParam + type StringParam = chisel3.core.StringParam + val StringParam = chisel3.core.StringParam + type RawParam = chisel3.core.RawParam + val RawParam = chisel3.core.RawParam + + // Implicit conversions for BlackBox Parameters + implicit def fromIntToIntParam(x: Int): IntParam = IntParam(BigInt(x)) + implicit def fromLongToIntParam(x: Long): IntParam = IntParam(BigInt(x)) + implicit def fromBigIntToIntParam(x: BigInt): IntParam = IntParam(x) + implicit def fromDoubleToDoubleParam(x: Double): DoubleParam = DoubleParam(x) + implicit def fromStringToStringParam(x: String): StringParam = StringParam(x) + } } |
