Logo
NGFC_NPhaseWaveGen_Demo

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

Variables

double starting_angle =0
 Starting angle of the main cos(x) and sin(x) cordic of the NPhase WaveGen IP Core Channel. It takes values -360 - 360 in degrees and defaults to 0 degree.
 
uint enable =1
 enable mode bit for the NPhase WaveGen 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 NPhase WaveGen 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
 
double frequency =10000
 Frequency of the carrier for the NPhase WaveGen IP Core in Hertz. It defaults to 10000 Hz.
 
uint waveform_type =0
 waveform_type takes values 0 to 3 where 0 is for Sin wave, 1 is for Square wave, 2 is for Ramp wave and 3 is for Triangle wave.
 
uint wavegen_signed =1
 wavegen_signed takes values 0 or 1 where 0 is unipolar waveform and 1 is bipolar waveform.
 
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 NPhase WaveGen 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 config_mode =0
 Configuration mode for the test program. Indicates to run the program in static mode or dynamic mode. It takes values 0-Configuration/1-Change Phase Increment/Amplitude/Phase on the fly. It defaults to 0.
 

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_NPhase_WaveGen_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 NPHASE WAVEGEN CHANNEL
fpgawb_NPhase_Wavegen_Activate_Ch(handle,chan,enable,activate)
This call activates the WaveGen IP Core Channel. 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/SETUP CHANNEL
C_fpgawb_NPhase_Wavegen_Configure_Ch(handle,chan,&config)
This call configures/setup the NPhase wavgen with parameters such as wave form type to be generated, unipolar/bipolar waveform type, starting angle.

Step 7: ACTIVATE NPHASE WAVEGEN CHANNEL
fpgawb_NPhase_Wavegen_Activate_Ch(handle,chan,1,1)
This call activates the WaveGen channel for Running 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 10: PROGRAM PHASE/AMPLITUDE CHANNEL
fpgawb_NPhase_Wavegen_Set_Ch_Phase_And_Amplitude(handle,channel,dynamic_config)
This call configures amplitude and phase of upto FPGAWB_IPCORE_NPHASE_WAVEGEN_MAXPHASES waveforms to be generated by NPhase wavegen.

Step 11: MSGDMA FIRE
fpgawb_IpCore_MsgDma_Fire(handle)
This call commences the MsgDma transfer

Step 12: RELEASE MSGDMA
ccrtNGFC_MsgDma_Release(handle)
This call releases the seized MsgDma. Release the MsgDma once done with the transfer

Step 13: SET CHANNEL PHASE INCREMENT
fpgawb_NPhase_Wavegen_Set_Ch_Frequency(handle,chan,frequency)
This call sets Frequency of the carrier in Hz for the NPhase WaveGen IP Core Channel.

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

void WaveGenUsage ( )

Usage:
./fpgawb_ipcore_nphase_wavegen [-A Activate] [-b BoardNumber] [-B BipolarMode] [-c channelNumber] [-C config_mode] [-e Enable] [-s StartAngle] [-w WaveMode]

Options Default value
-A Activate (0/1) 0
-b Board Number 0
-B Bipolar Mode (0/1) 1
-c channel Number (0-(Numchans-1) -1 (all channels)
-C Config Mode (0-Configuration/1-No Configuration- change Phase Increment) 0
-e Enable (0/1) 1
-s Starting Angle (-360 degrees - 360 degrees) 0
-w Wave Mode (0-Sin, 1-Square, 2-Ramp, 3-Triangle) 0


Examples:
SETUP: ./fpgawb_ipcore_nphase_wavegen -w0
RUNTIME:./fpgawb_ipcore_nphase_wavegen -C1 -w0