def METHOD_NAME(self, pads, mode="master"):
    assert mode in ["slave", "master"]
    r = []
    for name, width, direction in self.layout:
        sig  = getattr(self, name)
        pad  = getattr(pads, name)
        if mode == "master":
            if direction == DIR_M_TO_S:
                r.append(pad.eq(sig))
            else:
                r.append(sig.eq(pad))
        else:
            if direction == DIR_S_TO_M:
                r.append(pad.eq(sig))
            else:
                r.append(sig.eq(pad))
    return r