hdl.ast: fix naming of Signal.like() signals when tracer fails.
This commit is contained in:
parent
f2425001aa
commit
cb2f18ee37
|
@ -611,7 +611,7 @@ class Signal(Value, DUID):
|
||||||
self.decoder = decoder
|
self.decoder = decoder
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def like(cls, other, src_loc_at=0, **kwargs):
|
def like(cls, other, name=None, src_loc_at=0, **kwargs):
|
||||||
"""Create Signal based on another.
|
"""Create Signal based on another.
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
|
@ -619,8 +619,12 @@ class Signal(Value, DUID):
|
||||||
other : Value
|
other : Value
|
||||||
Object to base this Signal on.
|
Object to base this Signal on.
|
||||||
"""
|
"""
|
||||||
kw = dict(shape=cls.wrap(other).shape(),
|
if name is None:
|
||||||
name=tracer.get_var_name(depth=2 + src_loc_at))
|
try:
|
||||||
|
name = tracer.get_var_name(depth=2 + src_loc_at)
|
||||||
|
except tracer.NameNotFound:
|
||||||
|
name = "$like"
|
||||||
|
kw = dict(shape=cls.wrap(other).shape(), name=name)
|
||||||
if isinstance(other, cls):
|
if isinstance(other, cls):
|
||||||
kw.update(reset=other.reset, reset_less=other.reset_less,
|
kw.update(reset=other.reset, reset_less=other.reset_less,
|
||||||
attrs=other.attrs, decoder=other.decoder)
|
attrs=other.attrs, decoder=other.decoder)
|
||||||
|
|
|
@ -458,6 +458,8 @@ class SignalTestCase(FHDLTestCase):
|
||||||
self.assertEqual(s5.decoder, str)
|
self.assertEqual(s5.decoder, str)
|
||||||
s6 = Signal.like(10)
|
s6 = Signal.like(10)
|
||||||
self.assertEqual(s6.shape(), (4, False))
|
self.assertEqual(s6.shape(), (4, False))
|
||||||
|
s7 = [Signal.like(Signal(4))][0]
|
||||||
|
self.assertEqual(s7.name, "$like")
|
||||||
|
|
||||||
|
|
||||||
class ClockSignalTestCase(FHDLTestCase):
|
class ClockSignalTestCase(FHDLTestCase):
|
||||||
|
|
Loading…
Reference in a new issue