From: Robert Jordens Date: Fri, 25 Jul 2014 05:45:41 +0000 (-0600) Subject: migen.fhdl.structure: add Signal.like(other) X-Git-Tag: 24jan2021_ls180~2099^2~341 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=44c6e524ba97bab1f491d1d56d0a66ac371761cf;p=litex.git migen.fhdl.structure: add Signal.like(other) This is a convenience method. Signal(flen(other)) is used frequently but that drops the signedness. Signal((other.nbits, other.signed)) would be correct but is long. --- diff --git a/migen/fhdl/structure.py b/migen/fhdl/structure.py index 7ab42545..aa33888e 100644 --- a/migen/fhdl/structure.py +++ b/migen/fhdl/structure.py @@ -274,6 +274,20 @@ class Signal(Value): def __repr__(self): return "" + @classmethod + def like(cls, other): + """Create Signal based on another. + + Parameters + ---------- + other : Value + Object to base this Signal on. + + See `migen.fhdl.bitcontainer.value_bits_sign`() for details. + """ + from migen.fhdl.bitcontainer import value_bits_sign + return cls(value_bits_sign(other)) + class ClockSignal(Value): """Clock signal for a given clock domain