hdl.ast: add an explicit Shape class, included in prelude.
authorwhitequark <cz@m-labs.hk>
Fri, 11 Oct 2019 12:52:41 +0000 (12:52 +0000)
committerwhitequark <cz@m-labs.hk>
Fri, 11 Oct 2019 12:52:41 +0000 (12:52 +0000)
commitf08f7c564642441397098bb37fd91f65d702a8d9
tree392d2c1215d773ee742da0425fe151484dec190c
parent1d8a397404025329e4bbe44d1e2bdf8e4f6b548a
hdl.ast: add an explicit Shape class, included in prelude.

Shapes have long been a part of nMigen, but represented using tuples.
This commit adds a Shape class (using namedtuple for backwards
compatibility), and accepts anything castable to Shape (including
enums, ranges, etc) anywhere a tuple was accepted previously.

In addition, `signed(n)` and `unsigned(n)` are added as aliases for
`Shape(n, signed=True)` and `Shape(n, signed=False)`, transforming
code such as `Signal((8, True))` to `Signal(signed(8))`.
These aliases are also included in prelude.

Preparation for #225.
nmigen/hdl/__init__.py
nmigen/hdl/ast.py
nmigen/hdl/rec.py
nmigen/test/test_hdl_ast.py
nmigen/test/test_hdl_rec.py