From 04e9ffa2b2c607880631677654634bc4aa52882a Mon Sep 17 00:00:00 2001 From: Andrew Dennison Date: Tue, 1 Jun 2021 09:48:02 +1000 Subject: [PATCH 1/6] soc/csr: Document simulation side effects of read/write --- litex/soc/interconnect/csr.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/litex/soc/interconnect/csr.py b/litex/soc/interconnect/csr.py index ba4409bea..b9fc46e78 100644 --- a/litex/soc/interconnect/csr.py +++ b/litex/soc/interconnect/csr.py @@ -419,11 +419,16 @@ class CSRStorage(_CompoundCSR): self.sync += self.re.eq(sc.re) def read(self): - """Read method for simulation.""" + """Read method for simulation. + + Side effects: none (asynchronous).""" return (yield self.storage) def write(self, value): - """Write method for simulation.""" + """Write method for simulation. + + Side effects: synchronous advances simulation clk by one tick.""" + yield self.storage.eq(value) yield self.re.eq(1) if hasattr(self, "fields"): From 053e540b8ae6ae4a5c8fdb2babf6b82f2bca373c Mon Sep 17 00:00:00 2001 From: Andrew Dennison Date: Tue, 1 Jun 2021 09:49:58 +1000 Subject: [PATCH 2/6] soc/csr: ValueError if write would be truncated in simulation --- litex/soc/interconnect/csr.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/litex/soc/interconnect/csr.py b/litex/soc/interconnect/csr.py index b9fc46e78..ab1730a0e 100644 --- a/litex/soc/interconnect/csr.py +++ b/litex/soc/interconnect/csr.py @@ -428,6 +428,8 @@ class CSRStorage(_CompoundCSR): """Write method for simulation. Side effects: synchronous advances simulation clk by one tick.""" + if bits_for(value) > self.size: + raise ValueError(f"value {value} exceeds range of {self.size} bit CSR {self.name}.") yield self.storage.eq(value) yield self.re.eq(1) From 0e164bb23c569e3133d13ac92f9d6e6da0ebd2ae Mon Sep 17 00:00:00 2001 From: Andrew Dennison Date: Sun, 5 Sep 2021 10:29:15 +1000 Subject: [PATCH 3/6] build/generic_platform: include identifier in ValueError * show which identifier is incorrectly specified --- litex/build/generic_platform.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/litex/build/generic_platform.py b/litex/build/generic_platform.py index 6d95d5ff3..96fe8bc8e 100644 --- a/litex/build/generic_platform.py +++ b/litex/build/generic_platform.py @@ -155,7 +155,10 @@ class ConnectorManager: r = [] for identifier in identifiers: if ":" in identifier: - conn, pn = identifier.split(":") + try: + conn, pn = identifier.split(":") + except ValueError as err: + raise ValueError(f"\"{identifier}\" {err}") from err if pn.isdigit(): pn = int(pn) From 1fd99b366af46b313df17fe8e7addaabcdc3be31 Mon Sep 17 00:00:00 2001 From: Andrew Dennison Date: Fri, 15 Oct 2021 09:39:06 +1100 Subject: [PATCH 4/6] soc: report System clock to 3dp --- litex/soc/integration/soc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/litex/soc/integration/soc.py b/litex/soc/integration/soc.py index a63c5d6c9..dc2e7fb7b 100644 --- a/litex/soc/integration/soc.py +++ b/litex/soc/integration/soc.py @@ -731,7 +731,7 @@ class SoC(Module): self.logger.info(colorer("Creating SoC... ({})".format(build_time()))) self.logger.info(colorer("-"*80, color="bright")) self.logger.info("FPGA device : {}.".format(platform.device)) - self.logger.info("System clock: {:3.2f}MHz.".format(sys_clk_freq/1e6)) + self.logger.info("System clock: {:3.3f}MHz.".format(sys_clk_freq/1e6)) # SoC attributes --------------------------------------------------------------------------- self.platform = platform From f426872e0cb9ee9bf740ac898810222f960ea456 Mon Sep 17 00:00:00 2001 From: Andrew Dennison Date: Mon, 18 Oct 2021 10:40:13 +1100 Subject: [PATCH 5/6] efinix: read pll names from database --- litex/build/efinix/dbparser.py | 15 +++++++++++++++ litex/build/efinix/platform.py | 5 ++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/litex/build/efinix/dbparser.py b/litex/build/efinix/dbparser.py index 9f0e1d4f7..0b15d56cb 100644 --- a/litex/build/efinix/dbparser.py +++ b/litex/build/efinix/dbparser.py @@ -80,6 +80,21 @@ class EfinixDbParser(): return None + def get_block_instance_names(self, block): + dmap = self.get_device_map(self.device) + die = self.get_die_file_name(dmap) + tree = et.parse(self.efinity_db_path + 'die/' + die) + root = tree.getroot() + + peri = root.findall('efxpt:periphery_instance', namespaces) + names = [] + for p in peri: + if p.get('block') == block: + names.append(p.get('name')) + + print(f"block {block}: names:{names}") + return names + def get_pll_inst_from_gpio_inst(self, dmap, inst): die = self.get_die_file_name(dmap) tree = et.parse(self.efinity_db_path + 'die/' + die) diff --git a/litex/build/efinix/platform.py b/litex/build/efinix/platform.py index 2f337e881..e0ed622dd 100644 --- a/litex/build/efinix/platform.py +++ b/litex/build/efinix/platform.py @@ -22,9 +22,6 @@ class EfinixPlatform(GenericPlatform): self.timing_model = self.device[-2:] self.device = self.device[:-2] - self.pll_available = ['PLL_TL0', 'PLL_TR0', 'PLL_TR1', 'PLL_TR2', 'PLL_TR3', 'PLL_BR0', 'PLL_BR1', 'PLL_BR2', 'PLL_BL0'] - self.pll_used = [] - if os.getenv("LITEX_ENV_EFINITY", False) == False: msg = "Unable to find or source Efinity toolchain, please either:\n" msg += "- Set LITEX_ENV_EFINITY environment variant to Efinity path.\n" @@ -40,6 +37,8 @@ class EfinixPlatform(GenericPlatform): raise ValueError("Unknown toolchain") self.parser = EfinixDbParser(self.efinity_path, self.device) + self.pll_available = self.parser.get_block_instance_names('pll') + self.pll_used = [] def get_verilog(self, *args, special_overrides=dict(), **kwargs): so = dict(common.efinix_special_overrides) From a043b2536d1bac20f06f92fcd6ea5cafce2b9835 Mon Sep 17 00:00:00 2001 From: Andrew Dennison Date: Tue, 19 Oct 2021 10:38:54 +1100 Subject: [PATCH 6/6] efinix: abort if scripts fail * get obscure downstream errors when the scripts blindly continue --- litex/build/efinix/efinity.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/litex/build/efinix/efinity.py b/litex/build/efinix/efinity.py index f517a9c0e..f099877f8 100644 --- a/litex/build/efinix/efinity.py +++ b/litex/build/efinix/efinity.py @@ -156,7 +156,9 @@ def _build_peri(efinity_path, build_name, partnumber, named_sc, named_pc, fragme tools.write_to_file("iface.py", header + gen + gpio + add + footer) - subprocess.call([efinity_path + '/bin/python3', 'iface.py']) + if subprocess.call([efinity_path + '/bin/python3', 'iface.py']) != 0: + raise OSError("Error occurred during Efinity peri script execution.") + # Project configuration ------------------------------------------------------------------------ @@ -316,7 +318,8 @@ class EfinityToolchain(): # Run if run: - subprocess.call([self.efinity_path + '/scripts/efx_run.py', build_name + '.xml', '-f', 'compile']) + if subprocess.call([self.efinity_path + '/scripts/efx_run.py', build_name + '.xml', '-f', 'compile']) != 0: + raise OSError("Error occurred during efx_run script execution.") os.chdir(cwd)