@@ -207,11 +207,11 @@ def elaborate(self, platform):
207
207
208
208
class LatticePlatform (TemplatedPlatform ):
209
209
"""
210
- .. rubric:: Trellis toolchain (ECP5 only )
210
+ .. rubric:: Trellis toolchain (ECP5, MachXO2, MachXO3 )
211
211
212
212
Required tools:
213
213
* ``yosys``
214
- * ``nextpnr-ecp5``
214
+ * ``nextpnr-ecp5`` or ``nextpnr-machxo2``
215
215
* ``ecppack``
216
216
217
217
The environment is populated by running the script specified in the environment variable
@@ -220,11 +220,11 @@ class LatticePlatform(TemplatedPlatform):
220
220
Available overrides:
221
221
* ``verbose``: enables logging of informational messages to standard error.
222
222
* ``read_verilog_opts``: adds options for ``read_verilog`` Yosys command.
223
- * ``synth_opts``: adds options for ``synth_ecp5 `` Yosys command.
223
+ * ``synth_opts``: adds options for ``synth_<family> `` Yosys command.
224
224
* ``script_after_read``: inserts commands after ``read_ilang`` in Yosys script.
225
- * ``script_after_synth``: inserts commands after ``synth_ecp5 `` in Yosys script.
225
+ * ``script_after_synth``: inserts commands after ``synth_<family> `` in Yosys script.
226
226
* ``yosys_opts``: adds extra options for ``yosys``.
227
- * ``nextpnr_opts``: adds extra options for ``nextpnr-ecp5 ``.
227
+ * ``nextpnr_opts``: adds extra options for ``nextpnr-<family> ``.
228
228
* ``ecppack_opts``: adds extra options for ``ecppack``.
229
229
* ``add_preferences``: inserts commands at the end of the LPF file.
230
230
@@ -294,11 +294,16 @@ class LatticePlatform(TemplatedPlatform):
294
294
"BG756" : "caBGA756" ,
295
295
}
296
296
297
- _trellis_required_tools = [
297
+ _trellis_required_tools_ecp5 = [
298
298
"yosys" ,
299
299
"nextpnr-ecp5" ,
300
300
"ecppack"
301
301
]
302
+ _trellis_required_tools_machxo2 = [
303
+ "yosys" ,
304
+ "nextpnr-machxo2" ,
305
+ "ecppack"
306
+ ]
302
307
_trellis_file_templates = {
303
308
** TemplatedPlatform .build_script_templates ,
304
309
"{{name}}.il" : r"""
@@ -322,7 +327,11 @@ class LatticePlatform(TemplatedPlatform):
322
327
{% endfor %}
323
328
read_ilang {{name}}.il
324
329
{{get_override("script_after_read")|default("# (script_after_read placeholder)")}}
325
- synth_ecp5 {{get_override("synth_opts")|options}} -top {{name}}
330
+ {% if platform.family == "ecp5" %}
331
+ synth_ecp5 {{get_override("synth_opts")|options}} -top {{name}}
332
+ {% else %}
333
+ synth_lattice -family xo2 {{get_override("synth_opts")|options}} -top {{name}}
334
+ {% endif %}
326
335
{{get_override("script_after_synth")|default("# (script_after_synth placeholder)")}}
327
336
write_json {{name}}.json
328
337
""" ,
@@ -356,13 +365,17 @@ class LatticePlatform(TemplatedPlatform):
356
365
{{name}}.ys
357
366
""" ,
358
367
r"""
359
- {{invoke_tool("nextpnr-ecp5" )}}
368
+ {{invoke_tool("nextpnr-" + platform.family )}}
360
369
{{quiet("--quiet")}}
361
370
{{get_override("nextpnr_opts")|options}}
362
371
--log {{name}}.tim
363
- {{platform._nextpnr_device_options[platform.device]}}
364
- --package {{platform._nextpnr_package_options[platform.package]|upper}}
365
- --speed {{platform.speed}}
372
+ {% if platform.family == "ecp5" %}
373
+ {{platform._nextpnr_device_options[platform.device]}}
374
+ --package {{platform._nextpnr_package_options[platform.package]|upper}}
375
+ --speed {{platform.speed}}
376
+ {% else %}
377
+ --device {{platform.device}}-{{platform.speed}}{{platform.package}}{{platform.grade}}
378
+ {% endif %}
366
379
--json {{name}}.json
367
380
--lpf {{name}}.lpf
368
381
--textcfg {{name}}.config
@@ -422,7 +435,7 @@ class LatticePlatform(TemplatedPlatform):
422
435
prj_run Map -impl impl
423
436
prj_run PAR -impl impl
424
437
prj_run Export -impl impl -task Bitgen
425
- {% if family == "machxo2" -%}
438
+ {% if platform. family == "machxo2" -%}
426
439
prj_run Export -impl impl -task Jedecgen
427
440
{% endif %}
428
441
{{get_override("script_after_export")|default("# (script_after_export placeholder)")}}
@@ -523,7 +536,10 @@ def __init__(self, *, toolchain=None):
523
536
@property
524
537
def required_tools (self ):
525
538
if self .toolchain == "Trellis" :
526
- return self ._trellis_required_tools
539
+ if self .family == "ecp5" :
540
+ return self ._trellis_required_tools_ecp5
541
+ elif self .family == "machxo2" :
542
+ return self ._trellis_required_tools_machxo2
527
543
if self .toolchain == "Diamond" :
528
544
return self ._diamond_required_tools
529
545
assert False
0 commit comments