You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
110 lines
3.8 KiB
Python
110 lines
3.8 KiB
Python
3 years ago
|
from amaranth import *
|
||
|
from amaranth.build import *
|
||
2 years ago
|
from amaranth.lib.cdc import ResetSynchronizer
|
||
3 years ago
|
|
||
|
|
||
|
__all__ = ["SymbiYosysPlatform"]
|
||
|
|
||
|
|
||
|
class SymbiYosysPlatform(TemplatedPlatform):
|
||
|
"""
|
||
|
Required tools:
|
||
|
* ``yosys``
|
||
|
* ``sby``
|
||
|
|
||
3 years ago
|
Required tools for VHDL support (experimental):
|
||
3 years ago
|
* ``ghdl``
|
||
|
* ``ghdl-yosys-plugin``
|
||
|
|
||
|
Available overrides:
|
||
|
* ``sby_opts``: adds extra options for sby (default: "-f").
|
||
|
* ``sby_depth``: depth of the bounded model check in sby script.
|
||
|
* ``sby_skip``: number of skipped time steps in sby script.
|
||
|
* ``read_verilog_opts``: adds options for the ``read_verilog`` Yosys command.
|
||
|
* ``ghdl_opts``: adds options for the ``ghdl`` Yosys command.
|
||
|
* ``ghdl_top``: Top-level unit for the ``ghdl`` Yosys command (default: "top").
|
||
|
* ``prep_opts``: adds options for the ``prep`` Yosys command (default: "-flatten -nordff").
|
||
|
* ``script_before_read``: inserts commands before reading input files in Yosys script.
|
||
|
* ``script_after_read``: inserts command after reading input files in Yosys script.
|
||
2 years ago
|
* ``script_after_synth``: inserts command after ``prep`` in Yosys script.
|
||
3 years ago
|
|
||
|
Build products:
|
||
|
(TODO)
|
||
|
"""
|
||
|
toolchain = "oss-cad-suite"
|
||
|
|
||
|
required_tools = [
|
||
|
"yosys",
|
||
|
"sby",
|
||
|
]
|
||
|
file_templates = {
|
||
|
**TemplatedPlatform.build_script_templates,
|
||
|
"{{name}}.il": r"""
|
||
|
# {{autogenerated}}
|
||
|
{{emit_rtlil()}}
|
||
|
""",
|
||
|
"{{name}}.sby": r"""
|
||
|
# {{autogenerated}}
|
||
|
[options]
|
||
2 years ago
|
mode {{get_override("mode")|default("bmc")}}
|
||
3 years ago
|
expect pass,fail
|
||
|
append 0
|
||
3 years ago
|
depth {{get_override("depth")}}
|
||
|
skip {{get_override("skip")}}
|
||
3 years ago
|
|
||
|
[engines]
|
||
2 years ago
|
smtbmc boolector
|
||
3 years ago
|
|
||
|
[files]
|
||
|
{% for file in platform.iter_files(".il", ".v", ".sv", ".vhdl") -%}
|
||
|
{{file}}
|
||
|
{% endfor %}
|
||
|
{{name}}.il
|
||
|
|
||
|
[script]
|
||
|
{% if platform.iter_files(".vhdl")|first is defined -%}
|
||
|
plugin -i ghdl
|
||
|
{% endif %}
|
||
|
{{get_override("script_before_read")|default("# (script_before_read placeholder)")}}
|
||
|
{% for file in platform.iter_files(".il") -%}
|
||
|
read_ilang {{file}}
|
||
|
{% endfor %}
|
||
|
{% for file in platform.iter_files(".v", ".sv") -%}
|
||
|
read_verilog {{get_override("read_verilog_opts")|default("-sv")}} {{file}}
|
||
|
{% endfor %}
|
||
|
{% if platform.iter_files(".vhdl")|first is defined -%}
|
||
3 years ago
|
ghdl {{get_override("ghdl_opts")|options}} {{platform.iter_files(".vhdl")|join(" ")}} -e {{get_override("ghdl_top")|default("toplevel")}}
|
||
3 years ago
|
{% endif %}
|
||
|
read_ilang {{name}}.il
|
||
|
delete w:$verilog_initial_trigger
|
||
|
{{get_override("script_after_read")|default("# (script_after_read placeholder)")}}
|
||
2 years ago
|
prep {{get_override("prep_opts")|default("-nordff")}} -top {{name}}
|
||
|
{{get_override("script_after_synth")|default("# (script_after_synth placeholder)")}}
|
||
3 years ago
|
""",
|
||
|
}
|
||
|
command_templates = [
|
||
|
r"""
|
||
|
{{invoke_tool("sby")}}
|
||
|
{{get_override("sby_opts")|default("-f")}}
|
||
3 years ago
|
--yosys={{invoke_tool("yosys")}}
|
||
3 years ago
|
{{name}}.sby
|
||
|
""",
|
||
|
]
|
||
|
|
||
|
default_clk = "clk"
|
||
|
resources = [
|
||
|
Resource("clk", 0, Pins("clk", dir="i"), Clock(1e6)),
|
||
|
]
|
||
|
connectors = []
|
||
|
|
||
|
def create_missing_domain(self, name):
|
||
|
if name == "sync":
|
||
|
clk_i = self.request(self.default_clk).i
|
||
2 years ago
|
rst_i = Const(0)
|
||
|
|
||
|
m = Module()
|
||
3 years ago
|
m.domains.sync = ClockDomain("sync")
|
||
2 years ago
|
m.d.comb += ClockSignal("sync").eq(clk_i)
|
||
|
m.submodules.reset_sync = ResetSynchronizer(rst_i, domain="sync")
|
||
3 years ago
|
return m
|