From: Florent Kermarrec Date: Thu, 21 Apr 2016 06:08:47 +0000 (+0200) Subject: gen/genlib/record: rename leave_out by omit and add keep parameter to Record.connect X-Git-Tag: 24jan2021_ls180~1967 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=c330e7be4927ae1b6c96b0d9d3e59596654160a9;p=litex.git gen/genlib/record: rename leave_out by omit and add keep parameter to Record.connect --- diff --git a/litex/gen/genlib/record.py b/litex/gen/genlib/record.py index 0038b069..9b4ce3db 100644 --- a/litex/gen/genlib/record.py +++ b/litex/gen/genlib/record.py @@ -131,15 +131,24 @@ class Record: def raw_bits(self): return Cat(*self.flatten()) - def connect(self, *slaves, leave_out=set()): - if isinstance(leave_out, str): - leave_out = {leave_out} + def connect(self, *slaves, keep=None, omit=None): + if keep is None: + keep = set([f[0] for f in self.layout]) + if isinstance(keep, list): + keep = set(keep) + if omit is None: + omit = set() + if isinstance(omit, list): + omit = set(omit) + + keep = keep - omit + r = [] for f in self.layout: field = f[0] - if field not in leave_out: - self_e = getattr(self, field) - if isinstance(self_e, Signal): + self_e = getattr(self, field) + if isinstance(self_e, Signal): + if field in keep: direction = f[2] if direction == DIR_M_TO_S: r += [getattr(slave, field).eq(self_e) for slave in slaves] @@ -147,9 +156,9 @@ class Record: r.append(self_e.eq(reduce(or_, [getattr(slave, field) for slave in slaves]))) else: raise TypeError - else: - for slave in slaves: - r += self_e.connect(getattr(slave, field), leave_out=leave_out) + else: + for slave in slaves: + r += self_e.connect(getattr(slave, field), keep=keep, omit=omit) return r def connect_flat(self, *slaves):