diff options
author | Miodrag Milanovic <mmicko@gmail.com> | 2018-07-03 20:14:49 +0200 |
---|---|---|
committer | Miodrag Milanovic <mmicko@gmail.com> | 2018-07-03 20:14:49 +0200 |
commit | ec9a9de6d3db22de27b40d69d2acbdd4f29c3af3 (patch) | |
tree | 652dd8181fb4f1b124d14c42b8051dd79d1c20be /ice40 | |
parent | 5ca76461da3498b16f871f8ee50794fe67ce8394 (diff) | |
download | nextpnr-ec9a9de6d3db22de27b40d69d2acbdd4f29c3af3.tar.gz nextpnr-ec9a9de6d3db22de27b40d69d2acbdd4f29c3af3.tar.bz2 nextpnr-ec9a9de6d3db22de27b40d69d2acbdd4f29c3af3.zip |
Make chibdb.py able to generate pure binary output
Diffstat (limited to 'ice40')
-rw-r--r-- | ice40/chipdb.py | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/ice40/chipdb.py b/ice40/chipdb.py index 623cdfce..8a1c9ce2 100644 --- a/ice40/chipdb.py +++ b/ice40/chipdb.py @@ -3,6 +3,14 @@ import sys import re import textwrap +import argparse + +parser = argparse.ArgumentParser(description="convert ICE40 chip database") +group = parser.add_mutually_exclusive_group() +group.add_argument("-b", "--binary", action="store_true") +group.add_argument("-c", "--c_file", action="store_true") +parser.add_argument("filename", type=str, help="chipdb input filename") +args = parser.parse_args() endianness = "le" nodebug = True @@ -212,7 +220,7 @@ def init_tiletypes(device): tile_sizes = {i: (0, 0) for i in range(num_tile_types)} tile_bits = [[] for _ in range(num_tile_types)] -with open(sys.argv[1], "r") as f: +with open(args.filename, "r") as f: mode = None for line in f: @@ -855,6 +863,11 @@ class BinaryBlobAssembler: column = 0 print("\";", file=f) + def write_binary(self, f): + assert self.finalized + assert self.data[len(self.data)-1] == 0 + f.buffer.write(self.data) + bba = BinaryBlobAssembler("chipdb_blob_%s" % dev_name, endianness) bba.r("chip_info_%s" % dev_name, "chip_info") @@ -1131,12 +1144,21 @@ bba.r("package_info_%s" % dev_name, "packages_data") bba.finalize() -print('#include "nextpnr.h"') -print('NEXTPNR_NAMESPACE_BEGIN') +if args.c_file: + print('#include "nextpnr.h"') + print('NEXTPNR_NAMESPACE_BEGIN') + + +if args.binary: + bba.write_binary(sys.stdout) + +if args.c_file: + bba.write_string_c(sys.stdout) -bba.write_string_c(sys.stdout) # bba.write_uint64_c(sys.stdout) # bba.write_compact_c(sys.stdout, "uint8_t") # bba.write_verbose_c(sys.stdout, "uint8_t") -print('NEXTPNR_NAMESPACE_END') +if args.c_file: + print('NEXTPNR_NAMESPACE_END') + |