Skip to content

Commit

Permalink
Merge be24833 into e115690
Browse files Browse the repository at this point in the history
  • Loading branch information
Kuree committed May 17, 2019
2 parents e115690 + be24833 commit d738c47
Showing 1 changed file with 20 additions and 9 deletions.
29 changes: 20 additions & 9 deletions fault/system_verilog_target.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,13 @@
endmodule
"""

ncsim_cmd_string = """\
database -open -vcd vcddb -into verilog.vcd -default -timescale ps
probe -create -all -vcd -depth all
run 10000ns
quit
"""


class SystemVerilogTarget(VerilogTarget):
def __init__(self, circuit, circuit_name=None, directory="build/",
skip_compile=False, magma_output="coreir-verilog",
magma_opts={}, include_verilog_libraries=[], simulator=None,
timescale="1ns/1ns", clock_step_delay=5):
timescale="1ns/1ns", clock_step_delay=5, num_cycle=10000,
dump_vcd=True, no_warning=False):
"""
circuit: a magma circuit
Expand Down Expand Up @@ -78,6 +72,9 @@ def __init__(self, circuit, circuit_name=None, directory="build/",
self.simulator = simulator
self.timescale = timescale
self.clock_step_delay = clock_step_delay
self.num_cycle = num_cycle
self.dump_vcd = dump_vcd
self.no_warning = no_warning
self.declarations = []

def make_name(self, port):
Expand Down Expand Up @@ -272,10 +269,24 @@ def run(self, actions):
self.include_verilog_libraries)
cmd_file = Path(f"{self.circuit_name}_cmd.tcl")
if self.simulator == "ncsim":
if self.dump_vcd:
vcd_command = """
database -open -vcd vcddb -into verilog.vcd -default -timescale ps
probe -create -all -vcd -depth all"""
else:
vcd_command = ""
ncsim_cmd_string = f"""\
{vcd_command}
run {self.num_cycle}ns
quit"""
if self.no_warning:
warning = "-neverwarn"
else:
warning = ""
with open(self.directory / cmd_file, "w") as f:
f.write(ncsim_cmd_string)
cmd = f"""\
irun -top {self.circuit_name}_tb -timescale {self.timescale} -access +rwc -notimingchecks -input {cmd_file} {test_bench_file} {self.verilog_file} {verilog_libraries}
irun -top {self.circuit_name}_tb -timescale {self.timescale} -access +rwc -notimingchecks {warning} -input {cmd_file} {test_bench_file} {self.verilog_file} {verilog_libraries}
""" # nopep8
elif self.simulator == "vcs":
cmd = f"""\
Expand Down

0 comments on commit d738c47

Please sign in to comment.