diff options
-rwxr-xr-x | host/python/uhd/imgbuilder/image_builder.py | 18 | ||||
-rw-r--r-- | host/python/uhd/imgbuilder/templates/rfnoc_image_core.v.mako | 8 | ||||
-rwxr-xr-x | host/utils/rfnoc_image_builder.py | 16 |
3 files changed, 29 insertions, 13 deletions
diff --git a/host/python/uhd/imgbuilder/image_builder.py b/host/python/uhd/imgbuilder/image_builder.py index 1276ab693..84fc79798 100755 --- a/host/python/uhd/imgbuilder/image_builder.py +++ b/host/python/uhd/imgbuilder/image_builder.py @@ -829,31 +829,31 @@ def get_core_config_path(config_path): """ return os.path.join(config_path, RFNOC_CORE_DIR) -def generate_image_core_path(output_path, device, source): +def generate_image_core_path(output_path, name, source): """ Creates the path where the image core file gets to be stored. output_path: If not None, this is returned - device: Device type string, used to generate default file name + name: Device name string, used to generate default file name source: Otherwise, this path is returned, combined with a default file name """ if output_path is not None: return os.path.splitext(output_path)[0] + '.v' source = os.path.split(os.path.abspath(os.path.normpath(source)))[0] - return os.path.join(source, "{}_rfnoc_image_core.v".format(device)) + return os.path.join(source, "{}_rfnoc_image_core.v".format(name)) -def generate_image_core_header_path(output_path, device, source): +def generate_image_core_header_path(output_path, name, source): """ Creates the path where the image core header file will be stored. output_path: If not None, this is returned - device: Device type string, used to generate default file name + name: Device name string, used to generate default file name source: Otherwise, this path is returned, combined with a default file name """ if output_path is not None: return os.path.splitext(output_path)[0] + '.vh' source = os.path.split(os.path.abspath(os.path.normpath(source)))[0] - return os.path.join(source, "{}_rfnoc_image_core.vh".format(device)) + return os.path.join(source, "{}_rfnoc_image_core.vh".format(name)) def generate_edge_file_path(output_path, device, source): """ @@ -889,13 +889,13 @@ def build_image(config, fpga_path, config_path, device, **args): logging.info("Selected device %s", device) image_core_path = \ generate_image_core_path( - args.get('output_path'), device, args.get('source')) + args.get('output_path'), args.get('image_core_name'), args.get('source')) image_core_header_path = \ generate_image_core_header_path( - args.get('output_path'), device, args.get('source')) + args.get('output_path'), args.get('image_core_name'), args.get('source')) edge_file = \ generate_edge_file_path( - args.get('router_hex_path'), device, args.get('source')) + args.get('router_hex_path'), args.get('image_core_name'), args.get('source')) logging.debug("Image core output file: %s", image_core_path) logging.debug("Image core header output file: %s", image_core_header_path) diff --git a/host/python/uhd/imgbuilder/templates/rfnoc_image_core.v.mako b/host/python/uhd/imgbuilder/templates/rfnoc_image_core.v.mako index 549a469ee..a5a019e16 100644 --- a/host/python/uhd/imgbuilder/templates/rfnoc_image_core.v.mako +++ b/host/python/uhd/imgbuilder/templates/rfnoc_image_core.v.mako @@ -26,7 +26,13 @@ `default_nettype none -`include "${config.device.type}_rfnoc_image_core.vh" +<% + if hasattr(config, 'image_core_name'): + image_core_name = config.image_core_name + else: + image_core_name = config.device.type +%>\ +`include "${image_core_name}_rfnoc_image_core.vh" module rfnoc_image_core #( diff --git a/host/utils/rfnoc_image_builder.py b/host/utils/rfnoc_image_builder.py index 47d28751b..285dfe3e9 100755 --- a/host/utils/rfnoc_image_builder.py +++ b/host/utils/rfnoc_image_builder.py @@ -83,6 +83,11 @@ def setup_parser(): "Needs to be specified either here, or in the configuration file.", default=None) parser.add_argument( + "-n", "--image_core_name", + help="Name to use for the RFNoC image core." + "Defaults to the device name.", + default=None) + parser.add_argument( "-t", "--target", help="Build target (e.g. X310_HG, N320_XG, ...). Needs to be specified " "either here, on the configuration file.", @@ -113,12 +118,16 @@ def image_config(args): config = yaml_utils.load_config(args.yaml_config, get_config_path()) device = config.get('device') if args.device is None else args.device target = config.get('default_target') if args.target is None else args.target - return config, args.yaml_config, device, target + image_core_name = config.get('image_core_name') if args.image_core_name is None else args.image_core_name + if image_core_name is None: + image_core_name = device + return config, args.yaml_config, device, image_core_name, target with open(args.grc_config) as grc_file: config = yaml.load(grc_file) logging.info("Converting GNU Radio Companion file to image builder format") config = image_builder.convert_to_image_config(config, args.grc_blocks) - return config, args.grc_config, args.device, args.target + image_core_name = args.device if args.image_core_name is None else args.image_core_name + return config, args.grc_config, args.device, image_core_name, args.target def resolve_path(path, local): @@ -187,7 +196,7 @@ def main(): if args.log_level is not None: logging.root.setLevel(args.log_level.upper()) - config, source, device, target = image_config(args) + config, source, device, image_core_name, target = image_config(args) source_hash = hashlib.sha256() with open(source, "rb") as source_file: source_hash.update(source_file.read()) @@ -197,6 +206,7 @@ def main(): fpga_path=get_fpga_path(args), config_path=get_config_path(), device=device, + image_core_name=image_core_name, target=target, generate_only=args.generate_only, clean_all=args.clean_all, |