[Internal Configuration Port Interface] Interface for partial reconfiguration on the FPGA. More...
Go to the source code of this file.
Defines | |
#define | HC_CLBCOLS_XC4VFX12 24 |
Number of CLB columns on the XC4VFX12 (UG070, page 184). | |
#define | HC_CLBMINORROWS_XC4VFX12 64 |
#define | DUMMY_PACKET 0xFFFFFFFFUL |
#define | SYNC_PACKET 0xAA995566UL |
#define | NOP_PACKET 0X20000000UL |
#define | CMD_PACKET 0x30008001UL |
#define | FAR_PACKET 0x30002001UL |
#define | IDCODE_PACKET 0x30018001UL |
#define | STAT_PACKET 0x2800E001UL |
#define | WCFG_CMD 1 |
#define | LFRM_CMD 3 |
#define | RCFG_CMD 4 |
#define | RCRC_CMD 7 |
#define | DESYNC_CMD 14 |
#define | FDRI 2 |
#define | STAT 7 |
#define | XHI_DISABLED_AUTO_CRC 0x0000DEFCUL |
#define | XHI_TYPE_1_PACKET_MAX_WORDS 1024 |
#define | WORDS_PR_FRAME 41 |
#define | TYPE2 30 |
#define | TYPE1 29 |
#define | REG_ADDR 13 |
#define | OP_READ 27 |
#define | OP_WRITE 28 |
#define | V4FX12ID 0x21E58093; |
Functions | |
int | hicap_open (char *icap_device, char *device_type) |
Open the ICAP-device. | |
int | hicap_close (int icap_handle) |
Close the ICAP-device. | |
int | hicap_write (int icap_handle, char *infilename, int real_row, int clb_column, int frames_offset, int frames) |
Write a bitstream to ICAP. | |
int | hicap_get_status (int icap_handle) |
Get status of the ICAP-device. |
[Internal Configuration Port Interface] Interface for partial reconfiguration on the FPGA.
This module makes it possible to write a partial bitstream to the ICAP on the FPGA. Based on the important work done by Sverre Hamre in his thesis.
Original author (2009): Sverre Hamre Modified (2011): Sindre Hansen
Definition in file hicap.h.
#define HC_CLBMINORROWS_XC4VFX12 64 |
int hicap_close | ( | int | icap_handle | ) |
Close the ICAP-device.
icap_handle | The handle/file descriptor to the device as returned by hicap_open. |
Definition at line 259 of file hicap.c.
{ clbcols_current = -1; clbrows_current = -1; if (clbcol_to_abscol_current != NULL) free(clbcol_to_abscol_current); if (realrow_to_bitstreamrow_current != NULL) free(realrow_to_bitstreamrow_current); if (close(icap_handle) != 0) { hlog_write(HLOG_ERROR, "hicap_close: closing driver\n"); return -1; } else return 0; }
int hicap_get_status | ( | int | icap_handle | ) |
Get status of the ICAP-device.
Refer to the work of Sverre Hamre to find out what this function should return.
icap_handle | Handle for icap device. Returned by hicap_open. |
Definition at line 190 of file hicap.c.
{ uint32_t data[7]; uint32_t status; // Dummy, synch data[0] = DUMMY_PACKET; data[1] = SYNC_PACKET; data[2] = NOP_PACKET; //Flush data[3] = NOP_PACKET; //Flush // Read out status, one word. data[4] = (1<<TYPE1) | (1<<OP_READ) | (STAT<<REG_ADDR) | 1; data[5] = NOP_PACKET; data[6] = NOP_PACKET; if(write(icap_handle, data, sizeof(uint32_t)*7) == 0){ hlog_write(HLOG_ERROR, "hicap_get_status: writing get status\n"); return 0; //error } // Get status. if(read(icap_handle, &status, sizeof(uint32_t)) == 0){ hlog_write(HLOG_ERROR, "hicap_get_status: reading status\n"); return 0; //error } // Desync data[0] = DESYNC_CMD; data[1] = NOP_PACKET; data[2] = NOP_PACKET; if(write(icap_handle, data, sizeof(uint32_t)*3) == 0){ // write; hlog_write(HLOG_ERROR, "hicap_get_status: desyncing get status\n"); return 0; //error } return status; }
int hicap_open | ( | char * | icap_device, | |
char * | device_type | |||
) |
Open the ICAP-device.
icap_device | Path to the device in the system. Example: /dev/icap | |
device_type | Type of the Virtex-4 device. Only "XC4VFX12" is supported at this time. |
Definition at line 231 of file hicap.c.
{ clbcol_to_abscol_current = NULL; clbcols_current = -1; realrow_to_bitstreamrow_current = NULL; clbrows_current = -1; if (strcmp((const char*)device_type, "XC4VFX12") == 0) { clbcol_to_abscol_current = calloc(1, HC_CLBCOLS_XC4VFX12); clbcols_current = HC_CLBCOLS_XC4VFX12; clbrows_current = HC_CLBMINORROWS_XC4VFX12 / 16; realrow_to_bitstreamrow_current = calloc(1, clbrows_current); // Mapping found in Sverre Hamre's master thesis. int colmapping[HC_CLBCOLS_XC4VFX12] = {1,2,3,4,5,6,7,8,9,10,11,12,15,16,17,18,20,21,22,23,24,25,26,27}; // Mapping found in CLBRead and in Vegard Endresen's master thesis. int rowmapping[HC_CLBMINORROWS_XC4VFX12 / 16] = {1, 0, 2, 3}; int i; for (i = 0; i<HC_CLBCOLS_XC4VFX12; i++) clbcol_to_abscol_current[i] = colmapping[i]; for (i = 0; i<clbrows_current; i++) realrow_to_bitstreamrow_current[i] = rowmapping[i]; } return open(icap_device, O_RDWR); }
int hicap_write | ( | int | icap_handle, | |
char * | infilename, | |||
int | real_row, | |||
int | clb_column, | |||
int | frames_offset, | |||
int | frames | |||
) |
Write a bitstream to ICAP.
Each row spans the entire FPGA horizontally and is 16 CLBs in vertical width. The real row address start from 0 at the top of the device and increments downwards.
icap_handle | The handle/file descriptor to the device as returned by hicap_open. | |
infilename | The filename for the bitfile. | |
real_row | Specify a row from 0 to [max rows - 1]. See definition of row in description. | |
clb_column | Specify a CLB column from 0 to [max CLB columns - 1] to start from. | |
frames_offset | Specify an offset of frames within the given address (normally 0). | |
frames | The number of frames to be written. 22 frames are 8 CLBs + 1 HCLK + 8 CLBs. |
Definition at line 277 of file hicap.c.
{ if (write_header_(icap_handle, realrow_to_bitstreamrow_(real_row), clbcol_to_abscol_(clb_column), frames_offset, frames) < 0) { hlog_write(HLOG_ERROR, "hicap_write: Writing header\n"); return -1; } if (write_frames_(icap_handle, frames, infilename, frames_offset) < 0) { hlog_write(HLOG_ERROR, "hicap_write: Writing frames\n"); return -2; } if (write_postconfig_(icap_handle) < 0) { hlog_write(HLOG_ERROR, "hicap_write: Writing postconfig\n"); return -3; } return 0; }