From ad9e7ebbd34b522affbfa78f96ed1bda28651139 Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Wed, 25 Jul 2018 09:09:20 +0100 Subject: [PATCH] templateify axi_slave_idx --- src/bsv/peripheral_gen/base.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/bsv/peripheral_gen/base.py b/src/bsv/peripheral_gen/base.py index 642557d..4e17b4b 100644 --- a/src/bsv/peripheral_gen/base.py +++ b/src/bsv/peripheral_gen/base.py @@ -333,20 +333,23 @@ class PeripheralInterfaces(object): start += offs return '\n'.join(list(filter(None, ret))) - def axi_slave_idx(self, *args): + def _axi_num_idx(self, start, template, typ, getfn, *args): ret = [] - start = 0 for (name, count) in self.ifacecount: for i in range(count): if self.is_on_fastbus(name, i): continue - (rdef, offs) = self.data[name].axi_slave_idx(start, i) + (rdef, offs) = getattr(self.data[name], getfn)(start, i) #print ("ifc", name, rdef, offs) ret.append(rdef) start += offs - ret.append("typedef %d LastGen_slave_num;" % (start - 1)) + ret.append("typedef %d LastGen_%s_num;" % (start - 1, typ)) decls = '\n'.join(list(filter(None, ret))) - return axi_slave_declarations.format(decls) + return template.format(decls) + + def axi_slave_idx(self, *args): + return self._axi_num_idx(0, axi_slave_declarations, 'slave', + 'axi_slave_idx', *args) def axi_addr_map(self, *args): ret = [] -- 2.30.2