def copy_gear(mem_gear: Gear, args, kwds, name, intf_mapping, kwd_intfs): gear_inst, outside_intfs = copy_gear_full(mem_gear, name) in_num = len(gear_inst.in_ports) for pi, ii in intf_mapping.items(): if pi < len(gear_inst.in_ports): kwd_intfs[ii].connect(gear_inst.in_ports[pi]) else: kwd_intfs[ii].source(gear_inst.out_ports[pi - in_num]) for key in kwds: if key in reg['gear/params/extra']: gear_inst.params[key] = kwds[key] for name, val in mem_gear.const_args.items(): from pygears.lib import const const(val=val, intfs=[args[name]]) for i, intf in enumerate(args.values()): p = gear_inst.in_ports[i] assert p.producer is None intf.connect(p) out_intfs = tuple(o for i, o in enumerate(gear_inst.outputs) if (i + in_num) not in intf_mapping) return gear_inst, out_intfs
def connect_input(self, args, const_args): for name, val in const_args.items(): from pygears.lib import const const(val=val, intfs=[args[name]]) for i, (name, intf) in enumerate(args.items()): port = InPort(self, i, name, dtype=self.params[name]) intf.connect(port) self.in_ports.append(port) self.const_args = const_args self.args = args
def test_basic(sim_cls): directed(f=const(sim_cls=sim_cls, val=Uint[4](5)), ref=[5, 5, 5, 5]) sim(timeout=4)
def test_unit(sim_cls): directed(f=const(sim_cls=sim_cls, val=Unit()), ref=[Unit(), Unit(), Unit(), Unit()]) sim(timeout=4)