![]() |
Demo program for Change Of State 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 | COSUsage () |
int | main (int argc, char *argv[]) |
void | Display_channels () |
Variables | |
uint | active_high =1 |
Active High for the COS IP Core Channel. It takes values 0 or 1 and defaults to 1. | |
uint | enable =1 |
enable mode bit for the COS 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_cos_configure_t | config |
fpgawb_ipcore_cos_configure_t struct passed as argument to channel configure api call. Check fpgawb_lib.h or api call documentation for more information | |
uint | filter_count =0 |
Filter count for the COS IP Core Channel. It is a 10 bit integer. It takes positive integer values >=0 < 1024 and defaults to 0. | |
uint | mask_lower =0 |
Lower mask for the COS IP Core Channel. This is used to mask the lower 32 Digital Inputs [31:0] to the Dio Change of State IP Module. Each bit corresponds one Digital Input channel. A value of 1 indicates that the Digital Input will be edge detected, a zero indicates the input will be ignored. Thus if the mask is set to : FFFFFFFE only the LSB (or bit 0) will not be evaluated. All others Dio's will be included in the edge detection logic. | |
uint | mask_upper =0 |
Upper mask for the COS IP Core Channel. This is used to mask the upper 32 Digital Inputs [63:32] to the Dio Change of State IP Module. Each bit corresponds one Digital Input channel. A value of 1 indicates that the Digital Input will be edge detected a zero indicates the input will be ignored. Thus if the mask is set to : FFFFFFFA only bit 0 and bit 2 will not be evaluated. All others Dio's will be included in the edge detection logic. | |
int | channel =-1 |
Channel number for the COS 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_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 | num_data_to_be_read =0 |
Number of data to be read from the FIFO during the COS IP Core Channel's read operation. It takes value >=0 and <=128. It defaults to 0. | |
int | xfer_mode = 0 |
Transfer mode for the COS IP Core which specifies regular read or MsgDma read. It takes values 0 (regular) or 1 (MsgDma) and defaults to 0. | |
int | config_mode =0 |
Configuration mode for the test program which indicates to run the program in configure or read mode. It takes values 0-Configuration Mode/1-Read Mode and defaults to 0. | |
uint | cos_mode =0 |
This is the mode control for the change of state IP module. IF this is set to zero both rising and falling edges will be detection, A value of 1 will only detect rising edges and a value of 2 will only detect falling edges. It takes values 0, 1 and 2 and defaults to 0. | |
uint | fifo_count =0 |
FIFO Count of the COS IP Core Channel. Inout paramter used in the api call and defaults to 0. | |
void COSUsage | ( | ) |
Usage:
./fpgawb_ipcore_cos [-a ActiveHigh] [-b BoardNumber] [-c channelNumber] [-C config_mode] [-e Enable] [-f FilterCount] [-l MaskLower] [-m xfer_mode] [-M COSMode] [-n NumOfDataToBeRead] [-u MaskUpper]
Options | Default value |
---|---|
-a Active High (0/1) | 1 |
-b Board Number or Device Number | 0 |
-c channel Number (0- (NumChans-1)) | -1 (all channels) |
-C Config Mode (0/1) 0-Configuration Mode, 1-Read Mode | 0 |
-e Enable (0/1) | 1 |
-f Filter Count - O to 1023 | 0 |
-l Mask Lower | 0 |
-m Transfer mode for reading the FIFO data (0 is for Programmed I/O mode and 1 is for Modular Scatter-Gather DMA mode) | 0 |
-M COS Mode(0 - Both edges, 1 - Rising, 2 - Falling) | 0 |
-n # Data to be read (0 to 128) | 0 |
-u Mask Upper | 0 |
Examples:
./fpgawb_ipcore_change_of_state -uFFFFFFFF -lFFFFFFFF
./fpgawb_ipcore_change_of_state -C1 -n16
./fpgawb_ipcore_change_of_state -C1 -m1 -n16
void Display_channels | ( | ) |
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: READ COS CHANNEL DATA
fpgawb_CoS_Read_Ch_Data(handle, Chan, num_data_to_be_read, &all_info[Chan * ((num_data_to_be_read/4))], &all_status_info[Chan])
This call returns the COS IP Core Channel data such as counter upper, counter lower, data upper and data lower in all_info struct along with the chan's status information such as fifo_count and fifo_watermark in the all_status_info struct
Step 11: GET FIFO COUNT
fpgawb_CoS_Get_Ch_FIFO_Count(handle, 0, &fifo_count)
Returns FIFO count in the inout paramter passed as third argument
Step 12: MSGDMA FIRE
fpgawb_ip_core_MsgDma_Fire(handle)
This call commences the MsgDma transfer
Step 13: READ MSGDMA DATA
fpgawb_CoS_Read_MsgDma_Data(handle, num_data_to_be_read all_info,all_status_info)
Returns data for all the channels in the all_info struct passed as third argument along with status info
Step 14: RELEASE MSGDMA
ccrtNGFC_MsgDma_Release(handle)
This call releases the seized MsgDma. Release the MsgDma once done with the transfer
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_CoS_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 COS
fpgawb_CoS_Activate_Ch(handle,chan,enable,activate)
This call enables the COS IP Core Channel. Set enable to 1 to enable the COS IP Core Channel Note to set activate to 0 because we will be using the Config api calls which requires that activate be 0.
Step 6: CONFIGURE COS CHANNEL
C_fpgawb_CoS_Configure_Ch(handle,chan,&config)
Configures the fields specified in the struct fpgawb_ipcore_cos_configure_t such as active high, cos_mode, filter count, mask lower and mask upper for the COS IP Core Channel
Step 7: ACTIVATE COS - OUTPUT ENABLE
fpgawb_CoS_Activate_Ch(handle,chan,enable,activate)
Set activate to 1 using this call to enable the output_enable for the COS IP Core Channel.
Step 15: CLOSE DEVICE
ccrtNGFC_Close(handle)
Closes the device with the handle