Skip to content

Commit

Permalink
Remove old files
Browse files Browse the repository at this point in the history
  • Loading branch information
chenguokai committed Nov 16, 2020
1 parent 6b8d9c4 commit 7436555
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions src/main/scala/Xim/AddModulePrefix.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package yourpackage

import firrtl._
import firrtl.annotations.NoTargetAnnotation
import firrtl.ir._
import firrtl.stage.TransformManager.TransformDependency

case class ModulePrefixAnnotation(prefix: String) extends NoTargetAnnotation

class AddModulePrefix extends Transform with DependencyAPIMigration {

override def prerequisites: Seq[TransformDependency] = firrtl.stage.Forms.ChirrtlForm

override protected def execute(state: CircuitState): CircuitState = {
val c = state.circuit

val prefix = state.annotations.collectFirst {
case ModulePrefixAnnotation(p) => p
}.get

def onStmt(s: Statement): Statement = s match {
case DefInstance(info, name, module) =>
DefInstance(info, name, prefix + module)
case other =>
other.mapStmt(onStmt)
}

def onModule(m: DefModule): DefModule = {
val newMod = m.mapStmt(onStmt)
newMod match {
case Module(info, name, ports, body) =>
Module(info, prefix + name, ports, body)
case other =>
other
}
}
val newCircuit = c.mapModule(onModule)
state.copy(newCircuit.copy(main = prefix + newCircuit.main))
}

}

0 comments on commit 7436555

Please sign in to comment.