Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AssertionError domain.name not in self.domains #307

Closed
nmigen-issue-migration opened this issue Jan 18, 2020 · 3 comments
Closed

AssertionError domain.name not in self.domains #307

nmigen-issue-migration opened this issue Jan 18, 2020 · 3 comments
Labels
Milestone

Comments

@nmigen-issue-migration
Copy link

Issue by nicolas-robin
Saturday Jan 18, 2020 at 19:39 GMT
Originally opened as m-labs/nmigen#307


Since a7be3b4, this code fails :

Code :

from nmigen import *
from nmigen_boards.ice40_hx8k_b_evn import ICE40HX8KBEVNPlatform

platform = ICE40HX8KBEVNPlatform()
top = Module()
top.d.sync += platform.request("led").o.eq(1)
platform.build(top)

Error :

Traceback (most recent call last):
  File "[...]/sandbox.py", line 7, in <module>
    platform.build(top)
  File "[...]/venv/lib/python3.7/site-packages/nmigen/build/plat.py", line 77, in build
    plan = self.prepare(elaboratable, name, **kwargs)
  File "[...]/venv/lib/python3.7/site-packages/nmigen/build/plat.py", line 147, in prepare
    fragment = fragment.prepare(ports=self.iter_ports(), missing_domain=lambda name: None)
  File "[...]/venv/lib/python3.7/site-packages/nmigen/hdl/ir.py", line 556, in prepare
    new_domains = fragment._propagate_domains(missing_domain)
  File "[...]/venv/lib/python3.7/site-packages/nmigen/hdl/ir.py", line 403, in _propagate_domains
    self._propagate_domains_up()
  File "[...]/venv/lib/python3.7/site-packages/nmigen/hdl/ir.py", line 359, in _propagate_domains_up
    self.add_domains(domain)
  File "[...]/venv/lib/python3.7/site-packages/nmigen/hdl/ir.py", line 145, in add_domains
    assert domain.name not in self.domains
AssertionError
@nmigen-issue-migration
Copy link
Author

Comment by smunaut
Monday Jan 20, 2020 at 08:33 GMT


Same error happens when trying to run glasgow with latest nMigen.
(seen by me, @esden @miek at least)

@nmigen-issue-migration
Copy link
Author

Comment by smunaut
Monday Jan 20, 2020 at 08:54 GMT


Not sure if this is the correct fix, but this seems to work for me :

diff --git a/nmigen/hdl/ir.py b/nmigen/hdl/ir.py
index 26dec85..2b8b74c 100644
--- a/nmigen/hdl/ir.py
+++ b/nmigen/hdl/ir.py
@@ -142,7 +142,7 @@ class Fragment:
     def add_domains(self, *domains):
         for domain in flatten(domains):
             assert isinstance(domain, ClockDomain)
-            assert domain.name not in self.domains
+            assert (domain.name not in self.domains) or (self.domains[domain.name] == domain)
             self.domains[domain.name] = domain
 
     def iter_domains(self):

@nmigen-issue-migration
Copy link
Author

Comment by whitequark
Monday Jan 20, 2020 at 22:59 GMT


Likely not the correct fix, but an acceptable workaround.

@whitequark whitequark added the bug label Jan 29, 2020
@whitequark whitequark added this to the 0.2 milestone Jan 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants