-
Notifications
You must be signed in to change notification settings - Fork 210
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
migen: create VerilogConvert and EDIFConvert classes and return it wi…
…th convert functions
- Loading branch information
1 parent
21c5fb6
commit f03aa76
Showing
4 changed files
with
88 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -266,45 +266,57 @@ def _printspecials(overrides, specials, ns): | |
r += pr | ||
return r | ||
|
||
def convert(f, ios=None, name="top", | ||
return_ns=False, | ||
special_overrides=dict(), | ||
create_clock_domains=True, | ||
display_run=False): | ||
if not isinstance(f, _Fragment): | ||
f = f.get_fragment() | ||
if ios is None: | ||
ios = set() | ||
class VerilogConvert: | ||
This comment has been minimized.
Sorry, something went wrong.
sbourdeauducq
Member
|
||
def __init__(self, f, ios=None, name="top", | ||
special_overrides=dict(), | ||
create_clock_domains=True, | ||
display_run=False): | ||
self.name = name | ||
self.special_overrides = special_overrides | ||
self.display_run = display_run | ||
|
||
for cd_name in list_clock_domains(f): | ||
try: | ||
f.clock_domains[cd_name] | ||
except KeyError: | ||
if create_clock_domains: | ||
cd = ClockDomain(cd_name) | ||
f.clock_domains.append(cd) | ||
ios |= {cd.clk, cd.rst} | ||
else: | ||
raise KeyError("Unresolved clock domain: '"+cd_name+"'") | ||
if not isinstance(f, _Fragment): | ||
f = f.get_fragment() | ||
if ios is None: | ||
ios = set() | ||
|
||
f = lower_complex_slices(f) | ||
insert_resets(f) | ||
f = lower_basics(f) | ||
fs, lowered_specials = _lower_specials(special_overrides, f.specials) | ||
f += lower_basics(fs) | ||
for cd_name in list_clock_domains(f): | ||
try: | ||
f.clock_domains[cd_name] | ||
except KeyError: | ||
if create_clock_domains: | ||
cd = ClockDomain(cd_name) | ||
f.clock_domains.append(cd) | ||
ios |= {cd.clk, cd.rst} | ||
else: | ||
raise KeyError("Unresolved clock domain: '"+cd_name+"'") | ||
|
||
ns = build_namespace(list_signals(f) \ | ||
| list_special_ios(f, True, True, True) \ | ||
| ios) | ||
f = lower_complex_slices(f) | ||
insert_resets(f) | ||
f = lower_basics(f) | ||
fs, lowered_specials = _lower_specials(special_overrides, f.specials) | ||
f += lower_basics(fs) | ||
|
||
r = "/* Machine-generated using Migen */\n" | ||
r += _printheader(f, ios, name, ns) | ||
r += _printcomb(f, ns, display_run) | ||
r += _printsync(f, ns) | ||
r += _printspecials(special_overrides, f.specials - lowered_specials, ns) | ||
r += "endmodule\n" | ||
ns = build_namespace(list_signals(f) \ | ||
| list_special_ios(f, True, True, True) \ | ||
| ios) | ||
|
||
if return_ns: | ||
return r, ns | ||
else: | ||
self.f = f | ||
self.ios = ios | ||
self.ns = ns | ||
self.lowered_specials = lowered_specials | ||
|
||
def __str__(self): | ||
r = "/* Machine-generated using Migen */\n" | ||
r += _printheader(self.f, self.ios, self.name, self.ns) | ||
r += _printcomb(self.f, self.ns, self.display_run) | ||
r += _printsync(self.f, self.ns) | ||
r += _printspecials(self.special_overrides, self.f.specials - self.lowered_specials, self.ns) | ||
r += "endmodule\n" | ||
return r | ||
|
||
def convert(f, ios=None, name="top", | ||
special_overrides=dict(), | ||
create_clock_domains=True, | ||
display_run=False): | ||
return VerilogConvert(f, ios, name, special_overrides, create_clock_domains, display_run) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
We discussed that
str
should print the whole content of the conversion object, including data files.http://irclog.whitequark.org/m-labs/2015-03-19#12165196;