From 44c6e524ba97bab1f491d1d56d0a66ac371761cf Mon Sep 17 00:00:00 2001 From: Robert Jordens Date: Thu, 24 Jul 2014 23:45:41 -0600 Subject: [PATCH] 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. --- migen/fhdl/structure.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) 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 -- 2.30.2