Software Programming Guide: PC-FPGA Interaction

Thanks to the Keysight Programming Libraries, FPGAs created with Keysight M3602A integrate seamlessly with the user application, commonly referred in Keysight documentation as VI (Virtual Instrument, Section Programming Tools).

Within M3602A, an FPGA Project can be compiled into an FPGA binary file (File ⇒ Generate FPGA...). With this file, the FPGA can be executed and controlled from the user application, e.g. the FPGA can be launched, paused, stopped, etc. VIs and FPGAs can also exchange data and signals.

This Section describes the programming functions designed to control FPGAs.

 

Programming Functions

SW Programming Overview Programming Libraries

Keysight provides highly optimized programming libraries to operate the Keysight M3602A FPGA Design Environment which is supported by the following modules: M3100A, M3102A, M3201A, M3202A, M3300A and M3302A with -FPGA option enabled.

 

SD_Module Configurations

The following configurations are used as parameters of the SD_Module functions (in the next section).

Addressing Mode

The addressing mode configuration is used for selecting how the provided address is used in an Input/Output transaction.

 

Option Description Programming Definitions Name Value
Auto Increment Initial address is incremented after each access ADDRESSING_AUTOINCREMENT 0
Fixed Initial address is used for the whole access ADDRESSING_FIXED 1

 

In object-oriented languages, this configuration is implemented inside the SD_AddressingMode namespace.

 

Accessing Mode

The accessing mode configuration is used for using DMA technology or not in memory Input/Output operations.

 

Option Description Programming Definitions Name Value
Non DMA Memory access are split in several one double word accesses NONDMA 0
DMA memory access is done with one DMA transaction DMA 1

 

In object-oriented languages, this configuration is implemented inside the SD_AccessMode namespace.

 

Reset Mode

The reset mode configuration is used for selecting the reset signal mode type of FPGA.

 

Option Description Programming Definitions Name Value
Low Low active reset RESET_LOW 0
High High active reset RESET_HIGH 1
Pulse Pulse reset RESET_PULSE 2

 

In object-oriented languages, this configuration is implemented inside the SD_ResetMode namespace.

 

SD_Module Functions

FPGAwritePCport

This function writes data at the PCport FPGA Block.

Properties
Name Description
Inputs  
moduleID (Non-object-oriented languages only) Module identifier, returned by function open in Section 2.4.2.1.
nPCport PCport number
data Data buffer to write through PC port to FPGA
dataSize Number of 32-bit words to write (maximum is 128 words)
address Address that will appear on the PCport interface
addressMode Write addressing mode desired Section 2.1.2.1
accessMode Write accessing mode desired Section 2.1.2.2
errorIn (LabVIEW only) If it contains an error, the function will not be executed, and errorIn will be passed to errorOut
   
Outputs  
moduleIDout (LabVIEW only) A copy of moduleID
errorOut Error Codes

 

C

int SD_Module_FPGAwritePCport(int moduleID, int nPCport, int* data, int dataSize, int address,

int addressMode, int accessMode);

 

C++

int SD_Module::FPGAwritePCport(int nPCport, int* data, int dataSize, int address, SD_

AddressingMode addressMode, SD_AccessMode accessMode);

 

Visual Studio .NET, MATLAB

int SD_Module::FPGAwritePCport(int nPCport, int [] data, int address, SD_AddressingMode

addressMode, SD_AccessMode accessMode);

 

Python

int SD_Module::FPGAwritePCport(int nPCport, int [] data, int address, int addressMode, int

accessMode);

 

LabVIEW

FPGAwritePCport .vi

 

FPGAreadPCport

This function reads data at the PCport FPGA Block.

Properties
Name Description
Inputs  
moduleID (Non-object-oriented languages only) Module identifier, returned by function open in Section 2.4.2.1.
nPCport PCport number
dataSize Number of 32-bit words to read (maximum is 128 words)
address Address that will appear on the PCport interface
addressMode Read addressing mode desired Section 2.1.2.1
accessMode Read accessing mode desired Section 2.1.2.2
errorIn (LabVIEW only) If it contains an error, the function will not be executed, and errorIn will be passed to errorOut
   
Outputs  
data Rx data buffer
moduleIDout (LabVIEW only) A copy of moduleID
errorOut Error Codes

 

C

int SD_Module_FPGAreadPCport(int moduleID, int nPCport, int* data, int dataSize, int address, int

addressMode, int accessMode);

 

C++

int SD_Module::FPGAreadPCport(int nPCport, int* data, int dataSize, int address, SD_

AddressingMode addressMode, SD_AccessMode accessMode);

 

Visual Studio .NET, MATLAB

int SD_Module::FPGAreadPCport(int nPCport, int address, int[] data, SD_AddressingMode

addressMode, SD_AccessMode accessMode);

 

Python

{int[], int} SD_Module::FPGAreadPCport(int nPCport, int dataSize, int address, int addressMode, int

accessMode);

*Returned data array is a NumPy array.

 

LabVIEW

FPGAreadPCport.vi

 

FPGAload

This function loads a bitstream file generated using M3602A software to FPGA.

 

Properties
Name Description
Inputs  
moduleID (Non-object-oriented languages only) Module identifier, returned by function open in Section 2.4.2.1.
fileName File to load
errorIn (LabVIEW only) If it contains an error, the function will not be executed, and errorIn will be passed to errorOut
   
Outputs  
moduleIDout (LabVIEW only) A copy of moduleID
errorOut Error Codes

 

C

int SD_Module_FPGAload(int moduleID, const char *fileName);

 

C++

int FPGAload(const char *fileName);

 

Visual Studio .NET, MATLAB

int FPGAload(string fileName);

 

Python

int FPGAload(string fileName);

 

LabVIEW

load.vi

 

FPGAreset

This function sends a reset signal to FPGA.

 

Properties

Name Description
Inputs  
moduleID (Non-object-oriented languages only) Module identifier, returned by function open in Section 2.4.2.1.
mode Reset mode desired Section 2.1.2.3
errorIn (LabVIEW only) If it contains an error, the function will not be executed, and errorIn will be passed to errorOut
   
Outputs  
moduleIDout (LabVIEW only) A copy of moduleID
errorOut Error Codes

 

C

int SD_Module_FPGAreset(int moduleID, int mode);

 

C++

int FPGAreset(SD_ResetMode::SD_ResetMode mode);

 

Visual Studio .NET, MATLAB

int FPGAreset(SD_ResetMode mode);

 

Python

int FPGAreset(int mode);

 

LabVIEW

reset.vi

 

Error Codes

error codes  
#define SD_STATUS_OK 0
#define SD_ERROR_NONE 0
#define SD_STATUS_DEMO 1
#define SD_ERROR_OFFSET -8000

 

Open and Close Errors

Open and Close Errors  
//Open and Close Errors  
#define SD_ERROR_OPENING_MODULE -8000
#define SD_ERROR_OPENING_MODULE_STRING "Keysight Error: Opening module"
   
#define SD_ERROR_CLOSING_MODULE -8001
#define SD_ERROR_CLOSING_MODULE_STRING "Keysight Error: Closing module"
   
#define SD_ERROR_OPENING_HVI -8002
#define SD_ERROR_OPENING_HVI_STRING "Keysight Error: Opening HVI"
   
#define SD_ERROR_CLOSING_HVI -8003
#define SD_ERROR_CLOSING_HVI_STRING "Keysight Error: Closing HVI"
   
#define SD_ERROR_MODULE_NOT_OPENED -8004
#define SD_ERROR_MODULE_NOT_OPENED_STRING "Keysight Error: Module not opened"
   
#define SD_ERROR_MODULE_NOT_OPENED_BY_USER -8005
#define SD_ERROR_MODULE_NOT_OPENED_BY_USER_STRING "Keysight Error: Module not opened by user"
   
#define SD_ERROR_MODULE_ALREADY_OPENED -8006
#define SD_ERROR_MODULE_ALREADY_OPENED_STRING "Keysight Error: Module already opened"
   
#define SD_ERROR_HVI_NOT_OPENED -8007
#define SD_ERROR_HVI_NOT_OPENED_STRING "Keysight Error: HVI not opened"

 

ID Errors

ID Errors  
   
#define SD_ERROR_INVALID_OBJECTID -8008
#define SD_ERROR_INVALID_OBJECTID_STRING "Keysight Error: Invalid ObjectID"
   
#define SD_ERROR_INVALID_MODULEID -8009
#define SD_ERROR_INVALID_MODULEID_STRING "Keysight Error: Invalid ModuleID"
   
#define SD_ERROR_INVALID_MODULEUSERNAME -8010
#define SD_ERROR_INVALID_MODULEUSERNAME_STRING "Keysight Error: Invalid Module User Name"
   
#define SD_ERROR_INVALID_HVIID -8011
#define SD_ERROR_INVALID_HVIID_STRING "Keysight Error: Invalid HVI"
   
#define SD_ERROR_INVALID_OBJECT -8012
#define SD_ERROR_INVALID_OBJECT_STRING "Keysight Error: Invalid Object"
   
#define SD_ERROR_INVALID_NCHANNEL -8013
#define SD_ERROR_INVALID_NCHANNEL_STRING "Keysight Error: Invalid channel number"
   
#define SD_ERROR_BUS_DOES_NOT_EXIST -8014
#define SD_ERROR_BUS_DOES_NOT_EXIST_STRING "Keysight Error: Bus doesn't exist"
   
#define SD_ERROR_BITMAP_ASSIGNED_DOES_NOT_EXIST -8015
#define SD_ERROR_BITMAP_ASSIGNED_DOES_NOT_EXIST_STRING "Keysight Error: Any input assigned to the bitMap does not exist"
   
#define SD_ERROR_BUS_INVALID_SIZE -8016
#define SD_ERROR_BUS_INVALID_SIZE_STRING "Keysight Error: Input size does not fit on this bus"
   
#define SD_ERROR_BUS_INVALID_DATA -8017
#define SD_ERROR_BUS_INVALID_DATA_STRING "Keysight Error: Input data does not fit on this bus"
   
#define SD_ERROR_INVALID_VALUE -8018
#define SD_ERROR_INVALID_VALUE_STRING "Keysight Error: Invalid value"
   
#define SD_ERROR_CREATING_WAVE -8019
#define SD_ERROR_CREATING_WAVE_STRING "Keysight Error: Creating Waveform"
   
#define SD_ERROR_NOT_VALID_PARAMETERS -8020
#define SD_ERROR_NOT_VALID_PARAMETERS_STRING "Keysight Error: Invalid Parameters"
   
#define SD_ERROR_AWG -8021
#define SD_ERROR_AWG_STRING "Keysight Error: AWG function failed"
   
#define SD_ERROR_DAQ_INVALID_FUNCTIONALITY -8022
#define SD_ERROR_DAQ_INVALID_FUNCTIONALITY_STRING "Keysight Error: Invalid DAQ functionality"
   
#define SD_ERROR_DAQ_POOL_ALREADY_RUNNING -8023
#define SD_ERROR_DAQ_POOL_ALREADY_RUNNING_STRING "Keysight Error: DAQ buffer pool is already running"
   
#define SD_ERROR_UNKNOWN -8024
#define SD_ERROR_UNKNOWN_STRING "Keysight Error: Unknown error"
   
#define SD_ERROR_INVALID_PARAMETERS -8025
#define SD_ERROR_INVALID_PARAMETERS_STRING "Keysight Error: Invalid parameter"
   
#define SD_ERROR_MODULE_NOT_FOUND -8026
#define SD_ERROR_MODULE_NOT_FOUND_STRING "Keysight Error: Module not found"
   
#define SD_ERROR_DRIVER_RESOURCE_BUSY -8027
#define SD_ERROR_DRIVER_RESOURCE_BUSY_STRING "Keysight Error: Driver resource busy"
   
#define SD_ERROR_DRIVER_RESOURCE_NOT_READY -8028
#define SD_ERROR_DRIVER_RESOURCE_NOT_READY_STRING "Keysight Error: Driver resource not ready"
   
#define SD_ERROR_DRIVER_ALLOCATE_BUFFER -8029
#define SD_ERROR_DRIVER_ALLOCATE_BUFFER_STRING "Keysight Error: Cannot allocate buffer in driver"
   
#define SD_ERROR_ALLOCATE_BUFFER -8030
#define SD_ERROR_ALLOCATE_BUFFER_STRING "Keysight Error: Cannot allocate buffer"
   
#define SD_ERROR_RESOURCE_NOT_READY -8031
#define SD_ERROR_RESOURCE_NOT_READY_STRING "Keysight Error: Resource not ready"
   
#define SD_ERROR_HARDWARE -8032
#define SD_ERROR_HARDWARE_STRING "Keysight Error: Hardware error"
   
#define SD_ERROR_INVALID_OPERATION -8033
#define SD_ERROR_INVALID_OPERATION_STRING "Keysight Error: Invalid Operation"
   
#define SD_ERROR_NO_COMPILED_CODE -8034
#define SD_ERROR_NO_COMPILED_CODE_STRING "Keysight Error: No compiled code in the module"
   
#define SD_ERROR_FW_VERIFICATION -8035
#define SD_ERROR_FW_VERIFICATION_STRING "Keysight Error: Firmware verification failed"
   
#define SD_ERROR_COMPATIBILITY -8036
#define SD_ERROR_COMPATIBILITY_MODULE_STRING "Keysight Error: Compatibility error"
   
#define SD_ERROR_INVALID_TYPE -8037
#define SD_ERROR_INVALID_TYPE_STRING "Keysight Error: Invalid type"
   
#define SD_ERROR_DEMO_MODULE -8038
#define SD_ERROR_DEMO_MODULE_STRING "Keysight Error: Demo module"
   
#define SD_ERROR_INVALID_BUFFER -8039
#define SD_ERROR_INVALID_BUFFER_STRING "Keysight Error: Invalid buffer"
   
#define SD_ERROR_INVALID_INDEX -8040
#define SD_ERROR_INVALID_INDEX_STRING "Keysight Error: Invalid index"
   
#define SD_ERROR_INVALID_NHISTOGRAM -8041
#define SD_ERROR_INVALID_NHISTOGRAM_STRING "Keysight Error: Invalid histogram number"
   
#define SD_ERROR_INVALID_NBINS -8042
#define SD_ERROR_INVALID_NBINS_STRING "Keysight Error: Invalid number of bins"
   
#define SD_ERROR_INVALID_MASK -8043
#define SD_ERROR_INVALID_MASK_STRING "Keysight Error: Invalid mask"
   
#define SD_ERROR_INVALID_WAVEFORM -8044
#define SD_ERROR_INVALID_WAVEFORM_STRING "Keysight Error: Invalid waveform"
   
#define SD_ERROR_INVALID_STROBE -8045
#define SD_ERROR_INVALID_STROBE_STRING "Keysight Error: Invalid strobe"
   
#define SD_ERROR_INVALID_STROBE_VALUE -8046
#define SD_ERROR_INVALID_STROBE_VALUE_STRING "Keysight Error: Invalid strobe value"
   
#define SD_ERROR_INVALID_DEBOUNCING -8047
#define SD_ERROR_INVALID_DEBOUNCING_STRING "Keysight Error: Invalid debouncing"
   
#define SD_ERROR_INVALID_PRESCALER -8048
#define SD_ERROR_INVALID_PRESCALER_STRING "Keysight Error: Invalid prescaler"
   
#define SD_ERROR_INVALID_PORT -8049
#define SD_ERROR_INVALID_PORT_STRING "Keysight Error: Invalid port"
   
#define SD_ERROR_INVALID_DIRECTION -8050
#define SD_ERROR_INVALID_DIRECTION_STRING "Keysight Error: Invalid direction"
   
#define SD_ERROR_INVALID_MODE -8051
#define SD_ERROR_INVALID_MODE_STRING "Keysight Error: Invalid mode"
   
#define SD_ERROR_INVALID_FREQUENCY -8052
#define SD_ERROR_INVALID_FREQUENCY_STRING " Keysight Error: Invalid frequency"
   
#define SD_ERROR_INVALID_IMPEDANCE -8053
#define SD_ERROR_INVALID_IMPEDANCE_STRING "Keysight Error: Invalid impedance"
   
#define SD_ERROR_INVALID_GAIN -8054
#define SD_ERROR_INVALID_GAIN_STRING "Keysight Error: Invalid gain"
   
#define SD_ERROR_INVALID_FULLSCALE -8055
#define SD_ERROR_INVALID_FULLSCALE_STRING "Keysight Error: Invalid fullscale"
   
#define SD_ERROR_INVALID_FILE -8056
#define SD_ERROR_INVALID_FILE_STRING "Keysight Error: Invalid file"
   
#define SD_ERROR_INVALID_SLOT -8057
#define SD_ERROR_INVALID_SLOT_STRING "Keysight Error: Invalid slot"
   
#define SD_ERROR_INVALID_NAME -8058
#define SD_ERROR_INVALID_NAME_STRING "Keysight Error: Invalid product name"
   
#define SD_ERROR_INVALID_SERIAL -8059
#define SD_ERROR_INVALID_SERIAL_STRING "Keysight Error: Invalid serial number"
   
#define SD_ERROR_INVALID_START -8060
#define SD_ERROR_INVALID_START_STRING "Keysight Error: Invalid start"
   
#define SD_ERROR_INVALID_END -8061
#define SD_ERROR_INVALID_END_STRING "Keysight Error: Invalid end"
   
#define SD_ERROR_INVALID_CYCLES -8062
#define SD_ERROR_INVALID_CYCLES_STRING "Keysight Error: Invalid number of cycles"
   
#define SD_ERROR_HVI_INVALID_NUMBER_MODULES -8063
#define SD_ERROR_HVI_INVALID_NUMBER_MODULES_STRING "Keysight Error: Invalid number of modules on HVI"
   
#define SD_ERROR_DAQ_P2P_ALREADY_RUNNING -8064
#define SD_ERROR_DAQ_P2P_ALREADY_RUNNING_STRING "Keysight Error: DAQ P2P is already running"