-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Restoring staged generator PRs (Reverting #2329)
This reverts commit e170f8f.
- Loading branch information
1 parent
f215f01
commit fa64568
Showing
26 changed files
with
698 additions
and
299 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// See LICENSE.SiFive for license details. | ||
|
||
package freechips.rocketchip.stage | ||
|
||
import chisel3.experimental.BaseModule | ||
import firrtl.annotations.{Annotation, NoTargetAnnotation} | ||
import firrtl.options.{HasShellOptions, ShellOption, Unserializable} | ||
|
||
sealed trait RocketChipOption extends Unserializable { this: Annotation => } | ||
|
||
/* required options */ | ||
|
||
/** Path to top module class */ | ||
case class TopModuleAnnotation(clazz: Class[_ <: Any]) extends NoTargetAnnotation with RocketChipOption | ||
private[stage] object TopModuleAnnotation extends HasShellOptions { | ||
override val options = Seq( | ||
new ShellOption[String]( | ||
longOption = "top-module", | ||
toAnnotationSeq = a => Seq(TopModuleAnnotation(Class.forName(a).asInstanceOf[Class[_ <: BaseModule]])), | ||
helpText = "<top module>", | ||
shortOption = Some("T") | ||
) | ||
) | ||
} | ||
|
||
/** Paths to config classes */ | ||
case class ConfigsAnnotation(configNames: Seq[String]) extends NoTargetAnnotation with RocketChipOption | ||
private[stage] object ConfigsAnnotation extends HasShellOptions { | ||
override val options = Seq( | ||
new ShellOption[Seq[String]]( | ||
longOption = "configs", | ||
toAnnotationSeq = a => Seq(ConfigsAnnotation(a)), | ||
helpText = "<comma-delimited configs>", | ||
shortOption = Some("C") | ||
) | ||
) | ||
} | ||
|
||
/* optional options */ | ||
|
||
/** Optional base name for generated files' filenames */ | ||
case class OutputBaseNameAnnotation(outputBaseName: String) extends NoTargetAnnotation with RocketChipOption | ||
private[stage] object OutputBaseNameAnnotation extends HasShellOptions { | ||
override val options = Seq( | ||
new ShellOption[String]( | ||
longOption = "name", | ||
toAnnotationSeq = a => Seq(OutputBaseNameAnnotation(a)), | ||
helpText = "<base name of output files>", | ||
shortOption = Some("n") | ||
) | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// See LICENSE.SiFive for license details. | ||
|
||
package freechips.rocketchip.stage | ||
|
||
import firrtl.options.Shell | ||
|
||
trait RocketChipCli { this: Shell => | ||
|
||
parser.note("Rocket Chip Compiler Options") | ||
Seq( | ||
TopModuleAnnotation, | ||
ConfigsAnnotation, | ||
OutputBaseNameAnnotation, | ||
) | ||
.foreach(_.addOptions(parser)) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// See LICENSE.SiFive for license details. | ||
|
||
package freechips.rocketchip.stage | ||
|
||
class RocketChipOptions private[stage] ( | ||
val topModule: Option[Class[_ <: Any]] = None, | ||
val configNames: Option[Seq[String]] = None, | ||
val outputBaseName: Option[String] = None) { | ||
|
||
private[stage] def copy( | ||
topModule: Option[Class[_ <: Any]] = topModule, | ||
configNames: Option[Seq[String]] = configNames, | ||
outputBaseName: Option[String] = outputBaseName, | ||
): RocketChipOptions = { | ||
|
||
new RocketChipOptions( | ||
topModule=topModule, | ||
configNames=configNames, | ||
outputBaseName=outputBaseName, | ||
) | ||
} | ||
|
||
lazy val topPackage: Option[String] = topModule match { | ||
case Some(a) => Some(a.getPackage.getName) | ||
case _ => None | ||
} | ||
|
||
lazy val configClass: Option[String] = configNames match { | ||
case Some(names) => | ||
val classNames = names.map{ n => n.split('.').last } | ||
Some(classNames.mkString("_")) | ||
case _ => None | ||
} | ||
|
||
lazy val longName: Option[String] = outputBaseName match { | ||
case Some(name) => Some(name) | ||
case _ => | ||
if (!topPackage.isEmpty && !configClass.isEmpty) Some(s"${topPackage.get}.${configClass.get}") else None | ||
} | ||
} | ||
|
Oops, something went wrong.