1
0
Fork 0

Plusargs -- tilelink timeout detection from the command line (#752)

* util: PlusArg gives Chisel access to the command-line

* tilelink2: add a progress watchdog to Monitors
This commit is contained in:
Wesley W. Terpstra 2017-05-18 22:49:59 -07:00 committed by GitHub
parent 20704b1454
commit 7f1d3c445f
5 changed files with 52 additions and 0 deletions

View File

@ -155,6 +155,7 @@ done_processing:
srand48(random_seed);
Verilated::randReset(2);
Verilated::commandArgs(argc, argv);
TEST_HARNESS *tile = new TEST_HARNESS;
#if VM_TRACE

View File

@ -435,6 +435,13 @@ class TLMonitor(args: TLMonitorArgs) extends TLMonitorBase(args)
}
inflight := (inflight | a_set) & ~d_clr
val watchdog = RegInit(UInt(0, width = 32))
val limit = util.PlusArg("tilelink_timeout")
assert (!inflight.orR || limit === UInt(0) || watchdog < limit, "TileLink timeout expired" + extra)
watchdog := watchdog + UInt(1)
when (bundle.a.fire() || bundle.d.fire()) { watchdog := UInt(0) }
}
def legalizeDESink(bundle: TLBundleSnoop, edge: TLEdge)(implicit sourceInfo: SourceInfo) {

View File

@ -0,0 +1,21 @@
// See LICENSE.SiFive for license details.
package util
import Chisel._
class plusarg_reader(format: String, default: Int) 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
// 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
}

View File

@ -6,6 +6,7 @@
bb_vsrcs = \
$(base_dir)/vsrc/jtag_vpi.v \
$(base_dir)/vsrc/plusarg_reader.v \
$(base_dir)/vsrc/ClockDivider2.v \
$(base_dir)/vsrc/ClockDivider3.v \
$(base_dir)/vsrc/AsyncResetReg.v \

22
vsrc/plusarg_reader.v Normal file
View File

@ -0,0 +1,22 @@
// See LICENSE.SiFive for license details.
// No default parameter values are intended, nor does IEEE 1800-2012 require them (clause A.2.4 param_assignment),
// but Incisive demands them. These default values should never be used.
module plusarg_reader #(string FORMAT="borked", int DEFAULT=0) (
output [31:0] out
);
reg [31:0] myplus;
assign out = myplus;
initial begin
myplus = DEFAULT;
`ifndef SYNTHESIS
`ifndef verilator
// Work-around for https://www.veripool.org/issues/1165
if (!$value$plusargs(FORMAT, myplus)) myplus = DEFAULT;
`endif
`endif
end
endmodule