Commit graph

26 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
whitequark d964ba9cc4 build,vendor: never carry around parts of differential signals.
When a port component is skipped, it should appear neither in the RTL
nor in the constraint file. However, passing around components of
differential ports explicitly makes that harder.

Fixes #456.
Supersedes #457.

Co-authored-by: Jean THOMAS <git0@pub.jeanthomas.me>
2020-07-31 18:41:59 +00:00
Jacob Graves 8117ef6692
tests: fix remove unnecessary workaround for some unittest assertions. 2020-07-28 19:35:25 +00:00
whitequark 3b6727152e test_build_res: fix after commit 3e2ecdf2. 2020-02-07 00:07:19 +00:00
whitequark 75d0fcd639 test: use #nmigen: magic comment instead of monkey patch.
Also, fix missing and incorrect src_loc_at arguments where
appropriate so the testsuite passes without warnings.
2019-10-26 06:37:08 +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 8050cfaa98 build.res: simplify clock constraints.
Before this commit, it was possible to set and get clock constraints
placed on Pin objects. This was not a very good implementation, since
it relied on matching the identity of the provided Pin object to
a previously requested one. The only reason it worked like that is
deficiencies in nextpnr.

Since then, nextpnr has been fixed to allow setting constraints on
arbitrary nets. Correspondingly, backends that are using Synplify
were changed to use [get_nets] instead of [get_ports] in SDC files.
However, in some situations, Synplify does not allow specifying
ports in [get_nets]. (In fact, nextpnr had a similar problem, but
it has also been fixed.)

The simplest way to address this is to refer to the interior net
(after the input buffer), which always works. The only downside
of this is that requesting a clock as a raw pin using
    platform.request("clk", dir="-")
and directly applying a constraint to it could fail in some cases.
This is not a significant issue.
2019-09-21 14:12:29 +00:00
whitequark 378e924280 hdl.ast: rename nbits to width.
Also, replace `bits, sign = x.shape()` with more idiomatic
`width, signed = x.shape()`.

This unifies all properties corresponding to `len(x)` to `x.width`.
(Not all values have a `width` property.)

Fixes #210.
2019-09-20 15:36:25 +00:00
Robin Heinemann 8e048c5a7c build.dsl: add conn argument to Connector. 2019-08-18 19:56:25 +00:00
whitequark b471e33d7f build.res: detect physical conflicts earlier.
This is useful for two reasons:
  1. nMigen can provide better error messages than the platform and
     do it earlier in the build pipeline.
  2. Many platforms handle diffpairs by only constraining the P pin;
     the N pin is completely ignored. If this is undetected,
     downstream users (human or software) can rely on this
     information assuming it is correct and introduce more errors.
     (Of course, this will not catch every mistake, but the most
     common is a copy-paste issue, and that will handle it.)

Fixes #124.
2019-07-03 15:07:44 +00:00
whitequark efb2d773c3 build.{dsl,res,plat}: add PinsN and DiffPairsN. 2019-06-12 14:42:39 +00:00
whitequark b45c5119f5 build.res: allow querying frequency of a previously constrained clock. 2019-06-05 12:51:53 +00:00
whitequark c9879c795b build.{dsl,res,plat}: apply clock constraints to signals, not resources.
This adds the Clock() build DSL element, and adds a resource manager
function add_clock_constraint() that takes a Pin or a Signal.
Note that not all platforms, in particular not any nextpnr platforms
at the moment, can add constraints on arbitrary signals.

Fixes #86.
2019-06-05 08:52:30 +00:00
whitequark ab3f103e5a build.dsl: replace extras= with Attrs().
This change proved more tricky than expected due to downstream
dependencies, so it also includes some secondary refactoring.
2019-06-05 07:02:08 +00:00
whitequark 4310254103 build.res: use ConstraintError iff a constraint invariant is violated.
In particular don't use it for type errors.
2019-06-04 11:00:11 +00:00
whitequark ed64880cc4 build.{plat,res}: add support for connectors.
Fixes #77.
2019-06-03 15:02:15 +00:00
whitequark 41adcc3f97 vendor.fpga.lattice_ice40: implement differential input buffers. 2019-06-03 08:38:12 +00:00
whitequark 6fae06aea9 build.{dsl,plat,res}: allow dir="oe".
Although a dir="oe" pin is generally equivalent to dir="io" pin with
the i* signal(s) disconnected, they are not equivalent, because some
pins may not be able to support input buffers at all, either because
there are no input buffers, or because the input buffers are consumed
by some other resource.

E.g. this can happen on iCE40 when the input buffer is consumed by
a PLL.
2019-06-03 04:42:55 +00:00
whitequark 9ba2efd86b build.{res,plat}: use xdr=0 as default, not xdr=1.
The previous behavior was semantically incorrect.
2019-06-03 03:36:32 +00:00
whitequark cd6488c782 build.res: allow requesting raw ports, with dir="-".
This provides an escape hatch for the case where the nMigen platform
code is not flexible enough, and a IO buffer primitive needs to be
instantiated directly.
2019-06-03 03:36:32 +00:00
whitequark dc17d06fe9 vendor.fpga.lattice_ice40: instantiate SB_IO and apply extras.
The PULLUP and PULLUP_RESISTOR extras are representable in the PCF
file. The IO_STANDARD extra, however, can only be an SB_IO parameter.
2019-06-03 02:51:59 +00:00
whitequark fb01854372 build.{res,plat}: propagate extras to pin fragment factories.
This is necessary because on some platforms, like iCE40, extras
become parameters on an IO primitive, since the constraint file
format is not expressive enough for all of them.
2019-06-03 01:58:43 +00:00
whitequark 98497b2075 build.dsl: require a dict for extras instead of a stringly array.
Fixes #72.
2019-06-02 23:36:21 +00:00
whitequark 53ddff9f33 build.res: always return a Pin record.
In the simple cases, a Pin record consisting of exactly one field
is equivalent in every way to this single field. In the more complex
case however, it can be used as a record, making the code more robust
such that it works with both bidirectional and unidirectional pins.
2019-06-01 16:41:30 +00:00
whitequark 8c1b5a26b3 build.res: accept a list of clocks in ConstraintManager constructor. 2019-06-01 15:41:41 +00:00
Jean-François Nguyen d393c5ec64 build.res: add ConstraintManager. 2019-05-26 01:26:58 +00:00