plusarg_reader : Add the ability to add a documentation string.
This commit is contained in:
parent
274d908d98
commit
8440c4b1c4
@ -3,19 +3,23 @@
|
|||||||
package util
|
package util
|
||||||
import Chisel._
|
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),
|
"FORMAT" -> chisel3.core.StringParam(format),
|
||||||
"DEFAULT" -> chisel3.core.IntParam(default))) {
|
"DEFAULT" -> chisel3.core.IntParam(default))) {
|
||||||
val io = new Bundle {
|
val io = new Bundle {
|
||||||
val out = UInt(OUTPUT, width = 32)
|
val out = UInt(OUTPUT, width = 32)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
object PlusArg
|
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
|
// 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.
|
// initial block and thus accessing it from another initial is racey.
|
||||||
def apply(name: String, default: Int = 0): UInt =
|
// Add a docstring to document the arg, which can be dumped in elaboration
|
||||||
Module(new plusarg_reader(name + "=%d", default)).io.out
|
// pass.
|
||||||
|
|
||||||
|
def apply(name: String, default: Int = 0, docstring: String = ""): UInt =
|
||||||
|
Module(new plusarg_reader(name + "=%d", default, docstring)).io.out
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user