Skip to content

Commit

Permalink
Specify desiredName as defname for extmodule (#3958)
Browse files Browse the repository at this point in the history
* Specify right convention for modules

* Specify `desiredName` as `defname` for `extmodule`
  • Loading branch information
SpriteOvO authored Mar 31, 2024
1 parent 9177535 commit 728eadc
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions panamaconverter/src/PanamaCIRCTConverter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -922,15 +922,16 @@ class PanamaCIRCTConverter(val circt: PanamaCIRCT, fos: Option[FirtoolOptions],
def visitDefBlackBox(defBlackBox: DefBlackBox): Unit = {
val ports = util.convert(defBlackBox.ports ++ defBlackBox.id.secretPorts, defBlackBox.topDir)
val nameAttr = circt.mlirStringAttrGet(defBlackBox.name)
val desiredNameAttr = circt.mlirStringAttrGet(defBlackBox.id.desiredName)

val builder = util
.OpBuilder("firrtl.extmodule", firCtx.circuitBlock, circt.unkLoc)
.withRegionNoBlock()
.withNamedAttr("sym_name", nameAttr)
.withNamedAttr("sym_visibility", circt.mlirStringAttrGet("private"))
.withNamedAttr("defname", nameAttr)
.withNamedAttr("defname", desiredNameAttr)
.withNamedAttr("parameters", circt.mlirArrayAttrGet(defBlackBox.params.map(p => util.convert(p._1, p._2)).toSeq))
.withNamedAttr("convention", circt.firrtlAttrGetConvention(FIRRTLConvention.Internal)) // TODO: handle it corretly
.withNamedAttr("convention", circt.firrtlAttrGetConvention(FIRRTLConvention.Scalarized)) // TODO: Make an option `scalarizeExtModules` for it
.withNamedAttr("annotations", circt.emptyArrayAttr)
val firModule = util.moduleBuilderInsertPorts(builder, ports).build()

Expand Down Expand Up @@ -966,7 +967,7 @@ class PanamaCIRCTConverter(val circt: PanamaCIRCT, fos: Option[FirtoolOptions],
.withRegion(Seq((ports.types, ports.locs)))
.withNamedAttr("sym_name", circt.mlirStringAttrGet(defModule.name))
.withNamedAttr("sym_visibility", circt.mlirStringAttrGet(if (isMainModule) "public" else "private"))
.withNamedAttr("convention", circt.firrtlAttrGetConvention(FIRRTLConvention.Internal)) // TODO: handle it corretly
.withNamedAttr("convention", circt.firrtlAttrGetConvention(if (isMainModule) FIRRTLConvention.Scalarized else FIRRTLConvention.Internal)) // TODO: Make an option `scalarizePublicModules` for it
.withNamedAttr("annotations", circt.emptyArrayAttr)
val firModule = util.moduleBuilderInsertPorts(builder, ports).build()

Expand Down

0 comments on commit 728eadc

Please sign in to comment.