Logo
NGFC_SIORx_Demo

Demo program for SIO Rx 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 SIORxUsage ()
 
int main (int argc, char *argv[])
 
void * transmitReceiveDataFun (void *vargp)
 

Variables

uint nrx_bits =4
 This is the number of bits in a word for the SIO Rx IP Core. It takes value 4, 8, 16 or 32 and defaults to 4.
 
uint msb_swap =0
 endian is used for controlling if the data is written LSB or MSB first. It takes value 0 or 1. If 1, first bit received in the data stream from the serial interface will be the LSB of the word in the RAM. If 1, first bit received in the data stream from the serial interface will be the MSB of the word in the RAM.
 
fpgawb_ipcore_t ip_core
 fpgawb_ipcore_t struct which stores useful information about the SIO Rx IP Core after executing get IP Info api call. Check fpgawb_lib.h or api call documentation for more information
 
int channel =-1
 Channel number for the SIO Rx IP Core Channel. It takes values 0 to (number of IP Core channels-1) and defaults to -1 (test program executed for all channels)
 
fpgawb_ipcore_sio_rx_configure_t config
 fpgawb_ipcore_sio_rx_configure_t struct passed as argument for setting the static parameters for the SIO Rx IP Core channel. Check fpgawb_lib.h or api call documentation for more information
 
fpgawb_ipcore_sio_rx_data_t data [FPGAWB_MAX_IPCORE_CHANNELS]
 fpgawb_ipcore_sio_rx_data_t struct passed as argument for reading the data received by the SIO Rx IP Core. Check fpgawb_lib.h or api call documentation for more information
 
fpgawb_ipcore_sio_rx_transfer_length_t config_length
 fpgawb_ipcore_sio_rx_transfer_length_t struct passed as argument for configuring the transfer length in bytes for the respective SIO Rx IP Core channel. Check fpgawb_lib.h or api call documentation for more information
 
uint rx_period = 1500
 Simulator parameter for the test program to execute receiver api calls after specified microseconds.
 
fpgawb_ipcore_sio_rx_info_t all_info [FPGAWB_MAX_IPCORE_CHANNELS]
 fpgawb_ipcore_sio_rx_configure_t struct passed as argument for setting the static parameters for the SIO Rx IP Core channel. Check fpgawb_lib.h or api call documentation for more information
 
uint ced_invert = 0
 It is a one-hot invert for the C, E and D lines. It takes value 0 to 7. This is accomplished by using a 3 bit parameter whereby LSB when set to 1 negates D, second bit when set to 1 negates E, MSB when set to 1 negates C.
 
uint clock_delay = 0
 clock_delay is the delay of the Clock input signal in units of clock cycles (IP Clock)
 
uint enable_delay = 0
 enable_delay is the delay of the Enable input signal in units of clock cycles (IP Clock)
 
uint data_delay = 0
 data_delay is the delay of the Data input signal in units of clock cycles (IP Clock)
 
uint sio_mode = 0
 sio_mode indicates Fast SIO or Standard SIO. It takes value 0 for Fast SIO and 1 for Standard SIO
 

Function Documentation

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_SIO_Rx_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 SIO RX CHANNEL
fpgawb_SIO_Rx_Activate_Ch(handle,chan,enable,activate)
This call activates the SIO Rx IP Core Channel. Note to set activate to 0 because we will be using the Config api calls which requires activate to be 0. The default for activate is 0 in this test program. It is set to 1 at the end to enable the outputs after the static parameters are programmed.

Step 6: CONFIGURE/SETUP CHANNEL
C_fpgawb_SIO_Rx_Configure_Ch(handle,chan,&config)
This call configures/setup the static parameters such as offset for clock/delay/enable, invert for clock/delay/enable, endian, sio mode for the SIO Tx IP Core channel.

Step 7: ACTIVATE SIO RX CHANNEL
fpgawb_SIO_Rx_Activate_Ch(handle,chan,1,1)
This call sets the SIO Rx channel to enable the outputs after the configuration phase. Note that you put the activate to 0 before configuration so make it 1 now.

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 14: RELEASE MSGDMA
ccrtNGFC_MsgDma_Release(handle)
This call releases the seized MsgDma. Release the MsgDma once done with the transfer

Step 15: CLOSE DEVICE
ccrtNGFC_Close(handle)
Closes the device with the handle.

void SIORxUsage ( )

Usage:
./fpgawb_ipcore_sio_rx [-b BoardNumber] [-c channelNumber] [-clock_delay] [-enable_delay] [-data_delay] [-i CEDInvert] [-m MSBSwap/Endian] [-M SIOMode] [-r NumberOfBitsPerWord] [-rx_period]

Options Default value
-b Board Number 0
-c channel Number (0-(Numchans-1) -1 (all channels)
-clock_delay (IP clock cycles) 0
-enable_delay (IP clock cycles) 0
-data_delay (IP clock cycles) 0
-i CED Invert (0 to 7) 0
-m Endian/Endian (0 = LSB First / 1 = MSB First) 0
-M SIOMode ( 0 = Fast / 1 = Standard) 0
-r Num of bits in a word (4/8/16/32) 4
-rx_period 2000


Examples:
./fpgawb_ipcore_sio_rx -n 4

void* transmitReceiveDataFun ( void *  vargp)

Step 10: GET STATUS INFORMATION OF SIO RX Channels
fpgawb_SIO_Rx_Get_Ch_Info(handle,chan,&all_info[chan])
This api call returns the status information of the data and meta-data FIFOs of the SIO Rx IP Core channel. Refer to api call documentation for more information

Step 11: CONFIGURE MSGDMA TRANSFER LENGTH FOR SIO RX Channels
fpgawb_IpCore_SIO_Rx_MsgDma_Config(handle,&IpCodeSelect,&config_length)
This api call conifigures the transfer length in bytes for the MsgDma descriptors. Refer to api call documentation for more information on populating the config_length struct.

Step 12: MSGDMA FIRE
fpgawb_IpCore_MsgDma_Fire(handle)
This call commences the MsgDma transfer from Avalon to the physical memory.

Step 13: READ DATA FOR ALL SIO RX CHANNEL
fpgawb_SIO_Rx_Read_Ch_Data(handle,channel,data))
This api call reads the data from the physical memory allocated for MsgDma trasfer.