![]() |
Demo program for NIOS Programmer IP Core.
The Usage() function shows how to execute the test program, options available and default values set for different configuration variables. The Variables section specifies variables used in the test program, what they specify, the values it holds and can take. The main() function specifies sequence of api calls executed and tested.
Functions | |
void | NIOSProgrammerUsage () |
int | main (int argc, char *argv[]) |
Variables | |
uint | enable =1 |
enable mode bit for the NIOS Programmer IP Core Channel. Toggling the enable signal will cause the registers to revert to default power-on states. It takes values 0 or 1 and defaults to 1 | |
fpgawb_ipcore_t | ip_core |
fpgawb_ipcore_t struct which stores useful information about the IP Core after executing get IP Info api call. Check fpgawb_lib.h or api call documentation for more information | |
uint | control_mode =0 |
control_mode is used to instruct the NIOS programmer to do one of the following modes. A value of 1 means Do nothing/exit any current mode. A value of 1 means Write to Onchip memories. A value of 2 means reset subset of NIOSs. A value of 3 means flush all Onchip memories. | |
uint | fifo_size =2048 |
fifo_size indicates the desired size of the FIFO. It has a maximum size of 4K and defaults to 2K. | |
uint | ocm_size |
ocm_size is a vector of size 32 and represents the size of the onchip memory in bytes. The onchip memory is the RAM that holds the software code for the NIOS processor. | |
int main | ( | int | argc, |
char * | argv[] | ||
) |
Step 1: OPEN DEVICE
ccrtNGFC_Open(&handle,board_no,oflags)
Before using any API calls, the user needs to open the device and get a handle. This handle is then used as the first argument in most of the following APIs.
Step 2: GET DRIVER INFO
ccrtNGFC_Get_Driver_Info(handle, &binfo)
This call returns useful driver information and saves in the ccrtngfc_driver_info_t structure for later use.
Step 3: GET LIBRARY INFO
ccrtNGFC_Get_Library_Info(handle, &linfo)
This call returns useful library information and saves in the ccrtngfc_library_info_t structure for later use.
Step 4: GET IP INFO
fpgawb_NIOSProgrammer_Get_Ip_Info(handle, &ip_core)
This call returns useful IP Core information and saves in the fpgawb_ipcore_t structure for later use.
Step 5: ACTIVATE NIOS PROGRAMMER
fpgawb_IpCore_NIOSProgrammer_Activate(handle,enable)
This call enabled the NIOS Programmer IP Core.
Step 6: CONFIGURE
fpgawb_IpCore_NIOSProgrammer_Configure(handle,&config)
This api call configures the initial parameters such as NIOS selection mask, FIFO size and Onchip memory sizes of the NIOSs etc.
Step 7: SET CONTROL MODE
fpgawb_IpCore_NIOSProgrammer_Set_Control_Mode(handle,1)
This api call sets the control mode of the NIOS Programmer to Write mode.
Step 8: SEIZE MSGDMA
ccrtNGFC_MsgDma_Seize(handle)
Seizes the MsgDma for data transfer
Step 9: MSGDMA INITIALIZE
fpgawb_IpCore_MsgDma_Initialize_Plus(handle,&IpCodeSelect)
This call initializes Modular Scatter-Gather DMA for the selected IP Cores specified using the _fpgawb_ipcode_select_t struct. The api call calculates and allocates physical memory for the DMA transfer and configures the DMA Descriptors
Step 10: WRITE DATA
fpgawb_IpCore_NIOSProgrammer_Write_Data(handle,&data)
This call writes the data to the physical memory for MsgDma data transfer
Step 11: CONFIGURE MSGDMA DESCRIPTOR LENGTH
fpgawb_IpCore_NIOSProgrammer_MsgDma_Config(handle,MsgDmaEngine,transfer_length)
This call sets the descriptor length for the MsgDma data transfer
Step 12: MSGDMA FIRE
fpgawb_IpCore_MsgDma_Fire(handle)
This call commences the MsgDma transfer
Step 13: SET CONTROL MODE
fpgawb_IpCore_NIOSProgrammer_Set_Control_Mode(handle,0)
This api call sets the control mode of the NIOS Programmer to 0 indicating to exit write mode..
Step 14: RELEASE MSGDMA
ccrtNGFC_MsgDma_Release(handle)
This call releases the seized MsgDma. Release the MsgDma once done with the transfer
Step 15: SET CONTROL MODE
fpgawb_IpCore_NIOSProgrammer_Set_Control_Mode(handle,control_mode This api call sets the control mode for the NIOS Programmer.
Step 16: CLOSE DEVICE
ccrtNGFC_Close(handle)
Closes the device with the handle.
void NIOSProgrammerUsage | ( | ) |
Usage:
./fpgawb_ipcore_nios_programmer [-b BoardNumber] [-C ConfigMode] [-e Enable] [-f InputFile] [-m ControlMode] [-o OCMSize] [-s FIFOSize]
Options | Default value |
---|---|
-b Board Number | 0 |
-C Config Mode (0-Programs software, 1-Programs controls) | 0 |
-e Enable (0/1) | 1 |
-f Input File | NULL |
-m Control mode (0-Do nothing,1-Write,2-Reset,3-Flush all OCM) | 0 |
-o OCM Size | 0 |
-s FIFO Size | 2048 |
Examples:
1.) ./fpgawb_ipcore_nios_programmer -fabc.txt -o32768 -s2048
Input File: Output file of hex2msgdma.sh, the script takes app.hex as input file and outputs the data in format required for MsgDma
2.) ./fpgawb_ipcore_nios_programmer -C1 -m2