HAL
control.py
Go to the documentation of this file.
1 #!/usr/bin/python3
2 
3 import os
4 import argparse
5 import getpass
6 import sys
7 
8 from configuration import *
9 from utils import *
10 
11 
12 
13 parser = argparse.ArgumentParser(description='Call the HAL dataflow plugin.')
14 parser.add_argument('design', metavar='design', type=str, help='name of the design')
15 parser.add_argument('synthesizer', metavar='synthesizer', type=str, help='name of the synthesizer')
16 parser.add_argument('--rebuild', action='store_true', help='if set will clear build folder and rebuild cmake')
17 parser.add_argument('--rebuild-debug', action='store_true', help='if set will clear build folder and rebuild cmake with debug and execute with gdb')
18 parser.add_argument('--debug', action='store_true', help='if set will execute with gdb')
19 parser.add_argument('--sizes', metavar='sizes', type=str, help='define allowed sizes')
20 parser.add_argument('--hal-file', action='store_true', help='use the .hal file instead of the netlist')
21 parser.add_argument('--create-hal-file', action='store_true', help='run hal without the dataflow plugin to create a .hal file for the netlist')
22 
23 
27 
28 def expect(condition, error_message):
29  if not condition:
30  print(error_message)
31  exit(1)
32 
33 args = parser.parse_args()
34 
35 synthesizers = set(x for x in netlists)
36 designs = set(x for y in netlists for x in netlists[y])
37 
38 expect(os.path.isdir(path_to_core_collection), "core collection needs to be placed in: " + path_to_core_collection)
39 expect(os.path.isdir(path_to_core_collection), "hal needs to be placed in: " + path_to_core_collection)
40 expect(args.design in designs, "available designs: " +", ".join(designs))
41 expect(args.synthesizer in synthesizers, "available synthesizers: " +", ".join(synthesizers))
42 
43 
47 
48 if args.rebuild or args.rebuild_debug:
49  print("will recreate cmake")
50  #delete everything in build folder
51  os.system('rm -rf ' + path_to_hal_build + "/*")
52  os.chdir(path_to_hal_build)
53  if args.rebuild:
54  os.system("cmake ../ -GNinja -DPL_DATAFLOW=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo -DWITH_GUI=OFF")
55  else:
56  os.system("cmake ../ -GNinja -DPL_DATAFLOW=ON -DCMAKE_BUILD_TYPE=Debug -DWITH_GUI=OFF")
57 
58 expect(os.path.isdir(path_to_hal_build), "path to hal build '{}' does not exist".format(path_to_hal_build))
59 
60 os.chdir(path_to_hal_build)
61 
62 return_ninja = os.system('ninja')
63 expect(return_ninja == 0, "error in build: return code: " + str(return_ninja))
64 
65 
69 
70 expect(os.path.isfile(path_to_hal_bin), "could not find HAL binary in: " + path_to_hal_bin)
71 
72 input_design = path_to_core_collection + "/" + netlists[args.synthesizer][args.design]
73 
74 
75 if args.create_hal_file:
76  command = "{} -i {} --gate-library {}.lib".format(path_to_hal_bin, input_design, get_gate_library(args.design, args.synthesizer))
77  os.system(command)
78 else:
79  if args.hal_file:
80  input_design = input_design[:input_design.rfind(".")] + ".hal"
81 
82  expect(os.path.isfile(input_design), "could not find design: " + input_design)
83 
84  command = "{} -i {} --dataflow --path {} --gate-library {}.lib".format(path_to_hal_bin, input_design, path_dataflow_out, get_gate_library(args.design, args.synthesizer))
85 
86  if args.sizes != None:
87  command += " --sizes {}".format(args.sizes)
88 
89  print(command)
90 
91  if args.rebuild_debug or args.debug:
92  os.system("gdb --args " + command)
93  else:
94  os.system(command)
def expect(condition, error_message)
-— ARG CHECKS -—
Definition: control.py:28
GateLibrary * get_gate_library(const std::string &file_path)
CORE_API std::string join(const std::string &joiner, const Iterator &begin, const Iterator &end, const Transform &transform)
Definition: utils.h:412