summaryrefslogtreecommitdiff
path: root/chiselFrontend/src/main/scala/chisel3/core/BlackBox.scala
diff options
context:
space:
mode:
authorjackkoenig2016-09-22 22:38:33 -0700
committerjackkoenig2016-11-18 11:05:33 -0800
commit822160cc8e76e70643fb56707bb39f6f7526b6fd (patch)
tree50b9e132c6e7d2d5113195683ef3cc3fc5fc1113 /chiselFrontend/src/main/scala/chisel3/core/BlackBox.scala
parent6929ca0fc64b562f4852a49df617a1836e083563 (diff)
Add support for parameterized BlackBoxes
Also restrict black boxes to not allow hardware inside of them since it was being silently dropped anyway. Resolves #289
Diffstat (limited to 'chiselFrontend/src/main/scala/chisel3/core/BlackBox.scala')
-rw-r--r--chiselFrontend/src/main/scala/chisel3/core/BlackBox.scala18
1 files changed, 12 insertions, 6 deletions
diff --git a/chiselFrontend/src/main/scala/chisel3/core/BlackBox.scala b/chiselFrontend/src/main/scala/chisel3/core/BlackBox.scala
index 7fe429fa..85a57111 100644
--- a/chiselFrontend/src/main/scala/chisel3/core/BlackBox.scala
+++ b/chiselFrontend/src/main/scala/chisel3/core/BlackBox.scala
@@ -3,11 +3,20 @@
package chisel3.core
import chisel3.internal.Builder.pushCommand
-import chisel3.internal.firrtl.{ModuleIO, DefInvalid}
+import chisel3.internal.firrtl._
+import chisel3.internal.throwException
import chisel3.internal.sourceinfo.SourceInfo
// TODO: remove this once we have CompileOptions threaded through the macro system.
import chisel3.core.ExplicitCompileOptions.NotStrict
+/** Parameters for BlackBoxes */
+sealed abstract class Param
+case class IntParam(value: BigInt) extends Param
+case class DoubleParam(value: Double) extends Param
+case class StringParam(value: String) extends Param
+/** Unquoted String */
+case class RawParam(value: String) extends Param
+
/** Defines a black box, which is a module that can be referenced from within
* Chisel, but is not defined in the emitted Verilog. Useful for connecting
* to RTL modules defined outside Chisel.
@@ -16,12 +25,9 @@ import chisel3.core.ExplicitCompileOptions.NotStrict
* {{{
* ... to be written once a spec is finalized ...
* }}}
+ * @note The parameters API is experimental and may change
*/
-// REVIEW TODO: make Verilog parameters part of the constructor interface?
-abstract class BlackBox extends Module {
- // Don't bother taking override_clock|reset, clock/reset locked out anyway
- // TODO: actually implement this.
- def setVerilogParameters(s: String): Unit = {}
+abstract class BlackBox(val params: Map[String, Param] = Map.empty[String, Param]) extends Module {
// The body of a BlackBox is empty, the real logic happens in firrtl/Emitter.scala
// Bypass standard clock, reset, io port declaration by flattening io