diff --git a/litex/gen/common.py b/litex/gen/common.py index 604cec853..81c2fca88 100644 --- a/litex/gen/common.py +++ b/litex/gen/common.py @@ -19,10 +19,6 @@ def colorer(s, color="bright"): trailer = "\x1b[0m" return header + str(s) + trailer -# Signals ------------------------------------------------------------------------------------------ - -class Open(Signal) : pass - # Bit/Bytes Reversing ------------------------------------------------------------------------------ def reverse_bits(s): @@ -34,6 +30,20 @@ def reverse_bytes(s): return Cat(*[s[i*8:min((i + 1)*8, len(s))] for i in reversed(range(n))]) +# Signals ------------------------------------------------------------------------------------------ + +class Open(Signal): pass + +class Unsigned(Signal): + def __init__(self, bits=1, *args, **kwargs): + assert isinstance(bits, int) + Signal.__init__(self, bits_sign=(bits, 0), *args, **kwargs) + +class Signed(Signal): + def __init__(self, bits=1, *args, **kwargs): + assert isinstance(bits, int) + Signal.__init__(self, bits_sign=(bits, 1), *args, **kwargs) + # Reduction ---------------------------------------------------------------------------------------- from functools import reduce