else:
return jinja2.Undefined(name=var)
+ def options(opts):
+ if isinstance(opts, str):
+ return opts
+ else:
+ return " ".join(opts)
+
def verbose(arg):
if "NMIGEN_verbose" in os.environ:
return arg
try:
source = textwrap.dedent(source).strip()
compiled = jinja2.Template(source, trim_blocks=True, lstrip_blocks=True)
+ compiled.environment.filters["options"] = options
except jinja2.TemplateSyntaxError as e:
e.args = ("{} (at {}:{})".format(e.message, origin, e.lineno),)
raise
"{{name}}.ys": r"""
# {{autogenerated}}
{% for file in platform.iter_extra_files(".v") -%}
- read_verilog {{get_override("read_opts")|join(" ")}} {{file}}
+ read_verilog {{get_override("read_opts")|options}} {{file}}
{% endfor %}
{% for file in platform.iter_extra_files(".sv") -%}
- read_verilog -sv {{get_override("read_opts")|join(" ")}} {{file}}
+ read_verilog -sv {{get_override("read_opts")|options}} {{file}}
{% endfor %}
read_ilang {{name}}.il
{{get_override("script_after_read")|default("# (script_after_read placeholder)")}}
- synth_ecp5 {{get_override("synth_opts")|join(" ")}} -top {{name}}
+ synth_ecp5 {{get_override("synth_opts")|options}} -top {{name}}
{{get_override("script_after_synth")|default("# (script_after_synth placeholder)")}}
write_json {{name}}.json
""",
r"""
{{get_tool("yosys")}}
{{quiet("-q")}}
- {{get_override("yosys_opts")|join(" ")}}
+ {{get_override("yosys_opts")|options}}
-l {{name}}.rpt
{{name}}.ys
""",
r"""
{{get_tool("nextpnr-ecp5")}}
{{quiet("--quiet")}}
- {{get_override("nextpnr_opts")|join(" ")}}
+ {{get_override("nextpnr_opts")|options}}
--log {{name}}.tim
{{platform._nextpnr_device_options[platform.device]}}
--package {{platform._nextpnr_package_options[platform.package]|upper}}
"{{name}}.ys": r"""
# {{autogenerated}}
{% for file in platform.iter_extra_files(".v") -%}
- read_verilog {{get_override("read_opts")|join(" ")}} {{file}}
+ read_verilog {{get_override("read_opts")|options}} {{file}}
{% endfor %}
{% for file in platform.iter_extra_files(".sv") -%}
- read_verilog -sv {{get_override("read_opts")|join(" ")}} {{file}}
+ read_verilog -sv {{get_override("read_opts")|options}} {{file}}
{% endfor %}
read_ilang {{name}}.il
{{get_override("script_after_read")|default("# (script_after_read placeholder)")}}
- synth_ice40 {{get_override("synth_opts")|join(" ")}} -top {{name}}
+ synth_ice40 {{get_override("synth_opts")|options}} -top {{name}}
{{get_override("script_after_synth")|default("# (script_after_synth placeholder)")}}
write_json {{name}}.json
""",
r"""
{{get_tool("yosys")}}
{{quiet("-q")}}
- {{get_override("yosys_opts")|join(" ")}}
+ {{get_override("yosys_opts")|options}}
-l {{name}}.rpt
{{name}}.ys
""",
r"""
{{get_tool("nextpnr-ice40")}}
{{quiet("--quiet")}}
- {{get_override("nextpnr_opts")|default(["--placer","heap"])|join(" ")}}
+ {{get_override("nextpnr_opts")|default(["--placer","heap"])|options}}
--log {{name}}.tim
{{platform._nextpnr_device_options[platform.device]}}
--package
r"""
{{get_tool("vivado")}}
{{verbose("-verbose")}}
- {{get_override("vivado_opts")|join(" ")}}
+ {{get_override("vivado_opts")|options}}
-mode batch
-log {{name}}.log
-source {{name}}.tcl
command_templates = [
r"""
{{get_tool("xst")}}
- {{get_override("xst_opts")|join(" ")}}
+ {{get_override("xst_opts")|options}}
-ifn {{name}}.xst
""",
r"""
{{get_tool("ngdbuild")}}
{{quiet("-quiet")}}
{{verbose("-verbose")}}
- {{get_override("ngdbuild_opts")|join(" ")}}
+ {{get_override("ngdbuild_opts")|options}}
-uc {{name}}.ucf
{{name}}.ngc
""",
r"""
{{get_tool("map")}}
{{verbose("-detail")}}
- {{get_override("map_opts")|default(["-w"])|join(" ")}}
+ {{get_override("map_opts")|default(["-w"])|options}}
-o {{name}}_map.ncd
{{name}}.ngd
{{name}}.pcf
""",
r"""
{{get_tool("par")}}
- {{get_override("par_opts")|default(["-w"])|join(" ")}}
+ {{get_override("par_opts")|default(["-w"])|options}}
{{name}}_map.ncd
{{name}}_par.ncd
{{name}}.pcf
""",
r"""
{{get_tool("bitgen")}}
- {{get_override("bitgen_opts")|default(["-w"])|join(" ")}}
+ {{get_override("bitgen_opts")|default(["-w"])|options}}
{{name}}_par.ncd
{{name}}.bit
"""