From 8440c4b1c44e38de5b766c4e9f44d5b891a5cf67 Mon Sep 17 00:00:00 2001 From: Megan Wachs Date: Mon, 5 Jun 2017 16:16:52 -0700 Subject: [PATCH 1/2] plusarg_reader : Add the ability to add a documentation string. --- src/main/scala/util/PlusArg.scala | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main/scala/util/PlusArg.scala b/src/main/scala/util/PlusArg.scala index d902558d..288362f4 100644 --- a/src/main/scala/util/PlusArg.scala +++ b/src/main/scala/util/PlusArg.scala @@ -3,19 +3,23 @@ package util import Chisel._ -class plusarg_reader(format: String, default: Int) extends BlackBox(Map( +class plusarg_reader(val format: String, val default: Int, val docstring: String) extends BlackBox(Map( "FORMAT" -> chisel3.core.StringParam(format), "DEFAULT" -> chisel3.core.IntParam(default))) { val io = new Bundle { val out = UInt(OUTPUT, width = 32) } + } object PlusArg { - // PlusArg("foo") will return 42 if the simulation is run with +foo=42 + // PlusArg("foo") will return 42.U if the simulation is run with +foo=42 // Do not use this as an initial register value. The value is set in an // initial block and thus accessing it from another initial is racey. - def apply(name: String, default: Int = 0): UInt = - Module(new plusarg_reader(name + "=%d", default)).io.out + // Add a docstring to document the arg, which can be dumped in elaboration + // pass. + + def apply(name: String, default: Int = 0, docstring: String = ""): UInt = + Module(new plusarg_reader(name + "=%d", default, docstring)).io.out } From 7afd5e60704daaa13402a5f2eb53e493bc0a0a3b Mon Sep 17 00:00:00 2001 From: Megan Wachs Date: Mon, 5 Jun 2017 16:18:57 -0700 Subject: [PATCH 2/2] remove unnecessary whitespace. Fix grammar. --- src/main/scala/util/PlusArg.scala | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/scala/util/PlusArg.scala b/src/main/scala/util/PlusArg.scala index 288362f4..fc74de73 100644 --- a/src/main/scala/util/PlusArg.scala +++ b/src/main/scala/util/PlusArg.scala @@ -9,7 +9,6 @@ class plusarg_reader(val format: String, val default: Int, val docstring: String val io = new Bundle { val out = UInt(OUTPUT, width = 32) } - } object PlusArg @@ -17,7 +16,7 @@ object PlusArg // PlusArg("foo") will return 42.U if the simulation is run with +foo=42 // Do not use this as an initial register value. The value is set in an // initial block and thus accessing it from another initial is racey. - // Add a docstring to document the arg, which can be dumped in elaboration + // Add a docstring to document the arg, which can be dumped in an elaboration // pass. def apply(name: String, default: Int = 0, docstring: String = ""): UInt =