PSOC E8XXGP Device Support Library

General Description

Functions

cy_en_nnlite_status_t Cy_NNLite_Init (NNLITE_Type *nnlite, cy_nnlite_context_t *context)
 nnlite driver init function, validate context structure and set driver to init state More...
 
cy_en_nnlite_status_t Cy_NNLite_DeInit (NNLITE_Type *nnlite, cy_nnlite_context_t *context)
 nnlite driver deinit function check's for pending or ongoing operation and set driver state to deinit More...
 
cy_en_nnlite_status_t Cy_NNLite_Start (NNLITE_Type *nnlite, cy_nnlite_context_t *context)
 nnlite start operation, streamer should should be configured before calling this function, this function will write to start bit in CMD MEMIO More...
 
cy_en_nnlite_status_t Cy_NNLite_Stop (NNLITE_Type *nnlite, cy_nnlite_context_t *context)
 nnlite stop/abort operation, can be used to stop/abort current operation or to reset all configuration, API write abort in CMD MEMIO which will reset all the registers More...
 
cy_en_nnlite_status_t Cy_NNLite_ActivationStreamerCfg (NNLITE_Type *nnlite, cy_nnlite_context_t *context, uint32_t filterWidth, uint32_t filterHeight, uint32_t activationRepeats, uint32_t inputWidth, uint32_t inputHeight, uint32_t inputChannel, int16_t padVal, uint8_t padWidth, uint8_t padHeight, uint8_t strideCol, uint8_t strideRow, int32_t inputOffset)
 nnlite activation streamer configuration set, API will configure parameters for activation streamer More...
 
cy_en_nnlite_status_t Cy_NNLite_WeightStreamerCfg (NNLITE_Type *nnlite, cy_nnlite_context_t *context, uint32_t weightPerNeuron, int32_t filterOffset)
 nnlite weight streamer configuration set, API will configure offset for weight streamer and weights per neuron parameter* More...
 
cy_en_nnlite_status_t Cy_NNLite_OutputStreamerCfg (NNLITE_Type *nnlite, cy_nnlite_context_t *context, cy_nnlite_clipping_t clipping, int32_t outputOffset, uint32_t outputWidth, uint32_t outputHeight, uint32_t outputChannels)
 nnlite out streamer configuration set, API will set clipping mask, offset, width, height and channel for output streamer More...
 
cy_en_nnlite_status_t Cy_NNLite_StreamerBaseAddrSet (NNLITE_Type *nnlite, cy_en_nnlite_streamer_id_t strmId, const void *baseAddr)
 set nnlite streamer base address More...
 
static cy_en_nnlite_status_t Cy_NNLite_PipelineConfig (NNLITE_Type *nnlite, cy_en_nnlite_op_t opType, cy_en_nnlite_mode_t fetchMode, bool repeatWeights, bool biasEn, bool sparsityEn, cy_en_nnlite_output_rescaling_t outputRescaling, cy_en_nnlite_input_rescaling_t inputRescaling, cy_en_nnlite_fused_activation_t actType, cy_en_nnlite_activation_size_t inputSize, cy_en_nnlite_activation_size_t weightSize, cy_en_nnlite_output_size_t outputSize)
 Set NNLiteV2 pipeline configuration. More...
 
cy_en_nnlite_status_t Cy_NNLite_SetPrePostScaling (NNLITE_Type *nnlite, float preScalingFactor, const float *postScalingFactors)
 Set pre/post arithmetic/accumulation scaling. More...
 
cy_en_nnlite_status_t Cy_NNLite_SetInterpolationParam (NNLITE_Type *nnlite, uint32_t segment, float gradient)
 set interpolation parameter More...
 
cy_en_nnlite_status_t Cy_NNLite_FFTCfg (NNLITE_Type *nnlite, cy_nnlite_context_t *context, void *ppBuf0, void *ppBuf1, unsigned int fftStages)
 Configure NNLite for Q1.15 complex FFT. More...
 
cy_en_nnlite_status_t Cy_NNLite_SetInterruptMask (NNLITE_Type *nnlite, uint32_t intrMask)
 nnlite set interrupt mask, available interrupt are operation STATUS Done, MEM Fetch Error different streamers, Output Saturation interrupt More...
 
cy_en_nnlite_status_t Cy_NNLite_DatawireTriggerEnable (NNLITE_Type *nnlite, bool trigEn)
 nnlite set datawire trigger control, trigger datawire for next layer when trigger is 1 More...
 
cy_en_nnlite_status_t Cy_NNLite_GetOperationStatus (NNLITE_Type *nnlite, uint32_t *opStatus)
 nnlite get nnlite operation status, can be used to poll operation status More...
 
cy_en_nnlite_status_t Cy_NNLite_GetInterruptStatus (NNLITE_Type *nnlite, uint32_t *intrStatus)
 get nnlite interrupt status More...
 
cy_en_nnlite_status_t Cy_NNLite_GetInterruptMask (NNLITE_Type *nnlite, uint32_t *intrMask)
 get nnlite interrupt mask More...
 
cy_en_nnlite_status_t Cy_NNLite_GetDriverState (NNLITE_Type *nnlite, cy_nnlite_context_t *context, cy_en_nnlite_state_t *nnliteState)
 get nnlite driver state More...
 
cy_en_nnlite_status_t Cy_NNLite_InterruptClear (NNLITE_Type *nnlite, uint32_t intrMask)
 clear nnlite interrupts More...
 
void Cy_NNLite_InterruptHandler (NNLITE_Type *nnlite, cy_nnlite_context_t *context)
 nnlite ISR handler More...
 
cy_en_nnlite_status_t Cy_NNLite_WaitForCompletion (NNLITE_Type *nnlite, cy_nnlite_context_t *context)
 wait for completion of operation in busy loop More...
 

Function Documentation

◆ Cy_NNLite_Init()

cy_en_nnlite_status_t Cy_NNLite_Init ( NNLITE_Type nnlite,
cy_nnlite_context_t context 
)

nnlite driver init function, validate context structure and set driver to init state

Parameters
[in]nnlitebase pointer of NNLite Register Map.
[in]contextpointer to the driver context structure.
Return values
Refercy_en_nnlite_status_t

[in] context pointer to the driver context structure

◆ Cy_NNLite_DeInit()

cy_en_nnlite_status_t Cy_NNLite_DeInit ( NNLITE_Type nnlite,
cy_nnlite_context_t context 
)

nnlite driver deinit function check's for pending or ongoing operation and set driver state to deinit

Parameters
[in]nnlitebase pointer of NNLIte register map.
[in]contextpointer to the driver context structure.
Return values
Refercy_en_nnlite_status_t

[in] nnlite base pointer of register map.

[in] context pointer to the driver context structure

◆ Cy_NNLite_Start()

cy_en_nnlite_status_t Cy_NNLite_Start ( NNLITE_Type nnlite,
cy_nnlite_context_t context 
)

nnlite start operation, streamer should should be configured before calling this function, this function will write to start bit in CMD MEMIO

Parameters
[in]nnlitebase pointer of NNLIte register map.
[in]contextpointer to the driver context structure.
Return values
Refercy_en_nnlite_status_t

[in] nnlite base pointer of register map.

[in] context pointer to the driver context structure

◆ Cy_NNLite_Stop()

cy_en_nnlite_status_t Cy_NNLite_Stop ( NNLITE_Type nnlite,
cy_nnlite_context_t context 
)

nnlite stop/abort operation, can be used to stop/abort current operation or to reset all configuration, API write abort in CMD MEMIO which will reset all the registers

Parameters
[in]nnlitebase pointer of NNLIte register map.
[in]contextpointer to the driver context structure.
Return values
Refercy_en_nnlite_status_t

[in] nnlite base pointer of register map.

[in] context pointer to the driver context structure

◆ Cy_NNLite_ActivationStreamerCfg()

cy_en_nnlite_status_t Cy_NNLite_ActivationStreamerCfg ( NNLITE_Type nnlite,
cy_nnlite_context_t context,
uint32_t  filterWidth,
uint32_t  filterHeight,
uint32_t  activationRepeats,
uint32_t  inputWidth,
uint32_t  inputHeight,
uint32_t  inputChannel,
int16_t  padVal,
uint8_t  padWidth,
uint8_t  padHeight,
uint8_t  strideCol,
uint8_t  strideRow,
int32_t  inputOffset 
)

nnlite activation streamer configuration set, API will configure parameters for activation streamer

Parameters
[in]nnlitebase pointer of NNLIte register map.
[in]contextpointer to the driver context structure
[in]filterWidthfilter width
[in]filterHeightfFilter height
[in]activationRepeatsactivation streamer repeat count (how often each "kernel footprint" needs to be fetched)
[in]inputWidthinput activation Width
[in]inputHeightinput activation Height
[in]inputChannelinput activation channels
[in]inputChannelchannel depth multiplier (depthwise convolution only)
[in]padValpadding value
[in]padHeightpadding Height
[in]padWidthpadding Width
[in]strideColStride column
[in]strideRowStride rows
[in]inputOffsetinput offset value
Return values
Refercy_en_nnlite_status_t

[in] nnlite base pointer of register map.

[in] context pointer to the driver context structure

[in] filterWidth filter width

[in] filterHeight filter height

[in] activationRepeats activation streamer repeat count

[in] inputWidth input activation Width

[in] inputHeight input activation Height

[in] inputChannel input activation channels

[in] padVal padding value

[in] padHeight padding Height

[in] padWidth padding Width

[in] strideCol Stride column

[in] strideRow Stride rows

[in] inputOffset input offset value

◆ Cy_NNLite_WeightStreamerCfg()

cy_en_nnlite_status_t Cy_NNLite_WeightStreamerCfg ( NNLITE_Type nnlite,
cy_nnlite_context_t context,
uint32_t  weightPerNeuron,
int32_t  filterOffset 
)

nnlite weight streamer configuration set, API will configure offset for weight streamer and weights per neuron parameter*

Parameters
[in]nnlitebase pointer of NNLIte register map.
[in]contextpointer to the driver context structure
[in]weightPerNeuronweight/filter elements count per neuron
[in]filterOffsetweight/filter elements offset value
Return values
Refercy_en_nnlite_status_t

nnlite weight streamer configuration set, API will configure offset for weight streamer and weights per neuron parameter*

[in] nnlite base pointer of register map.

[in] context pointer to the driver context structure

[in] weightPerNeuron wight/filter elements count per neuron

[in] filterOffset wight/filter elements offset value

◆ Cy_NNLite_OutputStreamerCfg()

cy_en_nnlite_status_t Cy_NNLite_OutputStreamerCfg ( NNLITE_Type nnlite,
cy_nnlite_context_t context,
cy_nnlite_clipping_t  clipping,
int32_t  outputOffset,
uint32_t  outputWidth,
uint32_t  outputHeight,
uint32_t  outputChannels 
)

nnlite out streamer configuration set, API will set clipping mask, offset, width, height and channel for output streamer

Parameters
[in]nnlitebase pointer of NNLIte register map.
[in]contextpointer to the driver context structure
[in]clippingoutput clipping setting
[in]outputOffsetoutput elements offset value
[in]outputWidthoutput width
[in]outputHeightoutput height
[in]outputChannelsoutput Channels
Return values
Refercy_en_nnlite_status_t

nnlite out streamer configuration set, API will set clipping mask, offset, width, height and channel for output streamer

[in] nnlite base pointer of register map.

[in] context pointer to the driver context structure

[in] clipping output clipping setting mask or max/min values

[in] outputOffset output elements offset value

[in] outputChannels output Channels

◆ Cy_NNLite_StreamerBaseAddrSet()

cy_en_nnlite_status_t Cy_NNLite_StreamerBaseAddrSet ( NNLITE_Type nnlite,
cy_en_nnlite_streamer_id_t  strmId,
const void *  baseAddr 
)

set nnlite streamer base address

Parameters
[in]nnlitebase pointer of NNLIte register map.
[in]strmIdstreamer id
[in]baseAddrbase address of buffer
Return values
Refercy_en_nnlite_status_t

set nnlite streamer base address

[in] nnlite base pointer of register map.

[in] strmId streamer id

[in] baseAddr base address of buffer

◆ Cy_NNLite_PipelineConfig()

static cy_en_nnlite_status_t Cy_NNLite_PipelineConfig ( NNLITE_Type nnlite,
cy_en_nnlite_op_t  opType,
cy_en_nnlite_mode_t  fetchMode,
bool  repeatWeights,
bool  biasEn,
bool  sparsityEn,
cy_en_nnlite_output_rescaling_t  outputRescaling,
cy_en_nnlite_input_rescaling_t  inputRescaling,
cy_en_nnlite_fused_activation_t  actType,
cy_en_nnlite_activation_size_t  inputSize,
cy_en_nnlite_activation_size_t  weightSize,
cy_en_nnlite_output_size_t  outputSize 
)
inlinestatic

Set NNLiteV2 pipeline configuration.

Parameters
[in]nnlitebase pointer of NNLIte register map.
[in]opTypeALU (Arithmetic accumulation) stage operation
[in]fetchModeActivation fetch mode (depthwise, tensorwise)
[in]repeatWeightsEnable weight repetition
[in]biasEnEnable bias
[in]sparsityEnEnable packed sparse weights
[in]outputRescalingALU stage scaling mode
[in]inputRescalingALU prescaling mode
[in]actTypeActivation stage activation function
[in]inputSizeActivation.rhs input bit width
[in]weightSizeWeight/lhs input bit width
[in]outputSizeOutput bit width.
Returns
cy_en_nnlite_status_t
Note
inline as typical most parameters are constants

◆ Cy_NNLite_SetPrePostScaling()

cy_en_nnlite_status_t Cy_NNLite_SetPrePostScaling ( NNLITE_Type nnlite,
float  preScalingFactor,
const float *  postScalingFactors 
)

Set pre/post arithmetic/accumulation scaling.

Parameters
[in]nnlitebase pointer of NNLIte register map.
[in]preScalingFactorPre-scaling factor to input prior to arithmetic/accumulation operation
[in]postScalingFactorsPost-scaling factor(s) to be applied after arithmetic/accumulation
Return values
Refercy_en_nnlite_status_t
Note
Scale factors are restricted IEEE754 float values. For NNLite V2.0 supported exponents [8,-24] are supported. Mantissa is rounded to 16-bits. Non Nan etc.

◆ Cy_NNLite_SetInterpolationParam()

cy_en_nnlite_status_t Cy_NNLite_SetInterpolationParam ( NNLITE_Type nnlite,
uint32_t  segment,
float  gradient 
)

set interpolation parameter

Parameters
[in]nnlitebase pointer of NNLIte register map.
[in]segmentlookup segment table addr (0: [-inf..0], 1: [0..inf] )
[in]gradientslope value for interpolation (IEEE 32-bit float mantissa will be rounded to 7 bits)
Return values
Refercy_en_nnlite_status_t

set interpolation parameter

Parameters
[in]nnlitebase pointer of NNLIte register map.
[in]segmentlookup segment table addr (0: [-inf..0], 1: [0..inf] )
[in]gradientslope value for interpolation (IEEE 32-bit float mantissa will be rounded to 7 bits)
Return values
Refercy_en_nnlite_status_t

◆ Cy_NNLite_FFTCfg()

cy_en_nnlite_status_t Cy_NNLite_FFTCfg ( NNLITE_Type nnlite,
cy_nnlite_context_t context,
void *  ppBuf0,
void *  ppBuf1,
unsigned int  fftStages 
)

Configure NNLite for Q1.15 complex FFT.

NNLite implements Decimation-in-Time Radix-2 FFT

Note
FFT length =^= Number complex input values *2 = #
Parameters
contextpointer to the driver context structure.
ppBuf0Input / ping-pong buffer 0, Output (even stages/# values)
ppBuf1ping-pong buffer 1, Output (odd stages/# values)
fftStageslog_2(FFT length)
Returns
cy_en_nnlite_status_t

NNLite implements Decimation-in-Time Radix-2 FFT

Note
FFT length =^= Number complex input values *2 = #
Parameters
[in]nnlitebase pointer of NNLIte register map.
[in]contextpointer to the driver context structure.
[in]ppBuf0Input / ping-pong buffer 0, Output (even stages/# values)
[in]ppBuf1ping-pong buffer 1, Output (odd stages/# values)
[in]fftStageslog_2(FFT length)
Return values
Refercy_en_nnlite_status_t

◆ Cy_NNLite_SetInterruptMask()

cy_en_nnlite_status_t Cy_NNLite_SetInterruptMask ( NNLITE_Type nnlite,
uint32_t  intrMask 
)

nnlite set interrupt mask, available interrupt are operation STATUS Done, MEM Fetch Error different streamers, Output Saturation interrupt

Parameters
[in]nnlitebase pointer of NNLIte register map.
[in]intrMasknnlite interrupt mask register
Return values
Refercy_en_nnlite_status_t

[in] nnlite base pointer of register map.

[in] intrMask interrupt mask value

◆ Cy_NNLite_DatawireTriggerEnable()

cy_en_nnlite_status_t Cy_NNLite_DatawireTriggerEnable ( NNLITE_Type nnlite,
bool  trigEn 
)

nnlite set datawire trigger control, trigger datawire for next layer when trigger is 1

Parameters
[in]nnlitebase pointer of NNLIte register map.
[in]trigEndatawire trigger mask
Return values
Refercy_en_nnlite_status_t

[in] nnlite base pointer of register map.

[in] trigEn datawire trigger enable

◆ Cy_NNLite_GetOperationStatus()

cy_en_nnlite_status_t Cy_NNLite_GetOperationStatus ( NNLITE_Type nnlite,
uint32_t *  opStatus 
)

nnlite get nnlite operation status, can be used to poll operation status

Parameters
[in]nnlitebase pointer of NNLIte register map.
[out]opStatusnnlite last operation status
Return values
Refercy_en_nnlite_status_t

[in] nnlite base pointer of register map.

[out] opStatus nnlite last operation status

◆ Cy_NNLite_GetInterruptStatus()

cy_en_nnlite_status_t Cy_NNLite_GetInterruptStatus ( NNLITE_Type nnlite,
uint32_t *  intrStatus 
)

get nnlite interrupt status

Parameters
[in]nnlitebase pointer of NNLIte register map.
[out]intrStatusnnlite interrupt status register
Return values
Refercy_en_nnlite_status_t

get nnlite interrupt status

[in] nnlite base pointer of register map.

[out] intrStatus nnlite interrupt status register

◆ Cy_NNLite_GetInterruptMask()

cy_en_nnlite_status_t Cy_NNLite_GetInterruptMask ( NNLITE_Type nnlite,
uint32_t *  intrMask 
)

get nnlite interrupt mask

Parameters
[in]nnlitebase pointer of NNLIte register map.
[out]intrMaskinterrupt mask value
Return values
Refercy_en_nnlite_status_t

[in] nnlite base pointer of register map.

[out] intrMask nnlite interrupt mask

◆ Cy_NNLite_GetDriverState()

cy_en_nnlite_status_t Cy_NNLite_GetDriverState ( NNLITE_Type nnlite,
cy_nnlite_context_t context,
cy_en_nnlite_state_t nnliteState 
)

get nnlite driver state

Parameters
[in]nnlitebase pointer of NNLIte register map.
[in]contextpointer to the driver context structure
[out]nnliteStatedriver current state
Return values
Refercy_en_nnlite_status_t

◆ Cy_NNLite_InterruptClear()

cy_en_nnlite_status_t Cy_NNLite_InterruptClear ( NNLITE_Type nnlite,
uint32_t  intrMask 
)

clear nnlite interrupts

Parameters
[in]nnlitebase pointer of NNLIte register map.
[in]intrMasknnlite interrupts to be cleared
Return values
Refercy_en_nnlite_status_t

[in] nnlite base pointer of register map.

[in] intrMask nnlite interrupts to be cleared

◆ Cy_NNLite_InterruptHandler()

void Cy_NNLite_InterruptHandler ( NNLITE_Type nnlite,
cy_nnlite_context_t context 
)

nnlite ISR handler

Parameters
[in]nnlitebase pointer of NNLIte register map.
[in]contextnnlite context structure pointer

[in] nnlite base pointer of register map.

[in] context nnlite context structure pointer

◆ Cy_NNLite_WaitForCompletion()

cy_en_nnlite_status_t Cy_NNLite_WaitForCompletion ( NNLITE_Type nnlite,
cy_nnlite_context_t context 
)

wait for completion of operation in busy loop

Parameters
[in]nnlitebase pointer of NNLIte register map.
[in]contextnnlite context structure pointer

wait for completion of operation in busy loop

[in] nnlite base pointer of register map.

[in] context pointer to the driver context structure