Logo
Counter_Demo

Demo program for Counter 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 Usage (char *pname, char *error_description)
 
int main (int argc, char *argv[])
 

Variables

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 Counter 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_counter_config_t counter_config
 fpgawb_ipcore_counter_config_t struct passed as argument to the Config api call for configuring the parameters for the respective Counter IP Core channel. Check fpgawb_lib.h or api call documentation for more information
 
uint start = 1
 t specifies the start bit. It takes value 0 or 1.
 
uint enable = 1
 This specifies the enable bit. It takes value 0 or 1 and defaults to 1.
 
uint hw_mode = 0
 h specifies the hw_mode. It takes value 0 or 1.
 
uint start_mode = 0
 m specifies the start mode. It takes value 0 or 1.
 
uint start_value = 0
 s specifies the start value. Start value takes positive values from 0 to 2^32 - 1.
 
uint end_value = 512
 e specifies the end value. End value takes positive values from 1 to 2^32 - 1.
 
uint increment = 1
 i specifies the increment value. Increment takes values from 1 to 2^32 - 1.
 
uint config_mode = 0
 C specifies the config mode. Config mode takes values 0 or 1. Static Configuration(0) reconfigures the static/configuration parameters set by user or defaults. Dynamic Configuration(1) only changes the dynamic parameters, such as increment (i) and start (t).
 

Function Documentation

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_Counter_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 CHANNEL
fpgawb_Counter_Activate(handle, chan, enable)
This call programs the enable bit

Step 6: CONFIGURE CHANNEL
fpgawb_Counter_Configure_Ch(handle, chan, &counter_config)
This call programs the enable, start, stop, hw_mode, and start_mode values

Step 7: SET INCREMENT
fpgawb_Counter_Set_Increment(handle, chan, increment)
This call programs the increment value of the counter if the increment value was changed in the dynamic configuration mode

Step 8: START
fpgawb_Counter_Start(handle, chan, start)
This call programs the start value for the counter if the start value was changed in the dynamic configuration mode

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

void Usage ( char *  pname,
char *  error_description 
)

Usage:
./fpgawb_ipcore_counter [-b BoardNumber] [-c channelNumber] [-s StartValue] [-e EndValue] [-i Increment] [-h HWMode] [-m StartMode] [-C ConfigMode] [-t Start]\n

Options Default value
-b Board Number 0
-c channel Number -1 (all channels)
-s start value (0 to 2^32 - 1) 0
-e end value (1 to 2^32 - 1) 0xFFFFFFFF
-i increment (1 to 2^32 - 1) 1
-h hw mode (0 or 1) 0
-m start mode (0 or 1) 0
-C Config mode (static- 0, dynamic- 1) 0
-t Start (0 or 1) 1


Examples:
./fpgawb_ipcore_counter -s0 -e128
./fpgawb_ipcore_counter -s10 -e2000
./fpgawb_ipcore_counter -s0 -e4096 -h1
./fpgawb_ipcore_counter -i10 -t1 -C1