-
Notifications
You must be signed in to change notification settings - Fork 178
Added gatemate vendor and Updated init file #1460
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
base: main
Are you sure you want to change the base?
Changes from 8 commits
fd61e4d
0580d1a
95bea8a
ceeca1f
1eb3001
e3e65f8
4a2b7da
ed3f252
857d8e7
c3b8f9c
231bbda
59861aa
9c0e84b
3760be1
0505ca5
9a82d53
f639850
006ca56
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,129 @@ | ||||||||
from abc import abstractmethod | ||||||||
from amaranth import * | ||||||||
from amaranth.build import * | ||||||||
from amaranth.lib.cdc import ResetSynchronizer | ||||||||
|
||||||||
|
||||||||
|
||||||||
__all__ = ["GateMatePlatform"] | ||||||||
|
||||||||
whitequark marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||
|
||||||||
|
||||||||
class GateMatePlatform(TemplatedPlatform): | ||||||||
""" | ||||||||
|
||||||||
Required tools: | ||||||||
* ``yosys`` | ||||||||
* ``p_r`` | ||||||||
|
||||||||
The environment is populated by setting the ``AMARANTH_ENV_GATEMATE`` environment variable to point to the toolchain directory. | ||||||||
whitequark marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||
""" | ||||||||
|
||||||||
device = property(abstractmethod(lambda: None)) | ||||||||
package = property(abstractmethod(lambda: None)) | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I just realized that nothing in the platform file is using these variables. In that case they should be removed. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Deleted those lines |
||||||||
|
||||||||
toolchain = "GateMate" | ||||||||
|
||||||||
required_tools = [ | ||||||||
"yosys", | ||||||||
"p_r", | ||||||||
] | ||||||||
|
||||||||
file_templates = { | ||||||||
**TemplatedPlatform.build_script_templates, | ||||||||
"{{name}}.v": r""" | ||||||||
/* {{autogenerated}} */ | ||||||||
{{emit_verilog()}} | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For a Yosys-based platform, you should output a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added
Instead of
|
||||||||
""", | ||||||||
"{{name}}.debug.v": r""" | ||||||||
/* {{autogenerated}} */ | ||||||||
{{emit_debug_verilog()}} | ||||||||
""", | ||||||||
"{{name}}.ys": r""" | ||||||||
# {{autogenerated}} | ||||||||
{% for file in platform.iter_files(".v") -%} | ||||||||
read -sv {{get_override("read_verilog_opts")|options}} {{file}} | ||||||||
{% endfor %} | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This isn't right: you should not be reading There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. After reading all user-provided files, you should read the top-level There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The .ys script is now:
In the documentation provided here: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The
But running the code for my Blinky example I get this:
The
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, at the moment There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
That is odd. If you push your changes I can look into it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I pushed the changes. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I added my
|
||||||||
{{get_override("script_after_read")|default("# (script_after_read placeholder)")}} | ||||||||
synth_gatemate {{get_override("synth_opts")|options}} -top {{name}} -vlog {{name}}_synth.v | ||||||||
{{get_override("script_after_synth")|default("# (script_after_synth placeholder)")}} | ||||||||
""", | ||||||||
"{{name}}.ccf": r""" | ||||||||
# {{autogenerated}} | ||||||||
{% for port_name, pin_name, attrs in platform.iter_port_constraints_bits() -%} | ||||||||
Net "{{port_name}}" Loc = "{{pin_name}}" | ||||||||
{%- for constraint, value in attrs.items() -%} | ||||||||
| {{constraint}}={{value}} | ||||||||
{%- endfor -%}; | ||||||||
{% endfor %} | ||||||||
""", | ||||||||
"{{name}}.sdc": r""" | ||||||||
# {{autogenerated}} | ||||||||
{% for net_signal, port_signal, frequency in platform.iter_clock_constraints() -%} | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is no There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I didn't test the .sdc function, to be honest. I based this part of the on the What do I need to do here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You need to make sure that a clock constraint, as specified in your board file at least, is actually applied. Whether a clock constraint is applied or not can be seen in the report of the PNR tool, in a format described in the vendor's documentation. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That has a clock constraint file in the top right, as I would expect. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that is their pin constraint file, the |
||||||||
{% if port_signal is not none -%} | ||||||||
create_clock -period {{1000000000/frequency}} [get_ports {{port_signal.name|tcl_quote}}] | ||||||||
{% endif %} | ||||||||
{% endfor %} | ||||||||
""", | ||||||||
} | ||||||||
|
||||||||
command_templates = [ | ||||||||
r""" | ||||||||
{{invoke_tool("yosys")}} | ||||||||
{{quiet("-q")}} | ||||||||
{{get_override("yosys_opts")|options}} | ||||||||
-l {{name}}.rpt | ||||||||
{{name}}.ys | ||||||||
""", | ||||||||
r""" | ||||||||
|
||||||||
{{invoke_tool("p_r")}} | ||||||||
{{verbose("-v")}} | ||||||||
-i {{name}}_synth.v | ||||||||
-o {{name}} | ||||||||
-ccf {{name}}.ccf | ||||||||
-cCP > log/impl.log | ||||||||
whitequark marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is no log directory any more. The redirection should probably be something like this:
Suggested change
The There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changed to
|
||||||||
""", | ||||||||
] | ||||||||
|
||||||||
# Common logic | ||||||||
|
||||||||
@property | ||||||||
def default_clk_constraint(self): | ||||||||
if self.default_clk == "sys_clk0": | ||||||||
return Clock(self.osc_freq / self.osc_div) | ||||||||
return super().default_clk_constraint | ||||||||
|
||||||||
def add_clock_constraint(self, clock, frequency): | ||||||||
super().add_clock_constraint(clock, frequency) | ||||||||
clock.attrs["keep"] = "TRUE" | ||||||||
whitequark marked this conversation as resolved.
Show resolved
Hide resolved
whitequark marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||
|
||||||||
def create_missing_domain(self, name): | ||||||||
if name == "sync" and self.default_clk is not None: | ||||||||
m = Module() | ||||||||
if self.default_clk == "sys_clk0": | ||||||||
if not hasattr(self, "osc_div"): | ||||||||
raise ValueError("OSC divider (osc_div) must be an integer between 2 and 512") | ||||||||
if not isinstance(self.osc_div, int) or self.osc_div < 2 or self.osc_div > 512: | ||||||||
raise ValueError("OSC divider (osc_div) must be an integer between 2 and 512, not {!r}".format(self.osc_div)) | ||||||||
if not hasattr(self, "osc_freq"): | ||||||||
raise ValueError("OSC frequency (osc_freq) must be an integer between 2100000 and 80000000") | ||||||||
if not isinstance(self.osc_freq, int) or self.osc_freq < 2100000 or self.osc_freq > 80000000: | ||||||||
raise ValueError("OSC frequency (osc_freq) must be an integer between 2100000 and 80000000, not {!r}".format(self.osc_freq)) | ||||||||
clk_i = Signal() | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This doesn't look right--you aren't using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. From what I have read on their documentation for the CCGM1A1 Chip, there are no oscillators(ring or RC) on the chip. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Then you don't need any implementation of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removed |
||||||||
sys_clk0 = Signal() | ||||||||
m.submodules += Instance("qlal4s3b_cell_macro", o_Sys_Clk0=sys_clk0) | ||||||||
m.submodules += Instance("gclkbuff", o_A=sys_clk0, o_Z=clk_i) | ||||||||
else: | ||||||||
clk_i = self.request(self.default_clk).i | ||||||||
|
||||||||
if self.default_rst is not None: | ||||||||
rst_i = self.request(self.default_rst).i | ||||||||
else: | ||||||||
rst_i = Const(0) | ||||||||
|
||||||||
m.domains += ClockDomain("sync") | ||||||||
m.d.comb += ClockSignal("sync").eq(clk_i) | ||||||||
m.submodules.reset_sync = ResetSynchronizer(rst_i, domain="sync") | ||||||||
return m | ||||||||
|
Uh oh!
There was an error while loading. Please reload this page.