.. _lattice:

Lattice notes
#############

MachXO2/MachXO3
===============

Flash memory
------------

``.jed`` file is the default format generated by *Lattice Diamond*, so nothing special must be done to generates this
file.

File load:

.. code-block:: bash

    openFPGALoader [-b yourboard] [--flash-sector CFG0] impl1/*.jed

where ``yourboard`` may be:

* ``machX02EVN``
* ``machX03EVN``
* ``machXO3SK``

and where ``--flash-sector CFG0`` is needed for the MachXO3D Breakout Board.

``.bit`` may also be used for *machXO2*

SRAM
----

To generates ``.bit`` file *Bitstream file* must be checked under *Exports Files* in *Lattice Diamond* left panel.

File load:

.. code-block:: bash

    openFPGALoader [-b yourboard] impl1/*.bit

where ``yourboard`` may be:

* ``machX02EVN``
* ``machX03EVN``
* ``machXO3SK``

iCE40
=====

``.bin`` is the default format generated by *nextpnr*, so nothing special must be done.

Since most ice40 boards uses the same pinout between *FTDI* and *SPI flash* a generic *ice40_generic* board is provided.

For the specific case of the *iCE40HXXK-EVB* where no onboard programmer is present, please use this:

============= ===============
     FTDI      iCE40HXXK-EVB
============= ===============
SI  (ADBUS1)  Pin 8
SCK (ADBUS0)  Pin 9
SO  (ADBUS2)  Pin 7
CS  (ABDUS4)  Pin 10
RST (ADBUS6   Pin 6
DONE (ADBUS7) Pin 5
============= ===============

Bin file load:

.. code-block:: bash

    openFPGALoader -b ice40_generic /somewhere/*.bin

Since it's a direct access to the flash (SPI) the ``-b`` option is required.

ECP5/Crosslink-NX
=================

SRAM
----

.. code-block:: bash

    openFPGALoader [-b yourBoard] [-c yourCable] -m project_name/*.bit

.. HINT::
  By default, openFPGALoader loads bitstream in memory, so the ``-m`` argument is optional.

SPI Flash
---------

BIT:

.. code-block:: bash

    openFPGALoader [-b yourBoard] [-c yourCable] -f project_name/*.bit # or *.bin

MCS:

To generate ``.mcs`` file *PROM File* must be checked under *Exports Files* in *Lattice Diamond* left panel.

.. code-block:: bash

    openFPGALoader [-b yourBoard] [-c yourCable] project_name/*.mcs
