| 22 | |
| 23 | |
| 24 | class Options(object): |
| 25 | def __init__(self): |
| 26 | self.DATA_SIZE = 1024 |
| 27 | self.sharedLibrary = None |
| 28 | self.bitstreamFile = None |
| 29 | self.halLogFile = None |
| 30 | self.alignment = 4096 |
| 31 | self.option_index = 0 |
| 32 | self.index = None |
| 33 | self.cu_index = 0 |
| 34 | self.s_flag = False |
| 35 | self.verbose = False |
| 36 | self.handle = None |
| 37 | self.xcl_handle = None |
| 38 | self.first_mem = -1 |
| 39 | self.cu_base_addr = -1 |
| 40 | self.xuuid = uuid.uuid4() |
| 41 | self.kernels = [] |
| 42 | |
| 43 | def getOptions(self, argv, b_file): |
| 44 | try: |
| 45 | opts, args = getopt.getopt(argv[1:], "k:l:a:c:d:svhe", ["bitstream=", "hal_logfile=", "alignment=", |
| 46 | "cu_index=", "device=", "supported", "verbose", "help", "ert"]) |
| 47 | except getopt.GetoptError: |
| 48 | print(self.printHelp()) |
| 49 | sys.exit(2) |
| 50 | |
| 51 | for o, arg in opts: |
| 52 | if o in ("--bitstream", "-k"): |
| 53 | self.bitstreamFile = arg |
| 54 | elif o in ("--hal_logfile", "-l"): |
| 55 | self.halLogFile = arg |
| 56 | elif o in ("--alignment", "-a"): |
| 57 | print("-a/--alignment switch is not supported") |
| 58 | elif o in ("--cu_index", "-c"): |
| 59 | self.cu_index = int(arg) |
| 60 | elif o in ("--supported", "-s"): |
| 61 | self.s_flag = True |
| 62 | elif o in ("--device", "-d"): |
| 63 | self.index = arg |
| 64 | elif o in ("--help", "-h"): |
| 65 | print(self.printHelp()) |
| 66 | elif o == "-v": |
| 67 | self.verbose = True |
| 68 | elif o in ("-e", "--ert"): |
| 69 | print("-e/--ert switch is not supported") |
| 70 | else: |
| 71 | assert False, "unhandled option" |
| 72 | |
| 73 | if self.bitstreamFile is None: |
| 74 | raise RuntimeError("No bitstream specified") |
| 75 | |
| 76 | if self.halLogFile: |
| 77 | print("Log files are not supported on command line, Please use xrt.ini to specify logging configuration") |
| 78 | print("Host buffer alignment " + str(self.alignment) + " bytes") |
| 79 | print("Compiled kernel = " + self.bitstreamFile) |
| 80 | |
| 81 | if(os.path.isfile(self.bitstreamFile)): |