aboutsummaryrefslogtreecommitdiff
path: root/src/main/scala/firrtl/passes/memlib/InferReadWrite.scala
diff options
context:
space:
mode:
authorSchuyler Eldridge2019-04-22 21:20:08 -0400
committerSchuyler Eldridge2019-04-25 16:24:15 -0400
commitef8f06f23b9ee6cf86de2450752dfd0fcd32da80 (patch)
tree79e2e8c5753903ca6d14e9b952c26a07442bd980 /src/main/scala/firrtl/passes/memlib/InferReadWrite.scala
parent47fe781c4ace38dff7f31da7e78f772e131d689e (diff)
Add ShellOption, DeletedWrapper
Abstracts away option writing such that users no longer have to understand scopt semantics. This adds a ShellOption class and a HasShellOptions trait for something which provides one or more ShellOptions. This refactors the FIRRTL codebase to use this style of option specification. Adds and uses DeletedWrapper to automatically generate DeletedAnnotations. Signed-off-by: Schuyler Eldridge <schuyler.eldridge@ibm.com>
Diffstat (limited to 'src/main/scala/firrtl/passes/memlib/InferReadWrite.scala')
-rw-r--r--src/main/scala/firrtl/passes/memlib/InferReadWrite.scala17
1 files changed, 8 insertions, 9 deletions
diff --git a/src/main/scala/firrtl/passes/memlib/InferReadWrite.scala b/src/main/scala/firrtl/passes/memlib/InferReadWrite.scala
index f524d60b..0602e4f1 100644
--- a/src/main/scala/firrtl/passes/memlib/InferReadWrite.scala
+++ b/src/main/scala/firrtl/passes/memlib/InferReadWrite.scala
@@ -8,7 +8,7 @@ import firrtl.ir._
import firrtl.Mappers._
import firrtl.PrimOps._
import firrtl.Utils.{one, zero, BoolType}
-import firrtl.options.HasScoptOptions
+import firrtl.options.{HasShellOptions, ShellOption}
import MemPortUtils.memPortField
import firrtl.passes.memlib.AnalysisUtils.{Connects, getConnects, getOrigin}
import WrappedExpression.weq
@@ -147,17 +147,16 @@ object InferReadWritePass extends Pass {
// Transform input: Middle Firrtl. Called after "HighFirrtlToMidleFirrtl"
// To use this transform, circuit name should be annotated with its TransId.
-class InferReadWrite extends Transform with SeqTransformBased with HasScoptOptions {
+class InferReadWrite extends Transform with SeqTransformBased with HasShellOptions {
def inputForm = MidForm
def outputForm = MidForm
- def addOptions(parser: OptionParser[AnnotationSeq]): Unit = parser
- .opt[Unit]("infer-rw")
- .abbr("firw")
- .valueName ("<circuit>")
- .action( (_, c) => Seq(InferReadWriteAnnotation, RunFirrtlTransformAnnotation(new InferReadWrite)) ++ c )
- .maxOccurs(1)
- .text("Enable readwrite port inference for the target circuit")
+ val options = Seq(
+ new ShellOption[Unit](
+ longOption = "infer-rw",
+ toAnnotationSeq = (_: Unit) => Seq(InferReadWriteAnnotation, RunFirrtlTransformAnnotation(new InferReadWrite)),
+ helpText = "Enable read/write port inference for memories",
+ shortOption = Some("firw") ) )
def transforms = Seq(
InferReadWritePass,