HAL
test_plugin.py
Go to the documentation of this file.
1 #!/usr/bin/env python3
2 import sys, os
3 
4 #some necessary configuration:
5 base_path = "/home/simon/projects/hal/"
6 
7 sys.path.append(base_path + "build/lib/") #this is where your hal python lib is located
8 os.environ["HAL_BASE_PATH"] = base_path + "build" # hal base path
9 import hal_py
10 
11 #initialize HAL
12 hal_py.plugin_manager.load_all_plugins()
13 
14 #read netlist
15 
16 netlist = hal_py.NetlistFactory.load_netlist(base_path + "examples/fsm/fsm.v", base_path + "examples/fsm/example_library.hgl")
17 
18 from hal_plugins import solve_fsm
19 
20 pl_fsm = hal_py.plugin_manager.get_plugin_instance("solve_fsm")
21 
22 # UPDATE THE MODULE IDS OR CREATE YOUR OWN LIST OF GATES
23 fsm_mod = netlist.get_module_by_id(1)
24 
25 transition_gates = fsm_mod.get_gates(lambda g : g.type.has_property(hal_py.GateTypeProperty.combinational))
26 state_gates = fsm_mod.get_gates(lambda g : g.type.has_property(hal_py.GateTypeProperty.sequential))
27 
28 initial_state = {}
29 graph_path = base_path + "examples/fsm/graph.dot"
30 timeout = 600000
31 
32 g = pl_fsm.solve_fsm(netlist, state_gates, transition_gates, initial_state, graph_path, timeout)
33 
34 #unload everything hal related
35 hal_py.plugin_manager.unload_all_plugins()