From 2172d9f0ba717ddb202ed734e6a71b18da61b459 Mon Sep 17 00:00:00 2001 From: Shane Fleming Date: Thu, 20 Oct 2022 17:16:54 +0100 Subject: [PATCH] Moving the location of global state file saving (#1402) * Moved the caching function from the parser to the device, in all cases we want the cache to be generated only after download so it makes more sense here. * increasing version to 3.0.1 --- pynq/__init__.py | 2 +- pynq/pl_server/embedded_device.py | 51 ++++++++++++++----------------- 2 files changed, 24 insertions(+), 29 deletions(-) diff --git a/pynq/__init__.py b/pynq/__init__.py index f23b4d227..16022d5f2 100755 --- a/pynq/__init__.py +++ b/pynq/__init__.py @@ -17,7 +17,7 @@ from .uio import UioController __all__ = ["lib", "tests"] -__version__ = "3.0.0" +__version__ = "3.0.1" # This ID will always be tied to a specific release tag # since the file will be modified to edit the version __git_id__ = "$Id$" diff --git a/pynq/pl_server/embedded_device.py b/pynq/pl_server/embedded_device.py index 482a6bf7c..0caa45728 100644 --- a/pynq/pl_server/embedded_device.py +++ b/pynq/pl_server/embedded_device.py @@ -277,35 +277,8 @@ def get_parser(self, partial:bool=False): parser.bin_data = self.get_bin_data() parser.xclbin_data = xclbin_data parser.dtbo_data = self.get_dtbo_data() - self._cache_metadata(parser) return parser - def _cache_metadata(self, parser, name:str="Unknown")->None: - """ Caches the metadata and global state """ - if not hasattr(parser, "_from_cache"): - - t = datetime.datetime.now() - ts = "{}/{}/{} {}:{}:{} +{}".format( - t.year, t.month, t.day, t.hour, t.minute, t.second, t.microsecond - ) - - gs = GlobalState(bitfile_name=str(self._filepath), - timestamp=ts, - active_name=name, - psddr=parser.mem_dict.get("PSDDR", {})) - ip =parser.ip_dict - for sd_name, details in ip.items(): - if details["type"] in ["xilinx.com:ip:pr_axi_shutdown_manager:1.0", - "xilinx.com:ip:dfx_axi_shutdown_manager:1.0",]: - gs.add(name=sd_name, addr=details["phys_addr"]) - save_global_state(gs) - - if hasattr(parser, "systemgraph"): - if not parser.systemgraph is None: - STATE_DIR = os.path.dirname(__file__) - pickle.dump(parser, open(f"{STATE_DIR}/_current_metadata.pkl", "wb")) - - class BitfileHandler(BitstreamHandler): def get_bin_data(self): @@ -663,7 +636,28 @@ def set_axi_port_width(self, parser): def gen_cache(self, bitstream, parser=None): """ Generates the cache of the metadata even if no download occurred """ - super()._cache_metadata(parser, bitstream, self.name) + if not hasattr(parser, "_from_cache"): + t = datetime.datetime.now() + ts = "{}/{}/{} {}:{}:{} +{}".format( + t.year, t.month, t.day, t.hour, t.minute, t.second, t.microsecond + ) + + if os.path.exists(bitstream.bitfile_name): + gs=GlobalState(bitfile_name=str(bitstream.bitfile_name), + timestamp=ts, + active_name=self.name, + psddr=parser.mem_dict.get("PSDDR", {})) + ip=parser.ip_dict + for sd_name, details in ip.items(): + if details["type"] in ["xilinx.com:ip:pr_axi_shutdown_manager:1.0", + "xilinx.com:ip:dfx_axi_shutdown_manager:1.0",]: + gs.add(name=sd_name, addr=details["phys_addr"]) + save_global_state(gs) + + if hasattr(parser, "systemgraph"): + if not parser.systemgraph is None: + STATE_DIR = os.path.dirname(__file__) + pickle.dump(parser, open(f"{STATE_DIR}/_current_metadata.pkl", "wb")) def download(self, bitstream, parser=None): @@ -677,6 +671,7 @@ def download(self, bitstream, parser=None): if not bitstream.partial: self.shutdown() + self.gen_cache(bitstream, parser) flag = 0 else: flag = 1