Skip to content
Snippets Groups Projects
Commit 0899ce44 authored by Yaman Umuroglu's avatar Yaman Umuroglu
Browse files

[rtlsim] no autoeval for IP-stitched rtlsim

parent 36d406c3
No related branches found
No related tags found
No related merge requests found
...@@ -86,9 +86,7 @@ def rtlsim_exec(model, execution_context): ...@@ -86,9 +86,7 @@ def rtlsim_exec(model, execution_context):
sim = pyverilate_stitched_ip(model) sim = pyverilate_stitched_ip(model)
model.set_metadata_prop("rtlsim_so", sim.lib._name) model.set_metadata_prop("rtlsim_so", sim.lib._name)
else: else:
sim = PyVerilator(rtlsim_so) sim = PyVerilator(rtlsim_so, auto_eval=False)
_reset_rtlsim(sim)
_toggle_clk(sim)
ret = _run_rtlsim(sim, packed_input, num_out_values, trace_file) ret = _run_rtlsim(sim, packed_input, num_out_values, trace_file)
packed_output = ret[0] packed_output = ret[0]
model.set_metadata_prop("sim_cycles", str(ret[1])) model.set_metadata_prop("sim_cycles", str(ret[1]))
...@@ -104,18 +102,22 @@ def _reset_rtlsim(sim): ...@@ -104,18 +102,22 @@ def _reset_rtlsim(sim):
"""Sets reset input in pyverilator to zero, toggles the clock and set it """Sets reset input in pyverilator to zero, toggles the clock and set it
back to one""" back to one"""
sim.io.ap_rst_n_0 = 0 sim.io.ap_rst_n_0 = 0
sim.io.ap_clk_0 = 1 _toggle_clk(sim)
sim.io.ap_clk_0 = 0 _toggle_clk(sim)
sim.io.ap_rst_n_0 = 1 sim.io.ap_rst_n_0 = 1
_toggle_clk(sim)
_toggle_clk(sim)
def _toggle_clk(sim): def _toggle_clk(sim):
"""Toggles the clock input in pyverilator once.""" """Toggles the clock input in pyverilator once."""
sim.io.ap_clk_0 = 1
sim.io.ap_clk_0 = 0 sim.io.ap_clk_0 = 0
sim.eval()
sim.io.ap_clk_0 = 1
sim.eval()
def _run_rtlsim(sim, inp, num_out_values, trace_file=None): def _run_rtlsim(sim, inp, num_out_values, trace_file=None, reset=True):
"""Runs the pyverilator simulation by passing the input values to the simulation, """Runs the pyverilator simulation by passing the input values to the simulation,
toggle the clock and observing the execution time. Argument num_out_values contains toggle the clock and observing the execution time. Argument num_out_values contains
the number of expected output values, so the simulation is closed after all the number of expected output values, so the simulation is closed after all
...@@ -140,6 +142,8 @@ def _run_rtlsim(sim, inp, num_out_values, trace_file=None): ...@@ -140,6 +142,8 @@ def _run_rtlsim(sim, inp, num_out_values, trace_file=None):
if trace_file is not None: if trace_file is not None:
sim.start_vcd_trace(trace_file) sim.start_vcd_trace(trace_file)
if reset:
_reset_rtlsim(sim)
while not (output_observed): while not (output_observed):
sim.io.in0_V_V_0_tvalid = 1 if len(inputs) > 0 else 0 sim.io.in0_V_V_0_tvalid = 1 if len(inputs) > 0 else 0
...@@ -148,8 +152,7 @@ def _run_rtlsim(sim, inp, num_out_values, trace_file=None): ...@@ -148,8 +152,7 @@ def _run_rtlsim(sim, inp, num_out_values, trace_file=None):
inputs = inputs[1:] inputs = inputs[1:]
if sim.io.out_r_0_tvalid == 1 and sim.io.out_r_0_tready == 1: if sim.io.out_r_0_tvalid == 1 and sim.io.out_r_0_tready == 1:
outputs = outputs + [sim.io.out_r_0_tdata] outputs = outputs + [sim.io.out_r_0_tdata]
sim.io.ap_clk_0 = 1 _toggle_clk(sim)
sim.io.ap_clk_0 = 0
observation_count = observation_count + 1 observation_count = observation_count + 1
no_change_count = no_change_count + 1 no_change_count = no_change_count + 1
......
...@@ -104,6 +104,7 @@ def pyverilate_stitched_ip(model): ...@@ -104,6 +104,7 @@ def pyverilate_stitched_ip(model):
build_dir=build_dir, build_dir=build_dir,
trace_depth=get_rtlsim_trace_depth(), trace_depth=get_rtlsim_trace_depth(),
top_module_name=top_module_name, top_module_name=top_module_name,
auto_eval=False,
) )
return sim return sim
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment