Logo
NGFC_Recorder_Demo

Demo program for Recorder 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 RecorderUsage ()
 
void intHandler ()
 
int main (int argc, char *argv[])
 

Variables

uint enable =1
 enable mode bit for the Recorder 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 Recorder 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
 
fpgawb_ipcore_recorder_config_t config
 fpgawb_ipcore_recorder_config_t struct passed as argument for setting the initialization parameters for the Recorder IP Core channel. Check fpgawb_lib.h or api call documentation for more information
 
fpgawb_ipcore_recorder_info_t info
 fpgawb_ipcore_recorder_info_t struct passed as argument for reading the status information for the Recorder IP Core channel. Check fpgawb_lib.h or api call documentation for more information
 
uint timestamp_enable = 0
 timestamp_enable is the mode bit to enable internally generated timestamp for the Recorder IP Core channel. It takes value 0 or 1. When set to 1 a timestamp will be internally generated and placed in the lower 16 bits of the recorded data.
 
uint test_mode = 0
 test_mode is the mode bit to enable internal test mode for the Recorder IP Core channel. It takes value 0 or 1. When set to 1 the channel will be put in a test mode where the data to be recorded comes from internal counters.
 
uint trigger_mode = 0
 trigger_mode enables registering timestamp when trigger occurs for the Recorder IP Core channel. It takes value 0 or 1. When set to 1 the timestamp of when trigger occured for the channel will be registered.
 
_ccrtngfc_msgdma_engine_t MsgDmaEngine = 5
 MsgDmaEngine is the MsgDmaEngineto be used for Recording/Playing back. It takes value 0 to 4 where 0-2 are Quad-word MsgDma transfers and 3-4 are Single-word MsgDma transfers.
 
fpgawb_ipcore_recorder_data_t record_data [FPGA_MAX_RECORDER_CHANNELS]
 fpgawb_ipcore_recorder_data_t struct passed as argument for recording the data for the Recorder IP Core channel. Check fpgawb_lib.h or api call documentation for more information
 
fpgawb_ipcore_recorder_data_t playback_data [FPGA_MAX_RECORDER_CHANNELS]
 fpgawb_ipcore_recorder_data_t struct passed as argument for playing back the data for the Recorder IP Core channel. Check fpgawb_lib.h or api call documentation for more information
 
fpgawb_ipcore_recorder_transfer_length_t config_length [5]
 
fpgawb_ipcore_msgdma_config_t msgdma_config [5]
 
double start_time [FPGA_MAX_RECORDER_CHANNELS]
 Start time of the playback. This is used to identify the starting record of the playback.
 
double end_time [FPGA_MAX_RECORDER_CHANNELS]
 End time of the playback. This is used to identify the last record of the playback.
 
double sampling_frequency [FPGA_MAX_RECORDER_CHANNELS]
 Sampling frequency of the recorded data. This is used to compute the start and end record of the playback.
 
long start_record [FPGA_MAX_RECORDER_CHANNELS]
 Start record of the playback. It is computed using start_time/(1/sampling_frequency)
 
long end_record [FPGA_MAX_RECORDER_CHANNELS]
 End record of the playback. It is computed using end_time/(1/sampling_frequency)
 
uint record_channel_mask = 0
 The parameter record_channel_mask is a 16 bit mask where each bit corresponds to the respective Recorder IP Core channel. It takes value 0 or 1. A value of 1 means recording is enabled for that channel.
 
uint playback_channel_mask = 0
 The parameter playback_channel_mask is a 16 bit mask where each bit corresponds to the respective Recorder IP Core channel. It takes value 0 or 1. A value of 1 means playback is enabled for the channel.
 
uint channel_mask = 0
 The parameter channel_mask is a 16 bit mask where each bit corresponds to the respective Recorder IP Core channel. It takes value 0 or 1. A value of 1 means record/playback for the channel is enabled.
 
uint nrecord_channels = 0
 Number of recorder channels enabled.
 
uint nplayback_channels = 0
 Number of playback channels enabled.
 
uint msgdmaengine_mask = 0
 The parameter msgdmaengine_mask is a 5 bit mask where each bit corresponds to the respective MsgDmaEngine. It takes value 0 or 1. A value of 1 indicates that the MsgDmaEngine is being used for record/playback and 0 otherwise.
 
uint print =0
 Displays debug information. It takes value 0 or 1. A value of 0 means no debug information is printed. A value of 1 means it prints information such as when the buffer is full, number of elements in the buffer, indicates when the buffer is flushed onto the file.
 

Function Documentation

void intHandler ( )

Step 17: RESET RECORDER CHANNEL
fpgawb_Recorder_Activate(handle,0,0)
This call resets the Recorder IP core channel.

Step 18: RELEASE MSGDMA ENGINE
ccrtNGFC_MsgDma_Release(handle,MsgDmaEngine)
This call releases the seized MsgDmaEngine.

Step 19: CLOSE DEVICE
ccrtNGFC_Close(handle)
This api call closes the device.

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_Recorder_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 RECORDER CHANNEL
fpgawb_Recorder_Activate_Ch(handle,enable_channel_mask,activate_channel_mask)
This call activates the Recorder IP Core Channel by setting board_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 RECORDER CHANNEL
C_fpgawb_Recorder_Configure(handle,record_channel_mask,playback_channel_mask,&config)
This api call configures the initialization parameters such as watermark, timestamp_enable etc for the Recorder IP Core channel.

Step 7: SEIZE MSGDMA
ccrtNGFC_MsgDma_Seize(handle,&MsgDmaEngine)
Seizes the MsgDma for data transfer.

Step 8: MSGDMA INITIALIZE
fpgawb_IpCore_MsgDmaEngine_Initialize_Plus(handle,MsgDmaEngine,&IpCodeSelect,&msgdma_config[MsgDmaEngine-1])
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 9: ENABLE RECORDING
fpgawb_Recorder_Set_Record(handle,channel_mask,record_channel_mask)
This api call enables/pauses recording for the Recorder IP Core channel.

Step 10: ENABLE PLAYBACK
fpgawb_Recorder_Set_Playback(handle,channel_mask,playback_channel_mask)
This api call enables/pauses playback for the Recorder IP Core channel.

Step 11: ACTIVATE RECORDER CHANNEL
fpgawb_Recorder_Activate_Ch(handle,board_enable_channel_mask,activate_channel_mask)
This call enables the output enable for the Recorder IP core channel after the configuration phase. It is done by setting activate to 1.

Step 12: GET STATUS INFORMATION for RECORDER CHANNEL
fpgawb_Recorder_Get_Info(handle,&info)
This api call gets the status information such as almost_full, almost_empty etc for the Recorder IP Core channel.

Step 13: CONFIGURES MSGDMA DESCRIPTOR LENGTH
fpgawb_Recorder_MsgDmaEngine_Config(handle,msgdmaengine_mask,config_length)
This configures the MsgDma descriptor size for the Recorder IP core channel. Please refer to api call documentaion for more information on configuring the parameters.

Step 14: WRITE PLAYBACK DATA
fpgawb_Recorder_Write_Data(handle,info.playback_almost_empty,playback_data)
This call writes data to playback by the Recorder IP core channel.

Step 15: MSGDMA FIRE
fpgawb_IpCore_MsgDmaEngine_Fire(handle,MsgDmaEngine)
This call commences the MsgDma transfer from the fpga to physical memory, which contains the data recorded by the Recorder IP core channel.

Step 16: READ RECORDED DATA
fpgawb_Recorder_Read_Data(handle,info.record_almost_full,record_data)
This call reads the data recorded in the FIFO by the Recorder IP core channel.

void RecorderUsage ( )

Usage:
./fpgawb_ipcore_recorder [-b BoardNumber] [-d Directory] [-h HeadRoom] [-p Print] [-s BufferSize] [-x MsgDmaEngine]

Options Default value
-b Board Number 0
-d Directory Current directory
-h Headroom for Playback FIFO 1000

-p Print (0-No debug information displayed | 1- prints debug information) | 0 -s Buffer Size (Bytes) | (1073741824) 1GB -x MsgDmaEngine | 5
Examples:
./fpgawb_ipcore_recorder
./fpgawb_ipcore_recorder -b0 -d/home/abc/ -x5
The program records the data in binary format. The recorded data has to be converted to hex/deciaml format for viewing or playing it back. The program has two buffers buffer1 and buffer2. The size can be mentioned using -s option. When the buffer is almost full, the data is flushed to the file in binary format.
We use two buffers as a ping-pong buffer to handle missing any data during the flushing process.

Variable Documentation

fpgawb_ipcore_recorder_transfer_length_t config_length[5]

The parameter fpgawb_ipcore_recorder_transfer_length_t struct has one field transfer_length. The config_length is a struct array of size 5 where each index corresponds to each MsgDmaEngine. The tansfer_length field of the struct contains the size of the data transfer in bytes. When the fpgawb_IpCore_MsgDma_Initialize_Plus api call is called the descriptors for all the recorder channels are initialized first followed by the descriptors of the playback channels. The same is followed when indexing the transfer_length array to change the size of transfer. Eg: If User wants to record data for channel 0 and 1 using Engine 2 and playback the data on channel 4 and 5 using Engine 2, we have a total of 4 channels to record/playback in this setup, then config[1].transfer_length[0] and config[1].transfer_length[1] will have the transfer sizes corresponding to the recorder channels and config[1].transfer_length[2] and config[1].transfer_length[3] will have the transfer sizes corresponding to the playback channels.

fpgawb_ipcore_msgdma_config_t msgdma_config[5]

The parameter fpgawb_ipcore_msgdma_config_t struct passed as argument for initializing/configuring MsgDma descriptors for the Recorder IP Core channel. Check fpgawb_lib.h or api call documentation for more information