Commit graph

21 commits

Author SHA1 Message Date
whitequark 67b957d4f4 tests: move out of the main package.
Compared to tests in the repository root, tests in the package have
many downsides:
  * Unless explicitly excluded in find_packages(), tests and their
    support code effectively become a part of public API.
    This, unfortunately, happened with FHDLTestCase, which was never
    intended for downstream use.
  * Even if explicitly excluded from the setuptools package, using
    an editable install, or setting PYTHONPATH still allows accessing
    the tests.
  * Having a sub-package that is present in the source tree but not
    exported (or, worse, exported only sometimes) is confusing.
  * The name `nmigen.test` cannot be used for anything else, such as
    testing utilities that *are* intended for downstream use.
2020-08-27 00:33:31 +00:00
Jacob Graves 8117ef6692
tests: fix remove unnecessary workaround for some unittest assertions. 2020-07-28 19:35:25 +00:00
Shawn Anastasio 2f7c3bf443
hdl.rec: preserve shapes when constructing a layout.
Preserve the original user-provided shape, while still checking 
its validity. This allows Enum decoders to work when specifying
record fields with Enums.

Fixes #393.
2020-06-05 03:19:46 +00:00
whitequark 7a08901117 hdl.rec: improve repr() for Layout.
Fixes #326.
2020-04-12 04:47:40 +00:00
whitequark 2f9dab361f {,_}tools→{,_}utils
In context of nMigen, "tools" means "parts of toolchain", so it is
confusing to have a completely unrelated module also called "tools".
2019-10-13 18:53:38 +00:00
whitequark b90687c988 Rename remaining wrap methods to cast.
Following commit d72d4a55.
2019-10-11 13:28:26 +00:00
whitequark a658cb2bbf hdl.ast: deprecate shapes like (1, True) in favor of signed(1).
This is a great improvement in clarity.
2019-10-11 13:22:08 +00:00
whitequark 6aabdc0a73 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.
2019-10-11 12:52:41 +00:00
whitequark 1976310bf0 hdl.rec: fix using Enum subclass as shape if direction is specified.
Also improves error messages.

Fixes #224.
2019-09-22 17:23:32 +00:00
whitequark 4c582ef609 hdl.rec: allow using Enum subclass as shape.
Fixes #223.
2019-09-22 15:17:40 +00:00
whitequark 0ab0a74ec1 hdl.rec: respect modifications to signals in Record.like().
Fixes #126.
2019-07-08 10:59:15 +00:00
whitequark 6b843b5be6 hdl.rec: implement slicing by component names.
Fixes #121.
2019-07-02 17:46:53 +00:00
whitequark 34f110100a hdl.rec: implement Record.like.
Fixes #120.
2019-07-02 17:46:53 +00:00
whitequark a1940c5528 hdl.rec: unbreak hasattr(rec, ...).
hasattr() requires that AttributeError be raised. Change __getitem__
to raise AttributeError, too, since it is fundamentally just sugar
for getattr().
2019-06-03 07:43:31 +00:00
whitequark 2b7dc37ffe hdl.rec: allow providing fields during construction.
This allows creating records populated with e.g. signals with custom
names, or sub-records that are instances of Record subclasses.
2019-05-25 22:06:56 +00:00
whitequark ce1eff5464 hdl.rec: implement Record.connect.
Fixes #31.
2019-04-21 06:37:08 +00:00
whitequark 611c25f909 hdl.rec: fix slicing of records. 2019-04-19 19:55:39 +00:00
anuejn 3c95299c4e hdl.rec: separate record and signal name with __, not _.
This makes names of signals within records less ambiguous, in case
they themselves have underscores within them.
2019-03-25 14:26:00 +00:00
whitequark 3c07d8d52c hdl.rec: include record name in error message. 2019-01-01 03:39:12 +00:00
whitequark 031a9e2616 hdl.rec: use a helpful error on unknown field reference. 2019-01-01 03:35:34 +00:00
whitequark 92a96e1644 hdl.rec: add basic record support. 2018-12-28 13:22:10 +00:00