FPGA TN 02001 3 4 ICE40 Programming Configuration
FPGA TN 02001 3 4 ICE40 Programming Configuration
Technical Note
FPGA-TN-02001-3.4
December 2022
iCE40 Programming and Configuration
Technical Note
Disclaimers
Lattice makes no warranty, representation, or guarantee regarding the accuracy of information contained in this document or the suitability of its
products for any particular purpose. All information herein is provided AS IS, with all faults and associated risk the responsibility entirely of the Buyer.
Buyer shall not rely on any data and performance specifications or parameters provided herein. Products sold by Lattice have been subject to limited
testing and it is the Buyer's responsibility to independently determine the suitability of any products and to test and verify the same. No Lattice
products should be used in conjunction with mission- or safety-critical or any other application in which the failure of Lattice’s product could create a
situation where personal injury, death, severe property or environmental damage may occur. The information provided in this document is
proprietary to Lattice Semiconductor, and Lattice reserves the right to make any changes to the information in this document or to any products at
any time without notice.
© 2018-2022 Lattice Semiconductor Corp. All Lattice trademarks, registered trademarks, patents, and disclaimers are as listed at www.latticesemi.com/legal.
All other brand or product names are trademarks or registered trademarks of their respective holders. The specifications and information herein are subject to change without notice.
2 FPGA-TN-02001-3.4
iCE40 Programming and Configuration
Technical Note
Contents
Acronyms in This Document ................................................................................................................................6
1. Introduction ..................................................................................................................................................7
2. Configuration Overview ................................................................................................................................8
3. Configuration Mode Selection.................................................................................................................... 10
3.1. Mode Selection for iCE40 LP/HX, iCE40 Ultra, iCE40 UltraLite and iCE40 UltraPlus Devices.............. 10
3.2. Mode Selection for iCE40 LM ............................................................................................................ 11
4. Non-Volatile Configuration Memory .......................................................................................................... 13
4.1. NVCM Programming ......................................................................................................................... 13
5. Configuration Control Signals ..................................................................................................................... 14
6. Internal Oscillator....................................................................................................................................... 16
7. Internal Device Reset ................................................................................................................................. 17
7.1. Power-On Reset ................................................................................................................................ 17
7.2. CRESET_B Pin .................................................................................................................................... 17
8. sysCONFIG Port .......................................................................................................................................... 18
8.1. sysCONFIG Pins .................................................................................................................................. 18
9. SPI Master Configuration Interface ............................................................................................................ 19
9.1. SPI Master Configuration Mode Timing Considerations ................................................................... 19
9.2. SPI PROM Requirements ................................................................................................................... 20
9.3. Enabling SPI Configuration Interface ................................................................................................ 21
9.4. SPI Master Configuration Process ..................................................................................................... 21
10. Cold Boot Configuration Option................................................................................................................. 24
11. Warm Boot Configuration Option .............................................................................................................. 27
12. Time-Out and Retry .................................................................................................................................... 28
13. SPI Slave Configuration Interface ............................................................................................................... 29
13.1. Enabling SPI Configuration Interface ................................................................................................ 30
13.2. SPI Slave Configuration Process ........................................................................................................ 30
13.3. Voltage Compatibility ........................................................................................................................ 33
Appendix A. SPI Slave Configuration Procedure ............................................................................................... 34
A.1. CPU Configuration Procedure ................................................................................................................ 34
A.2. Configuration Waveforms ...................................................................................................................... 34
A.3. Pseudo Code .......................................................................................................................................... 36
Appendix B. Configuration Data Format ........................................................................................................... 38
References ........................................................................................................................................................ 39
Technical Support Assistance ............................................................................................................................. 40
Revision History ................................................................................................................................................ 41
© 2018-2022 Lattice Semiconductor Corp. All Lattice trademarks, registered trademarks, patents, and disclaimers are as listed at www.latticesemi.com/legal.
All other brand or product names are trademarks or registered trademarks of their respective holders. The specifications and information herein are subject to change without notice.
FPGA-TN-02001-3.4 3
iCE40 Programming and Configuration
Technical Note
Figures
Figure 2.1. Configuring and Programming the iCE40 Device .................................................................................................8
Figure 3.1. iCE40 Device Configuration Control Flow ..........................................................................................................11
Figure 3.2. iCE40 LM Device Configuration Control Flow ....................................................................................................12
Figure 5.1. iCE40 Configuration Control Pins ......................................................................................................................14
Figure 7.1. iCE40 Internal Reset Circuitry ...........................................................................................................................17
Figure 9.1. iCE40 SPI Master Configuration Interface ..........................................................................................................19
Figure 9.2. SPI Master Configuration Timing .......................................................................................................................20
Figure 9.3. SPI Release from Deep Power-down Command ................................................................................................22
Figure 9.4. SPI Fast Read Command ....................................................................................................................................22
Figure 9.5. Final Configuration Data, SPI Deep Power-down Command .............................................................................23
Figure 10.1. Cold Boot and Warm Boot Configuration ........................................................................................................24
Figure 10.2. Diamond Deployment Tool – Advanced SPI Flash Options ..............................................................................25
Figure 11.1. Enable Warm Boot Option...............................................................................................................................27
Figure 13.1. iCE40 SPI Slave Configuration Interface ..........................................................................................................29
Figure 13.2. Application Processor Waveforms for SPI Peripheral Mode Configuration Process ........................................31
Figure 13.3. SPI Slave Configuration Process.......................................................................................................................32
© 2018-2022 Lattice Semiconductor Corp. All Lattice trademarks, registered trademarks, patents, and disclaimers are as listed at www.latticesemi.com/legal.
All other brand or product names are trademarks or registered trademarks of their respective holders. The specifications and information herein are subject to change without notice.
4 FPGA-TN-02001-3.4
iCE40 Programming and Configuration
Technical Note
Tables
Table 1.1. iCE40 Devices Configuration Features Comparison ............................................................................................. 7
Table 2.1. Single-Ended I/O Standards ................................................................................................................................. 8
Table 5.1. iCE40 Configuration Control Signals ................................................................................................................... 14
Table 7.1. Power-On Reset Voltage Resources .................................................................................................................... 17
Table 8.1. sysCONFIG Ports ................................................................................................................................................. 18
Table 8.2. sysCONFIG Pins................................................................................................................................................... 18
Table 9.1. SPI Master Configuration Interface Pins (SPI_SS High Before Configuration) ..................................................... 19
Table 9.2. Bitstream Sizes for Different iCE40 FPGA Densities Used to Select a SPI Flash ................................................... 21
Table 10.1. CBSEL[1:0] Vector Address ............................................................................................................................... 25
Table 13.1. SPI Slave Configuration Interface Pins (SPI_SS Low when CRESET_B Released)................................................ 30
Table 13.2. SPI Peripheral Mode Supply Voltages ............................................................................................................... 33
Table 13.3. CRESET_B and CDONE Voltage Compatibility ................................................................................................... 33
Table A.1. iCE40 SRAM Configuration Sequence................................................................................................................. 34
Table B.1. Configuration Data ............................................................................................................................................. 38
© 2018-2022 Lattice Semiconductor Corp. All Lattice trademarks, registered trademarks, patents, and disclaimers are as listed at www.latticesemi.com/legal.
All other brand or product names are trademarks or registered trademarks of their respective holders. The specifications and information herein are subject to change without notice.
FPGA-TN-02001-3.4 5
iCE40 Programming and Configuration
Technical Note
© 2018-2022 Lattice Semiconductor Corp. All Lattice trademarks, registered trademarks, patents, and disclaimers are as listed at www.latticesemi.com/legal.
All other brand or product names are trademarks or registered trademarks of their respective holders. The specifications and information herein are subject to change without notice.
6 FPGA-TN-02001-3.4
iCE40 Programming and Configuration
Technical Note
1. Introduction
The iCE40™ devices are SRAM-based FPGAs. The iCE40 LP, iCE40 HX, iCE40 Ultra™, iCE40 UltraLite™, and iCE40
UltraPlus™ devices also have an on-chip, one-time programmable NVCM (Non-Volatile Configuration Memory) to store
configuration data. The SRAM memory cells are volatile, meaning that once power is removed from the device, its
configuration is lost, and must be reloaded on the next power-up. This behavior has the advantage of being
re-programmable in the field which provides flexibility for products already deployed to the field. But it also requires
that the configuration information be stored in a non-volatile device and loaded each time power is applied to the
device. The on-chip NVCM allows the device to configure instantly and greatly enhances the design security by
eliminating the need to use an external memory device. The configuration data can also be stored in an external SPI
Flash from which the FPGA can configure itself upon power-up. This is useful for prototyping the FPGA or in situations
where reconfigurability is required. Additionally, the device can be configured by a processor in an embedded
environment.
Table 1.1. iCE40 Devices Configuration Features Comparison
Features iCE40 LM iCE40 LP/iCE40 HX/iCE40 Ultra/iCE40 UltraLite/iCE40 UltraPlus
NVCM (one time programmable) — Yes
Multiple Configuration Image — Yes
Master SPI Configuration Mode Yes Yes
Slave SPI Configuration Mode Yes Yes
© 2018-2022 Lattice Semiconductor Corp. All Lattice trademarks, registered trademarks, patents, and disclaimers are as listed at www.latticesemi.com/legal.
All other brand or product names are trademarks or registered trademarks of their respective holders. The specifications and information herein are subject to change without notice.
FPGA-TN-02001-3.4 7
iCE40 Programming and Configuration
Technical Note
2. Configuration Overview
The iCE40 devices contain two types of memory, SRAM and NVCM (one-time programmable). The iCE40 LM devices,
however, contain only one type of memory, which is SRAM. The SRAM memory contains the active configuration. The
NVCM and the external SPI Flash provides a non-volatile storage for the configuration data. Additionally, the iCE40
configuration data can be downloaded from an external processor, microcontroller, or Digital Signal Processor (DSP)
processor using the SPI interface. In this document, the term programming refers to the programming of the NVCM
and the term configuration refers to the configuration of SRAM memory. For either programming or configuration, the
iCE40 FPGA utilizes the SPI configuration interface.
As described in Table 2.1, iCE40 components are configured for a specific application by loading a binary configuration
bitstream image, generated by the Lattice development system. For high-volume applications, the bitstream image is
usually permanently programmed in the on-chip Non-volatile Configuration Memory. However, the bitstream image
can also be stored externally in a standard, low-cost commodity SPI serial Flash PROM. The iCE40 component can
automatically load the image using the SPI Master Configuration Interface. Similarly, the iCE40 configuration data can
be downloaded from an external processor, microcontroller, or DSP using an SPI-like serial interface.
Table 2.1. Single-Ended I/O Standards
Mode Analogy Configuration Data Source
NVCM1 ASIC Internal, lowest-cost, secure, one-time programmable NVCM.
Master SPI Microprocessor External, low-cost, commodity, SPI serial Flash PROM.
Slave SPI Processor Peripheral Configured by external device, such as a processor, microcontroller, or DSP using practically
any data source, such as system Flash, a disk image, or over a network connection.
Note:
1. iCE40 LP, iCE40 HX, iCE40 Ultra, iCE40 UltraLite and iCE40 UltraPlus devices only.
Figure 2.1 provides an overview of the configuration and programming of the iCE40 FPGA. For configuration and
programming, the device can be accessed using the SPI interface/protocol described in later sections of this technical
note. The SRAM can configure itself (device in master mode) from the on-chip NVCM (iCE40 LP, ICE40 HX, iCE40 Ultra,
iCE40 UltraLite and iCE40 UltraPlus devices only), external SPI Flash or Lattice programming hardware. An external
processor or programming hardware can also configure the SRAM with the FPGA in slave SPI mode. The NVCM can be
programmed using the Lattice Diamond® Programmer (version 2.2 or later) or an external processor.
Third-Party USB-to-Serial
Convertor/
Lattice Programming Tool
SPI Port
NVCM
(iCE40 LP, ICE40 HX,
iCE40 Ultra, iCE40 UltraLite SRAM Memory Space
and iCE40 UltraPlus only)
© 2018-2022 Lattice Semiconductor Corp. All Lattice trademarks, registered trademarks, patents, and disclaimers are as listed at www.latticesemi.com/legal.
All other brand or product names are trademarks or registered trademarks of their respective holders. The specifications and information herein are subject to change without notice.
8 FPGA-TN-02001-3.4
iCE40 Programming and Configuration
Technical Note
© 2018-2022 Lattice Semiconductor Corp. All Lattice trademarks, registered trademarks, patents, and disclaimers are as listed at www.latticesemi.com/legal.
All other brand or product names are trademarks or registered trademarks of their respective holders. The specifications and information herein are subject to change without notice.
FPGA-TN-02001-3.4 9
iCE40 Programming and Configuration
Technical Note
3.1. Mode Selection for iCE40 LP/HX, iCE40 Ultra, iCE40 UltraLite and iCE40
UltraPlus Devices
The iCE40 LP/HX, iCE40 Ultra, iCE40 UltraLite and iCE40 UltraPlus device configuration mode is selected according to
the following priority described below and illustrated in Figure 3.1.
After exiting the Power-On Reset state or when CRESET_B returns High after being held Low, the iCE40 device
samples the logical value on its SPI_SS pin. Like other programmable I/O pins, the SPI_SS pin has an internal pullup
resistor. Refer to iCE40 LP/HX Family Data Sheet (FPGA-DS-02029) for the minimum pulse width requirement of
CRESET_B.
If the SPI_SS pin is sampled as a logic ‘1’ (High), then …
Check if the device is enabled to configure from the NVCM. If the NVCM is programmed, the device configures
from NVCM.
If enabled to configure from NVCM, the device configures itself using the NVCM.
If not enabled to configure from NVCM, then the device configures using the SPI Master Configuration
Interface.
If the SPI_SS pin is sampled as a logic ‘0’ (Low), then the device waits to be configured from an external controller
or from another device in SPI Master Configuration Mode using an SPI-like interface.
© 2018-2022 Lattice Semiconductor Corp. All Lattice trademarks, registered trademarks, patents, and disclaimers are as listed at www.latticesemi.com/legal.
All other brand or product names are trademarks or registered trademarks of their respective holders. The specifications and information herein are subject to change without notice.
10 FPGA-TN-02001-3.4
iCE40 Programming and Configuration
Technical Note
Power-Up
CDON E = 0
Yes
State of SPI_SS
Yes
pin sampled
A d evice with an
Yes unp rogrammed NVCM is not
enabled for configuration.
NVCM Enabled for Yes Con figure from
Con figuration? NVCM
No
Configure from
SPI Flash PROM
CDON E = 1
Yes
© 2018-2022 Lattice Semiconductor Corp. All Lattice trademarks, registered trademarks, patents, and disclaimers are as listed at www.latticesemi.com/legal.
All other brand or product names are trademarks or registered trademarks of their respective holders. The specifications and information herein are subject to change without notice.
FPGA-TN-02001-3.4 11
iCE40 Programming and Configuration
Technical Note
Power-Up
CDON E = 0
Yes
Holding CRESET_B Low
No delays the start of
CRESET_B = High? configuration.
No Configure as SPI
SPI_SS = High?
Peripheral
Configure from
SPI Flash PROM
CDON E = 1
Yes
© 2018-2022 Lattice Semiconductor Corp. All Lattice trademarks, registered trademarks, patents, and disclaimers are as listed at www.latticesemi.com/legal.
All other brand or product names are trademarks or registered trademarks of their respective holders. The specifications and information herein are subject to change without notice.
12 FPGA-TN-02001-3.4
iCE40 Programming and Configuration
Technical Note
© 2018-2022 Lattice Semiconductor Corp. All Lattice trademarks, registered trademarks, patents, and disclaimers are as listed at www.latticesemi.com/legal.
All other brand or product names are trademarks or registered trademarks of their respective holders. The specifications and information herein are subject to change without notice.
FPGA-TN-02001-3.4 13
iCE40 Programming and Configuration
Technical Note
I/O Bank 2
10 k R k (Refer to calculation bel ow)
CRESET_B CDONE
Rising edge starts
configuration process Configured
PIOs activat e 49
Pulse configuration clock
CRESET_B cycles after CDONE
Low Low resets iCE40 Unconfigured
goes High.
Figure 5.1. iCE40 Configuration Control Pins
Figure 5.1 shows the two iCE40 configuration control pins — CRESET_B and CDONE. When driven Low, the dedicated
Configuration Reset input, CRESET_B, resets the iCE40 device. When CRESET_B returns High, the iCE40 FPGA restarts
the configuration process from its power-on conditions (Cold Boot). The CRESET_B pin is a pure input with no internal
pullup resistor. If driven by open-drain driver or un-driven, then connect the CRESET_B pin to a 10 kΩ pullup resistor
connected to the designated VCCIO supply.
© 2018-2022 Lattice Semiconductor Corp. All Lattice trademarks, registered trademarks, patents, and disclaimers are as listed at www.latticesemi.com/legal.
All other brand or product names are trademarks or registered trademarks of their respective holders. The specifications and information herein are subject to change without notice.
14 FPGA-TN-02001-3.4
iCE40 Programming and Configuration
Technical Note
The iCE40 device signals the end of the configuration process by actively turning off the internal pulldown transistor on
the Configuration Done output pin, CDONE. The pin has a permanent, weak internal pullup resistor to the designated
VCCIO rail. However, for iCE40 LX/HX devices depending on the system capacitance and configuration frequency, the
CDONE pin must be tied to an external pullup resistor connected to the VCCIO_2 supply. The maximum resistor size can
be calculated knowing the configuration clock frequency (SCLK or MCLK) and the CDONE trace capacitance with the
following formula:
Rpullup=1/(2*ConfigFrequency*CDONETraceCap)
The PIO pins activate according to their configured function after 49 configuration clock cycles. The internal oscillator is
the configuration clock source for the SPI Master Configuration Interface and when configuring from NVCM. When
using the SPI Peripheral Configuration Interface, the configuration clock source is the SPI_SCK clock input pin.
© 2018-2022 Lattice Semiconductor Corp. All Lattice trademarks, registered trademarks, patents, and disclaimers are as listed at www.latticesemi.com/legal.
All other brand or product names are trademarks or registered trademarks of their respective holders. The specifications and information herein are subject to change without notice.
FPGA-TN-02001-3.4 15
iCE40 Programming and Configuration
Technical Note
6. Internal Oscillator
During SPI Master or NVCM (iCE40 LP, iCE40 HX, iCE40 Ultra, iCE40 UltraLite, and iCE40 UltraPlus only) configuration
mode, the controlling clock signal is generated from an internal oscillator. The oscillator starts operating at the default
frequency. During the configuration process, however, bit settings within the configuration bitstream can specify a
higher-frequency mode in order to maximize SPI bandwidth and reduce overall configuration time. Refer to the data
sheet for the specified oscillator frequency range.
Using the SPI Master Configuration Interface, internal oscillator controls all the interface timing and clocks the SPI serial
Flash PROM via the SPI_SCK clock output pin.
The oscillator output, which also supplies the SPI SCK clock output during the SPI Flash configuration process, has a 50%
duty cycle.
The Oscillator settings can be found in the iCEcube™ software by selecting the Tools > Tool Options pulldown menu and
then the Bitstream tab.
© 2018-2022 Lattice Semiconductor Corp. All Lattice trademarks, registered trademarks, patents, and disclaimers are as listed at www.latticesemi.com/legal.
All other brand or product names are trademarks or registered trademarks of their respective holders. The specifications and information herein are subject to change without notice.
16 FPGA-TN-02001-3.4
iCE40 Programming and Configuration
Technical Note
Internal
Device Pins Power-on
Voltage
Reset (POR)
Thresholds
VCC_SPI
SPI_VCCT
VCC
VCCT
Time-out
VCCIO_0*
Delay
VCCIO_2T
VCCIO_2
VCCIO_2T
VPP_2V5
Internal Reset
VPP_2V5T
© 2018-2022 Lattice Semiconductor Corp. All Lattice trademarks, registered trademarks, patents, and disclaimers are as listed at www.latticesemi.com/legal.
All other brand or product names are trademarks or registered trademarks of their respective holders. The specifications and information herein are subject to change without notice.
FPGA-TN-02001-3.4 17
iCE40 Programming and Configuration
Technical Note
8. sysCONFIG Port
The sysCONFIG port is used to program and configure the iCE40 FPGA. The device has a SPI configuration interface as
the sysCONFIG port which can be used to configure the device.
Table 8.1. sysCONFIG Ports
Interface Port Description
sysCONFIG SPI Master Configuration In this mode, the FPGA configures itself from an external SPI Flash. The FPGA
interface behaves as master, generates internal clock and drives the clock to the external SPI
Flash.
SPI Slave Configuration In this mode, the FPGA behaves as a Slave device. An external Application
interface Processor, µC or Diamond Programmer (version 2.2 or later) configures or
programs the device.
© 2018-2022 Lattice Semiconductor Corp. All Lattice trademarks, registered trademarks, patents, and disclaimers are as listed at www.latticesemi.com/legal.
All other brand or product names are trademarks or registered trademarks of their respective holders. The specifications and information herein are subject to change without notice.
18 FPGA-TN-02001-3.4
iCE40 Programming and Configuration
Technical Note
+3.3 V
VCC_SPI
10 k
SPI_SO
iCE40 SPI_SI
(SPI bank)
Commodity SPI
SPI_SS Serial Flash
PROM
SPI_SCK
The SPI configuration interface is used primarily during development before mass production, where the configuration
is then permanently programmed in the NVCM configuration memory (only available in iCE40 LP, iCE40 HX, iCE40 Ultra,
iCE40 UltraLite and iCE40 UltraPlus devices). However, the SPI interface can also be the primary configuration interface
allowing easy in-system upgrades and support for multiple configuration images.
The SPI control signals are defined in Table 9.1.
Table 9.1. SPI Master Configuration Interface Pins (SPI_SS High Before Configuration)
Signal Name Direction Description
VCC_SPI Supply SPI Flash PROM voltage supply input.
SPI_SO Output SPI Serial Output from the iCE40 device.
SPI_SI Input SPI Serial Input to the iCE40 device, driven by the select SPI serial Flash PROM.
SPI_SS Output SPI Slave Select output from the iCE40 device. Active Low.
SPI_SCK Output SPI Slave Clock output from the iCE40 device.
After configuration, the SPI port pins are available to the user-application as additional PIO pins, supplied by the
VCC_SPI input voltage.
© 2018-2022 Lattice Semiconductor Corp. All Lattice trademarks, registered trademarks, patents, and disclaimers are as listed at www.latticesemi.com/legal.
All other brand or product names are trademarks or registered trademarks of their respective holders. The specifications and information herein are subject to change without notice.
FPGA-TN-02001-3.4 19
iCE40 Programming and Configuration
Technical Note
Flight Time
SPI_SCK (output)
tSU tSU
tH D tH D
SPI_SI (input)
SPI_SI (input)
© 2018-2022 Lattice Semiconductor Corp. All Lattice trademarks, registered trademarks, patents, and disclaimers are as listed at www.latticesemi.com/legal.
All other brand or product names are trademarks or registered trademarks of their respective holders. The specifications and information herein are subject to change without notice.
20 FPGA-TN-02001-3.4
iCE40 Programming and Configuration
Technical Note
Table 9.2. Bitstream Sizes for Different iCE40 FPGA Densities Used to Select a SPI Flash
Device Bytes Bits
iCE40-LP 384 7417 59336
iCE40-LP 640 32306 258448
iCE40-LP/HX 1K 32303 258424
iCE40-LP/HX 4K 135183 1081464
iCE40-LP/HX 8K 135183 1081464
iCE40LM 1K 68177 545416
iCE40LM 2K 68177 545416
iCE40LM 4K 68176 545408
iCE5LP 1K 71342 570736
iCE5LP 2K 71342 570736
iCE5LP 4K 71342 570736
iCE40UL 640 30942 247536
iCE40UL 1K 30942 247536
iCE40UP 3K 104161 833288
iCE40UP 5K 104161 833288
© 2018-2022 Lattice Semiconductor Corp. All Lattice trademarks, registered trademarks, patents, and disclaimers are as listed at www.latticesemi.com/legal.
All other brand or product names are trademarks or registered trademarks of their respective holders. The specifications and information herein are subject to change without notice.
FPGA-TN-02001-3.4 21
iCE40 Programming and Configuration
Technical Note
SPI_SCK
SPI_SS
SPI_SO 1 0 1 0 1 0 1 1
0xAB
Re lea se from De ep Power-down
Figure 9.4 illustrates the next command issued by the iCE40 device. The iCE40 SPI interface again drives SPI_SS Low,
followed by a Fast Read command, hexadecimal command code 0x0B, followed by a 24-bit start address, transmitted
on the SPI_SO output. The iCE40 device provides data on the falling edge of SPI_SS. Upon initial power-up, the start
address is always 0x00_0000. After waiting eight additional clock cycles, the iCE40 device begins reading serial data
from the SPI PROM. Before presenting data, the SPI PROM serial data output is high-impedance. The SPI_SI input pin
has an internal pullup resistor and sees high-impedance as logic 1.
SPI_SCK
SPI_SS
SPI_SO
A18
A23
A22
A21
A20
A19
A17
A16
A15
A14
A13
A12
A11
A10
A8
A6
A4
A3
A2
A1
A9
A7
A5
0 0 0 0 1 0 1 1 X X X X X X X X
A0
D5
D3
D7
D6
D4
D2
D1
D0
D6
Data Byte 0
The external SPI PROM supplies data on the falling edge of the iCE40 device SPI_SCK clock output. The iCE40 device
captures each PROM data value on the SPI_SI input, using the rising edge of the SPI_SCK clock signal. The SPI PROM
data starts at the 24-bit address presented by the iCE40 device. PROM data is serially output, byte by byte, with the
most-significant bit, D7, presented first. The PROM automatically increments an internal byte counter as long as the
PROM is selected and clocked.
After transferring the required number of configuration data bits, the iCE40 device ends the Fast Read command by
de-asserting its SPI_SS PROM select output, as shown in Figure 9.5. To conserve power, the iCE40 device then
optionally issues a final Deep Power-down command, hexadecimal command code 0xB9. After de-asserting the SPI_SS
output, the SPI PROM enters its Deep Power-down mode. The final power-down step is optional; the application may
wish to use the SPI PROM and can skip this step, controlled by a configuration option.
© 2018-2022 Lattice Semiconductor Corp. All Lattice trademarks, registered trademarks, patents, and disclaimers are as listed at www.latticesemi.com/legal.
All other brand or product names are trademarks or registered trademarks of their respective holders. The specifications and information herein are subject to change without notice.
22 FPGA-TN-02001-3.4
iCE40 Programming and Configuration
Technical Note
SPI_SCK
SPI_SS
SPI_SO 1 0 1 1 1 0 0 1
0xB9
Deep Power-down
D7
D5
D4
D3
D2
D1
D0
D6
SPI_SI
© 2018-2022 Lattice Semiconductor Corp. All Lattice trademarks, registered trademarks, patents, and disclaimers are as listed at www.latticesemi.com/legal.
All other brand or product names are trademarks or registered trademarks of their respective holders. The specifications and information herein are subject to change without notice.
FPGA-TN-02001-3.4 23
iCE40 Programming and Configuration
Technical Note
At power-up or
after reset
CBSEL1 Jump based
on settings Enable/Disable Cold Boot
Cold/Warm Boot
CBSEL0 Enable/Disable Warm Boot
Cold Boot Applet
Control Jump Vector Addresses (4)
CRESET_B
Vector Address 0
Configuration
Power-On Image 0
Reset (0, 0)
SB_WARMBOOT
S1 Vector Address 1
S0 Configuration
Warm Image 1
(0, 1)
Boot
BOOT Control
Vector Address 2
Controlled by Configuration
currently loaded (1, 0) Image 2
iCE40 application
Vector Address 3
Configuration
(1, 1) Image 3
SPI PROM
When self-loading from an SPI Flash PROM, the FPGA supports an additional configuration option called Cold Boot
mode. This option can be implemented by creating an applet from Deployment Tool as shown in Figure 10.2. When this
option is enabled in the applet, the iCE40 FPGA boots normally from power-on or a master reset (CRESET_B = Low
pulse), but monitors the value on two PIO pins that are borrowed during configuration, as shown in Figure 10.1. These
pins, labeled PIO2/CBSEL0 and PIO2/CBSEL1, tell the FPGA which of the four possible SPI configurations to load into the
device.
© 2018-2022 Lattice Semiconductor Corp. All Lattice trademarks, registered trademarks, patents, and disclaimers are as listed at www.latticesemi.com/legal.
All other brand or product names are trademarks or registered trademarks of their respective holders. The specifications and information herein are subject to change without notice.
24 FPGA-TN-02001-3.4
iCE40 Programming and Configuration
Technical Note
For Cold Boot or Warm Boot applications, the initial configuration image must be stored at SPI Flash PROM and the
cold boot/warm boot applet must be stored at SPI Flash PROM address 0.
Check if Cold Boot configuration feature is enabled in the applet.
If Cold Boot is not enabled, the FPGA configuration starts from the default location (image 0) defined in the
Warm Boot applet.
If Cold Boot is enabled, the FPGA reads the logic values on pins CBSEL[1:0]. The FPGA uses the value as a vector
and then reads from the indicated vector address.
At the selected CBSEL[1:0] vector address, there is a starting address for the selected configuration image.
For SPI Flash PROMs, the new address is a 24-bit start address in Flash.
Table 10.1. CBSEL[1:0] Vector Address
CBSEL[1:0] Vector Address
00 0
01 1
10 2
11 3
Using the new start address, the FPGA restarts reading configuration memory from the new location.
© 2018-2022 Lattice Semiconductor Corp. All Lattice trademarks, registered trademarks, patents, and disclaimers are as listed at www.latticesemi.com/legal.
All other brand or product names are trademarks or registered trademarks of their respective holders. The specifications and information herein are subject to change without notice.
FPGA-TN-02001-3.4 25
iCE40 Programming and Configuration
Technical Note
When creating the initial configuration image, the Lattice development software loads the start address for up to four
configuration images in the multiple combined bitstreams. The multiple combined bitstreams are stored in the SPI
flash. The value on the CBSEL[1:0] pins tells the configuration controller to read a specific start address, then to load
the configuration image stored at the selected address.
After configuration, the CBSEL[1:0] pins become normal PIO pins available to the application.
The Cold Boot feature allows the iCE40 to be reprogrammed for special application requirements such as the following.
A normal operating mode and a self-test or diagnostics mode.
Different applications based on switch settings.
Different applications based on a card-slot ID number. Use external SPI Flash PROMs only.
© 2018-2022 Lattice Semiconductor Corp. All Lattice trademarks, registered trademarks, patents, and disclaimers are as listed at www.latticesemi.com/legal.
All other brand or product names are trademarks or registered trademarks of their respective holders. The specifications and information herein are subject to change without notice.
26 FPGA-TN-02001-3.4
iCE40 Programming and Configuration
Technical Note
A special design primitive, SB_WARMBOOT, allows an FPGA application to choose between four configuration images
using two internal signal ports, S1 and S0, as shown in Figure 10.1. These internal signal ports connect to
programmable interconnect, which in turn can connect to Programmable Logic Block (PLB) and/or PIO pins. S1 and S0
are used in the same way as CBSEL[1:0] as of the vector address indicators. The Warm Boot applet is created in the
same way as shown in Figure 10.2.
After selecting the desired configuration image, the application then asserts the internal signal BOOT port High to force
the FPGA to restart the configuration process from the specified vector address stored in PROM.
© 2018-2022 Lattice Semiconductor Corp. All Lattice trademarks, registered trademarks, patents, and disclaimers are as listed at www.latticesemi.com/legal.
All other brand or product names are trademarks or registered trademarks of their respective holders. The specifications and information herein are subject to change without notice.
FPGA-TN-02001-3.4 27
iCE40 Programming and Configuration
Technical Note
© 2018-2022 Lattice Semiconductor Corp. All Lattice trademarks, registered trademarks, patents, and disclaimers are as listed at www.latticesemi.com/legal.
All other brand or product names are trademarks or registered trademarks of their respective holders. The specifications and information herein are subject to change without notice.
28 FPGA-TN-02001-3.4
iCE40 Programming and Configuration
Technical Note
AP_VCCIO VCCIO_2
VCC_SPI
Application
Processor
SPI_SI
SPI_SO
iCE40
(SPI Bank)
SPI_SS
SPI_SCK
10 k
© 2018-2022 Lattice Semiconductor Corp. All Lattice trademarks, registered trademarks, patents, and disclaimers are as listed at www.latticesemi.com/legal.
All other brand or product names are trademarks or registered trademarks of their respective holders. The specifications and information herein are subject to change without notice.
FPGA-TN-02001-3.4 29
iCE40 Programming and Configuration
Technical Note
Table 13.1. SPI Slave Configuration Interface Pins (SPI_SS Low when CRESET_B Released)
Signal Name Direction iCE40 I/O Supply Description
Configuration Done output from iCE40. Connect to an external
pullup resistor to the application processor I/O voltage, AP_VCC.
The resistor size can be calculated knowing the configuration clock
frequency (SCLK or MCLK) and the CDONE trace capacitance with
CDONE Output
the following formula:
VCCIO_2 Rpullup=1/(2*ConfigFrequency*CDONETraceCap)
The iCE40-1KLP SWG16 package CDONE pin can be used as a user
output.
Configuration Reset input on iCE40. Typically driven by AP using an
CRESET_B Input open-drain driver, which also requires a 10 kΩ pullup resistor to
VCCIO_2.
VCC_SPI Supply SPI Flash PROM voltage supply input.
SPI Serial Input to the iCE40 FPGA, driven by the application
SPI_SI Input
processor.
SPI Serial Output from iCE40 device to the application processor.
SPI_SO Output Not actually used during SPI peripheral mode configuration but
VCC_SPI
required if the SPI interface is also used to program the NVCM.
SPI Slave Select output from the application processor. Active Low.
SPI_SS Input Optionally hold Low prior to configuration using a 10 kΩ pulldown
resistor to ground.
SPI_SCK Input SPI Slave Clock output from the application processor.
After configuration, the SPI port pins are available to the user-application as additional PIO pins, supplied by the
VCC_SPI input voltage.
© 2018-2022 Lattice Semiconductor Corp. All Lattice trademarks, registered trademarks, patents, and disclaimers are as listed at www.latticesemi.com/legal.
All other brand or product names are trademarks or registered trademarks of their respective holders. The specifications and information herein are subject to change without notice.
30 FPGA-TN-02001-3.4
iCE40 Programming and Configuration
Technical Note
edge of the SPI_SCK clock. The SPI_SO output pin in the iCE40 is not used during SPI slave mode but must connect to
the AP if the AP also programs the NVCM of the iCE40 device.
After sending the entire image, the iCE40 FPGA releases the CDONE output allowing it to float High via the external
pullup resistor to AP_VCC. If the CDONE pin remains Low, then an error occurred during configuration and the AP
should handle the error accordingly for the application.
After the CDONE output pin goes High, send at least 49 additional dummy bits, effectively 49 additional SPI_SCK clock
cycles measured from rising-edge to rising-edge.
After the additional SPI_CLK cycles, the SPI interface pins then become available to the user-application loaded in
FPGA. In the iCE40-1KLP SWG16 package, the CDONE pin can be used as a user output.
To reconfigure the iCE40 FPGA or to load a different configuration image, merely restart the configuration process by
pulsing CRESET_B Low or power-cycling the FPGA.
200 ns
CRESET_B 1200 us Max 100 clock cycles
8 dummy clocks
iCE40 clears internal
configuration memory.
D7
D6
D5
D4
D3
D2
D1
D0
SPI_SI x x x x x x x
Don t Care
Entire Configuration Images dummy bits
Send most-significant bit of each byte first
Figure 13.2. Application Processor Waveforms for SPI Peripheral Mode Configuration Process
© 2018-2022 Lattice Semiconductor Corp. All Lattice trademarks, registered trademarks, patents, and disclaimers are as listed at www.latticesemi.com/legal.
All other brand or product names are trademarks or registered trademarks of their respective holders. The specifications and information herein are subject to change without notice.
FPGA-TN-02001-3.4 31
iCE40 Programming and Configuration
Technical Note
Drive CRESET_B = 0.
Release CRESET_B or
drive CRESET_B = 1.
Set SPI_SS = 1,
Send 8 dummy clocks.
No
CDON E = 1? ERROR !
Yes
Send a minimum of 49
additional dummy bits and 49
addition SP I_SCK clock cycles
(rising-edge to rising-edge) to
active the user-I/O pins.
No
Reconfigure?
Yes
Note: The configuration flow is the same for a bitstream with and without a header.
Figure 13.3. SPI Slave Configuration Process
Refer to Appendix A. SPI Slave Configuration Procedure for the SPI peripheral configuration procedure.
© 2018-2022 Lattice Semiconductor Corp. All Lattice trademarks, registered trademarks, patents, and disclaimers are as listed at www.latticesemi.com/legal.
All other brand or product names are trademarks or registered trademarks of their respective holders. The specifications and information herein are subject to change without notice.
32 FPGA-TN-02001-3.4
iCE40 Programming and Configuration
Technical Note
Table 13.3 describes how to maintain voltage compatibility for two interface scenarios. The easiest interface is when
the Application Processor (AP) I/O supply rail and the iCE40 SPI and VCCIO_2 bank supply rails all connect to the same
voltage. The second scenario is when the AP I/O supply voltage is greater than the iCE40 VCCIO_2 supply voltage.
Table 13.3. CRESET_B and CDONE Voltage Compatibility
Condition CRESET_B CDONE Requirement
Direct Open-Drain Pullup Pullup
AP_VCCIO = VCC_SPI OK OK with Required if using Recommended AP can directly drive CRESET_B High and
AP_VCCIO = VCCIO_2 pullup open-drain Low although an open-drain output
output recommended is if multiple devices
control CRESET_B. If using an open-drain
driver, the CRESET_B input must include a
10 kΩ pullup resistor to VCCIO_2. The 10
kΩ pullup resistor to AP_VCCIO is also
AP_VCCIO > VCCIO_2 N/A Required, Required Required recommended.
The AP must control CRESET_B with an
requires open-drain output, which requires a 10
pullup kΩ pullup resistor to VCCIO_2. The 10 kΩ
pullup resistor to AP_VCCIO is required.
© 2018-2022 Lattice Semiconductor Corp. All Lattice trademarks, registered trademarks, patents, and disclaimers are as listed at www.latticesemi.com/legal.
All other brand or product names are trademarks or registered trademarks of their respective holders. The specifications and information herein are subject to change without notice.
FPGA-TN-02001-3.4 33
iCE40 Programming and Configuration
Technical Note
© 2018-2022 Lattice Semiconductor Corp. All Lattice trademarks, registered trademarks, patents, and disclaimers are as listed at www.latticesemi.com/legal.
All other brand or product names are trademarks or registered trademarks of their respective holders. The specifications and information herein are subject to change without notice.
34 FPGA-TN-02001-3.4
iCE40 Programming and Configuration
Technical Note
SPI_SCK
SPI_SS
SPI_SDI
SPI_SCK
8 (or 13000)
SPI_SS
clock cycles
SPI_SDI 5 4 3 2 1 0 7 6 5 4 3 2 1 0
Following Command
*= MSB
Figure A.2. iCE40 Reset Waveform 2
SPI_SCK
SPI_SS
* *
SPI_SDI 1 0 0 0 0 0 1 1 23 22 21 20 1 0 7 6 5 4 3 2 1 0
0x83 00 00 26 11 /
* = MSB 00 00 27 21
Figure A.3. iCE40 Reset Waveform 3
© 2018-2022 Lattice Semiconductor Corp. All Lattice trademarks, registered trademarks, patents, and disclaimers are as listed at www.latticesemi.com/legal.
All other brand or product names are trademarks or registered trademarks of their respective holders. The specifications and information herein are subject to change without notice.
FPGA-TN-02001-3.4 35
iCE40 Programming and Configuration
Technical Note
SPI_SCK
SPI_SS
SPI_SDI 1 0 0 0 0 0 0 1
0x81
Instruction
//
// Reset the iCE40 Device
//
Set_Port(SPI_SS, false);// Set SPI_SS low Set_Port(CRESET, false);// Set CRESET low
Set_Port(SPI_CLK, true);// Set SPI_CLK high nSec_Delay(200);// Delay minimum 200 nsec
Set_Port(CRESET, true);// Set CRESET high
if (type == L1K or L4K)
uSec_Delay(800);// Delay 800 usec if L1K,L4K else if (type == L8K)
uSec_Delay(1200);// Delay 1200 usec for L8K Set_Port(SPI_SS, true);// Set SPI_SS high
Send_Clocks (8);// Send 8 clocks
Set_Port(SPI_SS, false); // Set SPI_SS low
//
// Send data from bin file
//
Send_File(file_pointer);// Send bin file Send_Clocks (100);// Send 100 clocks
//
// Verify successful configuration
//
set_Port(SPI_SS,true); // Set SPI_SS high
if (Get_Port(CDONE))
Return PASS;// PASS if CDONE is true else
Return FAIL;// FAIL if CDONE is false
}
//
// Clock Generation 10MHz
//
void Send_Clocks(num_clocks)
© 2018-2022 Lattice Semiconductor Corp. All Lattice trademarks, registered trademarks, patents, and disclaimers are as listed at www.latticesemi.com/legal.
All other brand or product names are trademarks or registered trademarks of their respective holders. The specifications and information herein are subject to change without notice.
36 FPGA-TN-02001-3.4
iCE40 Programming and Configuration
Technical Note
{
for {i = 0; i < num_clocks; i++}
{
Set_Port(SPI_CLOCK, false);// Set SPI_CLK low nSec_Delay(50);// Delay 50 nsec
Set_Port(SPI_CLOCK, true);// Set SPI_CLK high nSec_Delay(50);// Delay 50 nsec
}
}
//
// Send Data from file
//
void Send_File(file_pointer)
{
byte = getc(file_pointer);// Read first byte from file while (byte != EOF)
{
Send_Byte (byte);// Send data byte
byte = getc(file_pointer);// read next byte from file
}
}
© 2018-2022 Lattice Semiconductor Corp. All Lattice trademarks, registered trademarks, patents, and disclaimers are as listed at www.latticesemi.com/legal.
All other brand or product names are trademarks or registered trademarks of their respective holders. The specifications and information herein are subject to change without notice.
FPGA-TN-02001-3.4 37
iCE40 Programming and Configuration
Technical Note
© 2018-2022 Lattice Semiconductor Corp. All Lattice trademarks, registered trademarks, patents, and disclaimers are as listed at www.latticesemi.com/legal.
All other brand or product names are trademarks or registered trademarks of their respective holders. The specifications and information herein are subject to change without notice.
38 FPGA-TN-02001-3.4
iCE40 Programming and Configuration
Technical Note
References
For more information, refer to the following documents:
iCE40 LP/HX Family Data Sheet (FPGA-DS-02029)
iCE40 LM Family Data Sheet (FPGA-DS-02043)
Programming Cables User Guide (FPGA-UG-02042)
© 2018-2022 Lattice Semiconductor Corp. All Lattice trademarks, registered trademarks, patents, and disclaimers are as listed at www.latticesemi.com/legal.
All other brand or product names are trademarks or registered trademarks of their respective holders. The specifications and information herein are subject to change without notice.
FPGA-TN-02001-3.4 39
iCE40 Programming and Configuration
Technical Note
© 2018-2022 Lattice Semiconductor Corp. All Lattice trademarks, registered trademarks, patents, and disclaimers are as listed at www.latticesemi.com/legal.
All other brand or product names are trademarks or registered trademarks of their respective holders. The specifications and information herein are subject to change without notice.
40 FPGA-TN-02001-3.4
iCE40 Programming and Configuration
Technical Note
Revision History
Revision 3.4, December 2022
Section Change Summary
All Changed all instances of “pull-up” to “pullup”.
Changed all instances of “pull-down” to “pulldown”.
Updated all instances of “SPI_SS_B” to “SPI_SS” in all the figures.
sysCONFIG Port Updated the description for SPI_SI and SPI_SO in Table 8.2. sysCONFIG Pins.
SPI Slave Configuration Interface Updated the description for SPI_SO in Table 13.1. SPI Slave Configuration Interface Pins
(SPI_SS Low when CRESET_B Released), indicating that this signal is from “iCE40 device”
instead of “CE65 device”.
Added information of SPI configuration requirements in the Enabling SPI Configuration
Interface section.
© 2018-2022 Lattice Semiconductor Corp. All Lattice trademarks, registered trademarks, patents, and disclaimers are as listed at www.latticesemi.com/legal.
All other brand or product names are trademarks or registered trademarks of their respective holders. The specifications and information herein are subject to change without notice.
FPGA-TN-02001-3.4 41
iCE40 Programming and Configuration
Technical Note
© 2018-2022 Lattice Semiconductor Corp. All Lattice trademarks, registered trademarks, patents, and disclaimers are as listed at www.latticesemi.com/legal.
All other brand or product names are trademarks or registered trademarks of their respective holders. The specifications and information herein are subject to change without notice.
42 FPGA-TN-02001-3.4
iCE40 Programming and Configuration
Technical Note
© 2018-2022 Lattice Semiconductor Corp. All Lattice trademarks, registered trademarks, patents, and disclaimers are as listed at www.latticesemi.com/legal.
All other brand or product names are trademarks or registered trademarks of their respective holders. The specifications and information herein are subject to change without notice.
FPGA-TN-02001-3.4 43
iCE40 Programming and Configuration
Technical Note
© 2018-2022 Lattice Semiconductor Corp. All Lattice trademarks, registered trademarks, patents, and disclaimers are as listed at www.latticesemi.com/legal.
All other brand or product names are trademarks or registered trademarks of their respective holders. The specifications and information herein are subject to change without notice.
44 FPGA-TN-02001-3.4
www.latticesemi.com