Skip to content

Commit

Permalink
Temporary fixup for prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
chenguokai committed Nov 16, 2020
1 parent 7436555 commit aad71c5
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 14 deletions.
8 changes: 4 additions & 4 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ addCompilerPlugin("org.scalamacros" % "paradise" % "2.1.0" cross CrossVersion.fu

// Provide a managed dependency on X if -DXVersion="" is supplied on the command line.
val defaultVersions = Seq(
"chisel-iotesters" -> "1.5.0-RC1",
"chiseltest" -> "0.3.0-RC1"
)
"chisel-iotesters" -> "1.4.1+",
"chiseltest" -> "0.2.1+"
)

libraryDependencies ++= defaultVersions.map { case (dep, ver) =>
"edu.berkeley.cs" %% dep % sys.props.getOrElse(dep + "Version", ver) }

scalacOptions ++= scalacOptionsVersion(scalaVersion.value)

javacOptions ++= javacOptionsVersion(scalaVersion.value)
javacOptions ++= javacOptionsVersion(scalaVersion.value)
2 changes: 1 addition & 1 deletion src/main/scala/Xim/AXI_Bridge.scala
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class AXI_Bridge(width: Int = 64) extends BlackBox with HasBlackBoxInline {
}))
setInline("AXI_Bridge.v",
s"""
module chenguokai_AXI_Bridge
module AXI_Bridge
(
input clock,
input reset,
Expand Down
18 changes: 9 additions & 9 deletions src/main/scala/Xim/AddModulePrefix.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package yourpackage
package Xim

import firrtl._
import firrtl.annotations.NoTargetAnnotation
Expand All @@ -8,34 +8,34 @@ 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
case ExtModule(info, name, ports, defname, params) =>
ExtModule(info, prefix+name, ports, defname, params)
}
}
val newCircuit = c.mapModule(onModule)
state.copy(newCircuit.copy(main = prefix + newCircuit.main))
}

}
1 change: 1 addition & 0 deletions src/test/scala/Xim/SoC_Main.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package Xim

import chisel3._
import firrtl.stage.RunFirrtlTransformAnnotation

object SoC_Main_Type_One extends App {
iotesters.Driver.execute(args, () => new SoC) {
Expand Down

0 comments on commit aad71c5

Please sign in to comment.