-
Notifications
You must be signed in to change notification settings - Fork 58
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
build: add ConstraintManager. #64
Conversation
Codecov Report
@@ Coverage Diff @@
## master #64 +/- ##
==========================================
+ Coverage 86.2% 86.38% +0.18%
==========================================
Files 28 30 +2
Lines 4174 4297 +123
Branches 867 897 +30
==========================================
+ Hits 3598 3712 +114
- Misses 481 486 +5
- Partials 95 99 +4
Continue to review full report at Codecov.
|
|
||
# Implementation of the Yosys RTLIL::IdString escaping function, as defined in | ||
# https://github.com/YosysHQ/yosys/blob/master/backends/verilog/verilog_backend.cc#L101-L159 | ||
def yosys_id_escape(s): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This list doesn't have anything to do with Yosys itself, it is a list of (System)Verilog keywords.
nmigen/build/generic_platform.py
Outdated
@@ -0,0 +1,161 @@ | |||
from collections import defaultdict, OrderedDict |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file (and its corresponding test file) should really be called something like nmigen.build.constraint
.
nmigen/build/generic_platform.py
Outdated
if not isinstance(resource, Resource): | ||
raise TypeError("Object {!r} is not a Resource".format(resource)) | ||
if isinstance(resource.io[0], Subsignal): | ||
raise ConstraintError("Cannot constrain Resource ('{}', {}) to a period of {} ns " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be more clear to say "Cannot constrain period of resource … because it has subsignals", since there is no period that would be valid here at all.
nmigen/build/generic_platform.py
Outdated
|
||
class ConstraintManager: | ||
def __init__(self, resources): | ||
self.available = defaultdict(dict) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First, this should be an OrderedDict too.
Second, a much nicer logic would be to have two dicts, resources
and requested
. In the first dict would be contained all resources ever registered with this constraint manager. In the second dict, there would be contained resources requested from this constraint manager.
The reasons are twofold. First, oMigen has a problem that if a resource is requested twice, it acts the second time as if the resource has never existed in the first place. This is very confusing. Second, with the current implementation, you can request, add, request, add, ... the same resource any amount of times.
nmigen/build/generic_platform.py
Outdated
self.tristates = [] | ||
self.diffpairs = [] | ||
self.ports = [] | ||
self.inouts = [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, since none of the fields above appear to be a part of the public API, they all should be named starting with an underscore.
Thanks for this great PR. I've merged it manually with some changes:
|
No description provided.