Skip to content

Commit

Permalink
[pyxsi] expose close_rtlsim() to exit cleanly
Browse files Browse the repository at this point in the history
  • Loading branch information
maltanar authored and auphelia committed Oct 11, 2024
1 parent c04a4a8 commit b266a8a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/finn/util/pyxsi_rpcclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,9 @@ def load_sim_obj(sim_out_dir, out_so_relative_path, tracefile=None, is_toplevel_
return handle


def close_sim(handle):
(_, _, _, proc) = handle
def close_rtlsim(handle):
(sim_id, rpc_proxy, _, proc) = handle
rpc_proxy.close_rtlsim(sim_id)
proc.terminate()


Expand Down
8 changes: 7 additions & 1 deletion src/finn/util/pyxsi_rpcserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def compile_sim_obj(top_module_name, source_list, sim_out_dir):
return ret


def load_sim_obj(sim_out_dir, out_so_relative_path, tracefile=None, is_toplevel_verilog=True):
def load_sim_obj(sim_out_dir, out_so_relative_path, tracefile, is_toplevel_verilog):
ret_sim_obj = pyxsi_utils.load_sim_obj(
sim_out_dir, out_so_relative_path, tracefile, is_toplevel_verilog
)
Expand Down Expand Up @@ -106,6 +106,11 @@ def toggle_pos_edge(sim_id, clk_name):
pyxsi_utils.toggle_pos_edge(sim, clk_name)


def close_rtlsim(sim_id):
sim = sim_id_to_obj[sim_id]
pyxsi_utils.close_rtlsim(sim)


# ask to create server on port 0 to find an available port
with SimpleXMLRPCServer(("localhost", 0), requestHandler=RequestHandler, allow_none=True) as server:
port = server.server_address[1]
Expand All @@ -119,5 +124,6 @@ def toggle_pos_edge(sim_id, clk_name):
server.register_function(toggle_clk)
server.register_function(toggle_neg_edge)
server.register_function(toggle_pos_edge)
server.register_function(close_rtlsim)
print(f"pyxsi RPC server is now running on {port}")
server.serve_forever()

0 comments on commit b266a8a

Please sign in to comment.