sPyNNaker neural_modelling 7.1.1
Loading...
Searching...
No Matches
Data Structures | Macros | Functions
maths.h File Reference

Support functions for STDP. More...

#include <common/neuron-typedefs.h>
#include <debug.h>
#include <spin1_api.h>

Go to the source code of this file.

Data Structures

struct  int16_lut
 Lookup Table of 16-bit integers. More...
 

Macros

#define MIN(X, Y)   ((X) < (Y) ? (X) : (Y))
 Minimum. Evaluates arguments twice.
 
#define MAX(X, Y)   ((X) > (Y) ? (X) : (Y))
 Maximum. Evaluates arguments twice.
 

Functions

static int16_lutmaths_copy_int16_lut (address_t *address)
 Copy a Lookup Table from SDRAM to DTCM, updating the address.
 
static int32_t maths_lut_exponential_decay (uint32_t time, const int16_lut *lut)
 Get value from lookup table.
 
static int32_t maths_clamp_pot (int32_t x, uint32_t shift)
 Clamp to fit in number of bits.
 
static int32_t maths_mul_16x16 (int16_t x, int16_t y)
 multiply two 16-bit numbers to get a 32-bit number.
 
static int32_t maths_fixed_mul16 (int32_t a, int32_t b, const int32_t fixed_point_position)
 multiply two 16-bit fixed point numbers (encoded in int32_t)
 
static int32_t maths_fixed_mul32 (int32_t a, int32_t b, const int32_t fixed_point_position)
 multiply two 32-bit fixed point numbers (encoded in int32_t)
 

Detailed Description

Support functions for STDP.

Definition in file maths.h.


Data Structure Documentation

◆ int16_lut

struct int16_lut

Lookup Table of 16-bit integers.

Will be padded to a word boundary at the end.

Definition at line 44 of file maths.h.

Data Fields
uint16_t size Number of entries in table.
uint16_t shift Mapping from time to table index.
int16_t values[] Table of actual values.

Macro Definition Documentation

◆ MIN

#define MIN (   X,
 
)    ((X) < (Y) ? (X) : (Y))

Minimum. Evaluates arguments twice.

Parameters
XFirst value
YSecond value
Returns
Minimum of two values

Definition at line 34 of file maths.h.

◆ MAX

#define MAX (   X,
 
)    ((X) > (Y) ? (X) : (Y))

Maximum. Evaluates arguments twice.

Parameters
XFirst value
YSecond value
Returns
Maximum of two values

Definition at line 39 of file maths.h.

Function Documentation

◆ maths_copy_int16_lut()

static int16_lut * maths_copy_int16_lut ( address_t address)
inlinestatic

Copy a Lookup Table from SDRAM to DTCM, updating the address.

Parameters
[in,out]addressPointer to the SDRAM address to copy from. This is updated to point to the space after the structure.
Returns
A pointer to the copied lookup table, malloc'd in DTCM

Definition at line 57 of file maths.h.

◆ maths_lut_exponential_decay()

static int32_t maths_lut_exponential_decay ( uint32_t  time,
const int16_lut lut 
)
inlinestatic

Get value from lookup table.

Parameters
[in]timeThe time that we are mapping
[in]lutThe lookup table (result of maths_copy_int16_lut())
Returns
The value from the LUT, or zero if out of range

Definition at line 79 of file maths.h.

◆ maths_clamp_pot()

static int32_t maths_clamp_pot ( int32_t  x,
uint32_t  shift 
)
inlinestatic

Clamp to fit in number of bits.

Parameters
[in]xThe value to clamp
[in]shiftWidth of the field to clamp the value to fit in
Returns
The clamped value

Definition at line 92 of file maths.h.

◆ maths_mul_16x16()

static int32_t maths_mul_16x16 ( int16_t  x,
int16_t  y 
)
inlinestatic

multiply two 16-bit numbers to get a 32-bit number.

NOTE: this should 'encourage' GCC to insert SMULxy 16x16 multiply

Parameters
[in]xThe first multiplicand
[in]yThe first multiplicand
Returns
The product

Definition at line 109 of file maths.h.

◆ maths_fixed_mul16()

static int32_t maths_fixed_mul16 ( int32_t  a,
int32_t  b,
const int32_t  fixed_point_position 
)
inlinestatic

multiply two 16-bit fixed point numbers (encoded in int32_t)

Parameters
[in]aThe first multiplicand
[in]bThe first multiplicand
[in]fixed_point_positionThe location of the fixed point
Returns
The product

Definition at line 119 of file maths.h.

◆ maths_fixed_mul32()

static int32_t maths_fixed_mul32 ( int32_t  a,
int32_t  b,
const int32_t  fixed_point_position 
)
inlinestatic

multiply two 32-bit fixed point numbers (encoded in int32_t)

Parameters
[in]aThe first multiplicand
[in]bThe first multiplicand
[in]fixed_point_positionThe location of the fixed point
Returns
The product

Definition at line 131 of file maths.h.