self.decoder = decoder
@classmethod
- def like(cls, other, name=None, src_loc_at=0, **kwargs):
+ def like(cls, other, name=None, name_suffix=None, src_loc_at=0, **kwargs):
"""Create Signal based on another.
Parameters
other : Value
Object to base this Signal on.
"""
- name = name or tracer.get_var_name(depth=2 + src_loc_at, default="$like")
- kw = dict(shape=cls.wrap(other).shape(), name=name)
+ if name is not None:
+ new_name = str(name)
+ elif name_suffix is not None:
+ new_name = other.name + str(name_suffix)
+ else:
+ new_name = tracer.get_var_name(depth=2 + src_loc_at, default="$like")
+ kw = dict(shape=cls.wrap(other).shape(), name=new_name)
if isinstance(other, cls):
kw.update(reset=other.reset, reset_less=other.reset_less,
attrs=other.attrs, decoder=other.decoder)
self.assertEqual(s6.shape(), (4, False))
s7 = [Signal.like(Signal(4))][0]
self.assertEqual(s7.name, "$like")
+ s8 = Signal.like(s1, name_suffix="_ff")
+ self.assertEqual(s8.name, "s1_ff")
class ClockSignalTestCase(FHDLTestCase):