Logo
Comparator_Demo

Demo program for Comparator 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 ComparatorUsage ()
 
int main (int argc, char *argv[])
 

Variables

uint enable =1
 enable mode bit for the Comparator 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
 
uint activate =0
 output enable for the Comparator IP Core Channel. Enable this after configuring the registers associated with api calls starting with C. It takes values 0 or 1 and defaults to 0
 
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
 
int channel =-1
 Channel number for the Comparator IP Core Channel. It takes values 0 to (number of IP Core channels-1) and defaults to -1 (test program executed for all channels)
 
uint mode = 0
 Mode take values from 0 to 5 and specifies the operator used to compare the first and second input. 0 is Equal To, 1 is Not Equal To, 2 is Greater Than, 3 is Greater Than or Equal To, 4 is Less Than, and 5 is Less Than or Equal To.
 

Function Documentation

void ComparatorUsage ( )

Usage:
./fpgawb_ipcore_comparator [-A Activate] [-b BoardNumber] [-c channelNumber] [-e Enable] [-m Mode]

Options Default value
-A Activate (0/1) 0
-b Board Number 0
-c channel Number (0-(Numchans-1) -1 (all channels)
-e Enable (0/1) 1
-m Mode (0-5) 0


Examples:
./fpgawb_ipcore_comparator -m3

int main ( int  argc,
char *  argv[] 
)

Step 1: OPEN DEVICE
ccurPMFC_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
ccurPMFC_Get_Driver_Info(handle, &binfo)
This call returns useful driver information and saves in the ccurpmfc_driver_info_t structure for later use.

Step 3: GET LIBRARY INFO
ccurPMFC_Get_Library_Info(handle, &linfo)
This call returns useful library information and saves in the ccurpmfc_library_info_t structure for later use.

Step 4: GET IP INFO
fpgawb_Comparator_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 COMPARATOR CHANNEL
fpgawb_Comparator_Activate_Ch(handle,chan,enable,activate)
This call activates the Comparator IP Core Channel by setting enable to 1. Note to set activate to 0 because we will be using the Config api calls which requires activate be 0. The default for activate is 0 in this test program. It is set to 1 at the end. Please be careful to give in the value as 0 when running the test program.

Step 6: CONFIGURE PARAMETERS
fpgawb_Comparator_Configure_Ch(handle, chan, &comparator_config)
This call programs the mode for the Comparator IP Core channel.

Step 7: ACTIVATE COMPARATOR CHANNEL
fpgawb_Comparator_Activate_Ch(handle,chan,1,1)
This call activates the Comparator IP core channel for Running after the configuration phase. Note that you put the activate to 0 before configuration so make it 1 now.

Step 8: CLOSE DEVICE
ccurPMFC_Close(handle)
Closes the device with the handle.