Xapp583 Fpga Configuration
Xapp583 Fpga Configuration
Summary With embedded systems becoming more popular, many designers want to reduce their
component count and increase flexibility. To accomplish both of these goals, a microprocessor
already available in the system can be used to configure an FPGA. This application note
provides a thorough discussion of FPGA configuration via a microprocessor, covering the Xilinx
7 series FPGAs. C code is included to illustrate an example application using either Slave
Serial or Slave SelectMAP mode. The included example configures a Kintex™-7 XC7K325T
device from a MicroBlaze™ processor.
System Today’s systems demand greater functionality in less space and at reduced cost. In addition,
Overview each generation of Xilinx FPGAs delivers higher performance and increased capabilities.
Although Xilinx FPGAs support direct configuration from third-party flash, an embedded
processor-based configuration solution can allow for advanced FPGA configuration
applications and reduce board real estate requirements, assuming that an external, embedded
processor with sufficient memory is already a prerequisite for the system. This technique
requires that the processor be operational before FPGA functionality is required.
This application note describes a technique for configuring an FPGA from an embedded
processor. The Xilinx design tools generate the FPGA configuration data, also known as a
configuration bitstream. To configure the FPGA, the processor uses the described technique to
load the generated bitstream into the FPGA. A system diagram is shown in Figure 1.
X-Ref Target - Figure 1
Memory
7 Series
Processor
FPGA
7 Series
Bitstream
X583_01_040412
A microprocessor whose primary purpose is to perform other tasks can also be used to
coordinate the loading of configuration data into a Xilinx FPGA. A processor provides greater
flexibility, for example, in choosing which of multiple configuration files to program into the
FPGA.
© Copyright 2012 Xilinx, Inc. Xilinx, the Xilinx logo, Artix, ISE, Kintex, Spartan, Virtex, Zynq, and other designated brands included herein are trademarks of Xilinx in the United
States and other countries. AMBA and ARM are registered trademarks of ARM in the EU and other countries. All other trademarks are the property of their respective owners.
Configuration Microprocessor configuration of 7 series FPGAs can be accomplished in either Slave Serial or
Background Slave SelectMAP mode. There are several similarities between these two modes. Most
importantly, the basic configuration sequence is identical for both modes.
The JTAG configuration interface can also be controlled via a microprocessor, but that interface
is not included in this application note.
Pulse
Power-up PROGRAM_B
1. Power-up or
Configuration
Reset
INIT_B = Low
2. Device
Initialization
INIT_B = High
3. Configuration
(Bitstream)
Load
INIT_B = Low
INIT_B = ? Error
INIT_B = High
Special Startup
Conditions Timeout
Compensation FAIL:
DONE = Low
SUCCESS:
DONE = High
[Optional]
Configuration
Reconfigure
Complete
FPGA
X583_02_040412
Sync Word
After a few pad bits and the bus width auto-detection pattern, at the beginning of the bitstream
is a 32-bit sync word (0xAA995566). The sync word bit order (or byte order) from the processor
to the FPGA is the most important signature for correct delivery of the bitstream to the FPGA.
Device Identification
A device ID check follows the sync word in the bitstream. This checks that the appropriate
device is receiving the bitstream. If the device ID check fails, the FPGA drives its INIT_B pin
Low to indicate a configuration error.
CRC Check
Near the end of the bitstream is a command that checks the internal configuration cyclic
redundancy check (CRC) against an expected value from the bitstream. If the device
recognizes the CRC check command and if the CRC does not match the expected value, the
FPGA drives its INIT_B pin Low to indicate a configuration error.
Start-Up
After the device receives all the configuration data from the bitstream and passes the CRC
check, a start-up command near the end of the bitstream initiates a start-up sequence for the
loaded design. See UG470, 7 Series FPGAs Configuration User Guide for the details of the
start-up sequence. During the start-up sequence, the FPGA releases its DONE pin to a
high-impedance state. The FPGA waits at that point in the start-up sequence until the DONE
pin goes High. A strong external pull-up resistor (or the BitGen DriveDONE option) is required
to bring the DONE pin High. The start-up sequence completes when it reaches the end of
start-up (EOS) state.
Note: The DONE signal is released before EOS. Thus, the processor code must not stop delivering the
bitstream or stop delivering CCLK pulses when DONE transitions to High.
The processor code must deliver all bits/words of the bitstream to the FPGA. Typically, the
start-up sequence completes to EOS before the last bit of the bitstream is delivered to the
FPGA.
Two extra control signals are present for SelectMAP: CSI_B and RDWR_B. These signals must
both be asserted Low for a configuration byte to be transferred to the FPGA.
Note: The appropriate 7 series FPGA family data sheet must be referred to for setup and hold
specifications for all signals. The Slave SelectMAP configuration reference design for this application note
demonstrates configuration via only the 8 bit SelectMAP bus. The 7 series FPGA families also support 16-
or 32-bit-wide SelectMAP buses. With appropriate modifications and attention to bit ordering, the
principles of this reference design can be extended for the 16- or 32-bit-wide SelectMAP bus. See
UG470, 7 Series FPGAs Configuration User Guide for more details.
Data ordering in Slave Serial configuration is very simple. Loading begins with the first bit in the
bitstream and continues one bit at a time until the end of the file is reached.
In contrast, data ordering for Slave SelectMAP configuration is slightly more complex. A
description of bit order for the 8-bit SelectMAP parallel bus is presented here. (See UG470,
7 Series FPGAs Configuration User Guide for the parallel bus bit order when using the
SelectMAP 16-bit and 32-bit bus widths.) Configuration data is loaded one byte at each rising
CCLK edge, and the MSB of each byte is presented on the D[00] pin, not the D[07] pin.
Because of this non-conventional ordering, presenting the data as is from the .bin file is
generally incorrect. The reason is that most processors interpret D[07] (not D[00]) as the most
significant bit in each byte. Connecting D[07] on the processor to the D[07] on the FPGA
SelectMAP data bus effectively loads the data backwards, resulting in unsuccessful
configuration. For this reason, the source data stream might need to be bit-swapped, with bits
in each byte in the data stream reversed. Figure 3 shows two bytes (0xABCD) being reversed.
X-Ref Target - Figure 3
Hex: A B C D
SelectMAP
Data Pin: D0 D1 D2 D3 D4 D5 D6 D7 D0 D1 D2 D3 D4 D5 D6 D7
Binary: 1 0 1 0 1 0 1 1 1 1 0 0 1 1 0 1
Bit-Swapped
Binary: 1 1 0 1 0 1 0 1 1 0 1 1 0 0 1 1
SelectMAP D7 D6 D5 D4 D3 D2 D1 D0 D7 D6 D5 D4 D3 D2 D1 D0
Data Pin:
Bit-Swapped
Hex: D 5 B 3
X583_03_032912
Regardless of the orientation of the data, the MSB of the first byte of the data must be
transmitted to D[00]. However, in the bit-swapped version of the data, the bit that must be
transmitted to D[00] is the rightmost bit and, in the non-bit-swapped data, the leftmost bit. With
Xilinx tools, the .mcs files are always bit-swapped, and the .bit, .rbt, and .bin files are never
bit-swapped. Hexadecimal files can be produced bit-swapped according to the PROMGen tool
command line options.
Note: Whether or not data is bit-swapped is entirely processor- or application-dependent and is
generally only applicable for Slave SelectMAP applications. Non-bit-swapped data should be used for
Slave Serial downloads.
1/FSCCK
Symbols:
F SCCK = Maximum CCLK frequency
1/F SCCK = Minimum CCLK period
CCLK TSCCKL TSCCKH T SCCKL = Minimum CCLK low time
T SCCKH = Minimum CCLK high time
T DCCK = Minimum D01_DIN to CCLK rising-edge setup time
T CCKD = Minimum CCLK rising-edge to D01_DIN hold time
Set D01_DIN
TPROGRAM
PROGRAM_B
INIT_B
CCLK
DONE
X583_05_053012
In Figure 5, data is ignored before the sync word and after configuration is complete.
TPROGRAM
PROGRAM_B
INIT_B
CCLK
CSI_B
RDWR_B
DONE
X583_06_032912
Hardware Microprocessor
Implementation The reference design is based on the Xilinx MicroBlaze processor. For more information on the
MicroBlaze processor, see www.xilinx.com/microblaze.
Voltage Compatibility
The processor I/O needs to support a voltage that is compatible with the connected FPGA pins.
The configuration interfaces include the JTAG and dedicated configuration pins in bank 0, and
the dual-purpose pins in bank 14. To support the appropriate configuration interface voltage on
bank 0 and bank 14, the configuration bank voltage select pin (CFGBVS) must be set to High
or Low to set the configuration-related I/O for 3.3V/2.5V or 1.8V operation, respectively.
Typically, both banks receive the same VCCO voltage supply to ensure a consistent I/O voltage
interface for all of the configuration interface pins. In the Virtex-7 FPGA, bank 14 is a
high-performance bank limited to 1.8V or lower I/O standards. The design must meet the
voltage restrictions shown in Table 4.
Notes:
1. The JTAG pins are in bank 0. Therefore, the JTAG signal voltage follows the voltage required for bank 0.
configuration option. As shown in Figure 7, this design retrieves the FPGA configuration data
stored in external memory and directly configures the target FPGA.
X-Ref Target - Figure 7
VCCINT
See Configuration Voltage Requirements
CFGBVS VCCAUX
section for appropriate connection. (Note1)
VCCAUX
VCCO_0
VCCO_0
VCCO_14
VCC VCCO_0
VCCO_14
M2
Microprocessor
M1
VCCO_0
M0
7 Series
4.7 kΩ
FPGA
Configuration D[31:0] D[31:0]
Memory
Source SELECT CSI_B
READ/WRITE RDWR _B INIT_B
CLOCK CCLK
PROGRAM_B PROGRAM_B
DONE
DONE
INIT_B
GND
VCCO_0
GND
4.7 kΩ
330Ω
PROGRAM_B
.
X583_07_040412
Note: See TPROGRAM in the target FPGA data sheet for specific requirements on the PROGRAM_B
pulse width. Asserting PROGRAM_B is not required if the FPGA has just completed power-up or is reset
through other means besides asserting PROGRAM_B.
After PROGRAM_B and INIT_B are deasserted, shift_word_out() is called for each 32-bit word
in the target FPGA bitstream stored in memory. This function deasserts CCLK, sequences the
next byte from the current word onto D[7:0], and then asserts CCLK.
After sending the target bitstream, main() waits for the target to assert DONE. To make sure
that any special start-up conditions have been met, another eight CCLK assertion and
deassertions are sent to the target.
Note: The following pseudocode represents a memory-mapped I/O structure such as in the MicroBlaze
processor. While the slave_selectmap.c source file in the reference design should be easily portable,
the user might need to modify the read and write commands and addresses to match the new system.
Also, many systems might have one or two GPIO instances and need to use bit masking to drive the pins
independently. The C code in this reference design accesses the I/O pins as individually memory-mapped
peripherals and reads and writes from these I/O using pointers. This makes the code simple and portable
to a wide range of microprocessors.
/* Global defines
* Define the addresses for the I/O peripherals used to control and
* monitor the target FPGA. Also define the location in memory the
* bitstream is stored and its size. These are system dependent and
* should be adjusted as needed
*/
/* PROGRAM_B pulse width. Check the target FPGA data sheet for the
* TPROGRAM pulse width. One microsecond is safe for any 7 series FPGA
*/
TPROGRAM = 1 /* Assumes sleep() is microseconds */
/* Serialize word and clock each bit on target's DIN and CCLK pins */
shift_word_out(data32)
{
*cclk = CCLK_GPIO_BASEADDR
*data_out = DATA_OUT_GPIO_BASEADDR
/* Sequence the 32-bit word into bytes. The endianess can be either
* little or big. The following assumes the sync word is read from
* external memory as 0x665599AA (instead of 0xAA995566).
*/
byte[0] = data32 >> 24
byte[1] = data32 >> 16
byte[2] = data32 >> 8
byte[3] = data32
*cclk = 0
*cclk = 0
for (i = 0; i < count; --i) {
*cclk = 1
*cclk = 0
}
}
int main()
{
bits_start = BITSTREAM_START_ADDR
bits_size = BITSTREAM_SIZE_BYTES
*program_b = PROGRAM_B_GPIO_BASEADDR
*rdrw_b = RDRW_B_GPIO_BASEADDR
*csi_b = CSI_B_GPIO_BASEADDR
*init_b = INIT_B_GPIO_BASEADDR
*done = DONE_GPIO_BASEADDR
/* Check INIT_B */
if (*init_b_pointer == 0) {
return 1
}
/* Check INIT_B */
if (*init_b == 0) {
return 1
}
while(*done == 0)
;
VCCINT
See Configuration Voltage Requirements
CFGBVS VCCAUX
section for appropriate connection. (Note 1)
VCCAUX
VCCO_0
VCCO_0
VCCO_14
VCC0_14
VCC
VCCO_0 7 Series VCCO_0
FPGA
M2
Microprocessor M1
4.7 k
M0
Configuration PROGRAM_B
Memory
Source CLOCK CCLK DONE
SERIAL_OUT DIN
PROGRAM_B INIT_B
DONE
INIT_B
GND
VCCO_0
GND 4.7 k
330
PROGRAM_B
X583_08_032912
/* Global defines
* Define the addresses for the I/O peripherals used to control and
* monitor the target FPGA. Also define the location in memory the
* bitstream is stored and its size. These are system dependent and
* should be adjusted as needed
*/
/* PROGRAM_B pulse width. Check the target FPGA data sheet for the
* TPROGRAM pulse width. One microsecond is safe for any 7 series FPGA
*/
TPROGRAM = 1 /* Assumes sleep() is microseconds */
/* Serialize a 32-bit word and clock each bit on the target's DIN and
* CCLK pins */
shift_word_out(data32)
{
*cclk = CCLK_GPIO_BASEADDR
*serial_out = SERIAL_OUT_GPIO_BASEADDR
*cclk = 0
*serial_out = 0
for (i = 31; i >= 0; --i){
*serial_out = (data32 & 1 << i) ? 1 : 0
shift_cclk(1)
}
}
*cclk = 0
for (i = 0; i < count; --i) {
*cclk = 1
*cclk = 0
}
}
int main()
{
bits_start = BITSTREAM_START_ADDR
bits_size = BITSTREAM_SIZE_BYTES
*program_b = PROGRAM_B_GPIO_BASEADDR
*init_b = INIT_B_GPIO_BASEADDR
*done = DONE_GPIO_BASEADDR
/* Configuration Reset */
*program_b = 0
sleep(TPROGRAM)
*program_b = 1
/* Check INIT_B */
if (*init_b_pointer == 0) {
return 1
}
Reference The reference design files for this application note can be downloaded from:
Design Files https://secure.xilinx.com/webreg/clickthrough.do?cid=188189
Table 5 shows the reference design checklist.
Conclusion This application note provides background on configuration as well as a description of two
complete sets of reference designs allowing a Xilinx FPGA to be configured through Slave
SelectMAP or Slave Serial mode. Although the microprocessor C code targets a Xilinx
MicroBlaze processor, it was written with portability in mind. Porting the code to another
processor requires some effort, but all the design files are documented extensively.
Revision The following table shows the revision history for this document.
History
Date Version Description of Revisions
05/31/2012 1.0 Initial Xilinx release.
Notice of The information disclosed to you hereunder (the “Materials”) is provided solely for the selection and use of
Xilinx products. To the maximum extent permitted by applicable law: (1) Materials are made available “AS
Disclaimer IS” and with all faults, Xilinx hereby DISCLAIMS ALL WARRANTIES AND CONDITIONS, EXPRESS,
IMPLIED, OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF
MERCHANTABILITY, NON-INFRINGEMENT, OR FITNESS FOR ANY PARTICULAR PURPOSE; and (2)
Xilinx shall not be liable (whether in contract or tort, including negligence, or under any other theory of
liability) for any loss or damage of any kind or nature related to, arising under, or in connection with, the
Materials (including your use of the Materials), including for any direct, indirect, special, incidental, or
consequential loss or damage (including loss of data, profits, goodwill, or any type of loss or damage
suffered as a result of any action brought by a third party) even if such damage or loss was reasonably
foreseeable or Xilinx had been advised of the possibility of the same. Xilinx assumes no obligation to
correct any errors contained in the Materials or to notify you of updates to the Materials or to product
specifications. You may not reproduce, modify, distribute, or publicly display the Materials without prior
written consent. Certain products are subject to the terms and conditions of the Limited Warranties which
can be viewed at http://www.xilinx.com/warranty.htm; IP cores may be subject to warranty and support
terms contained in a license issued to you by Xilinx. Xilinx products are not designed or intended to be
fail-safe or for use in any application requiring fail-safe performance; you assume sole risk and liability for
use of Xilinx products in Critical Applications: http://www.xilinx.com/warranty.htm#critapps.
Automotive XILINX PRODUCTS ARE NOT DESIGNED OR INTENDED TO BE FAIL-SAFE, OR FOR USE
Applications IN ANY APPLICATION REQUIRING FAIL-SAFE PERFORMANCE, SUCH AS APPLICATIONS
RELATED TO: (I) THE DEPLOYMENT OF AIRBAGS, (II) CONTROL OF A VEHICLE, UNLESS
Disclaimer THERE IS A FAIL-SAFE OR REDUNDANCY FEATURE (WHICH DOES NOT INCLUDE USE
OF SOFTWARE IN THE XILINX DEVICE TO IMPLEMENT THE REDUNDANCY) AND A
WARNING SIGNAL UPON FAILURE TO THE OPERATOR, OR (III) USES THAT COULD
LEAD TO DEATH OR PERSONAL INJURY. CUSTOMER ASSUMES THE SOLE RISK AND
LIABILITY OF ANY USE OF XILINX PRODUCTS IN SUCH APPLICATIONS.