hdl.ast: add an explicit Shape class, included in prelude.
authorwhitequark <whitequark@whitequark.org>
Fri, 11 Oct 2019 12:52:41 +0000 (12:52 +0000)
committerwhitequark <whitequark@whitequark.org>
Fri, 11 Oct 2019 12:52:41 +0000 (12:52 +0000)
commit6aabdc0a73dac75e42e0f0923f66497827cd8b17
tree392d2c1215d773ee742da0425fe151484dec190c
parentdb960e7c30f7ac66893af4a026a4515162ce5613
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