spinn_common 7.3.1
Support code for SpiNNaker applications.
Loading...
Searching...
No Matches
Functions
utils.h File Reference

Utility functions for SpiNNaker. More...

#include <stdint.h>

Go to the source code of this file.

Functions

static uint32_t __hi (uint64_t x)
 This function returns the most significant 32-bit word of a 64-bit unsigned integer.
 
static uint32_t __lo (uint64_t x)
 This function returns the least significant 32-bit word of a 64-bit unsigned integer.
 
static uint64_t round64 (uint64_t x)
 The function treats the 64-bit number as if it were a 32-bit integer and a 32-bit fraction, rounding the fractional part.
 
static uint64_t scale64 (uint64_t x, uint32_t y)
 The function scales the 64-bit number x, treating y as if it were an unsigned long fract, rounding the fractional part.
 
static uint32_t scale32 (uint32_t x, uint32_t y)
 The function scales the 32-bit number x, treating y as if it were an unsigned long fract, rounding the fractional part.
 
static uint32_t log_next_power_of_2 (uint32_t v)
 Returns the log of the next highest power of 2 of a value.
 
static uint32_t ilog_2 (uint32_t v)
 Returns the integer part of the log to base 2 of a number.
 
static uint32_t next_power_of_2 (uint32_t v)
 Returns the next highest power of 2 of a value.
 
static bool is_power_of_2 (uint32_t v)
 Returns True if the value is a power of 2.
 

Detailed Description

Utility functions for SpiNNaker.

Author
Dave Lester (david.nosp@m..r.l.nosp@m.ester.nosp@m.@man.nosp@m.chest.nosp@m.er.a.nosp@m.c.uk)
Date
12 December, 2013

Function Documentation

◆ __hi()

static uint32_t __hi ( uint64_t  x)
inlinestatic

This function returns the most significant 32-bit word of a 64-bit unsigned integer.

Parameters
[in]xThe 64-bit number
Returns
The most significant 32-bits of x.

◆ __lo()

static uint32_t __lo ( uint64_t  x)
inlinestatic

This function returns the least significant 32-bit word of a 64-bit unsigned integer.

Parameters
[in]xThe 64-bit number
Returns
The least significant 32-bits of x.

◆ round64()

static uint64_t round64 ( uint64_t  x)
inlinestatic

The function treats the 64-bit number as if it were a 32-bit integer and a 32-bit fraction, rounding the fractional part.

Parameters
[in]xThe 64-bit number
Returns
The rounded result.

◆ scale64()

static uint64_t scale64 ( uint64_t  x,
uint32_t  y 
)
inlinestatic

The function scales the 64-bit number x, treating y as if it were an unsigned long fract, rounding the fractional part.

Parameters
[in]xA 64-bit unsigned integer.
[in]yA 32-bit unsigned integer treated as if it is an unsigned long fract.
Returns
The rounded result.

◆ scale32()

static uint32_t scale32 ( uint32_t  x,
uint32_t  y 
)
inlinestatic

The function scales the 32-bit number x, treating y as if it were an unsigned long fract, rounding the fractional part.

Parameters
[in]xA 32-bit unsigned integer.
[in]yA 32-bit unsigned integer treated as if it is an unsigned long fract.
Returns
The rounded result.

◆ log_next_power_of_2()

static uint32_t log_next_power_of_2 ( uint32_t  v)
inlinestatic

Returns the log of the next highest power of 2 of a value.

Parameters
[in]vA 32-bit unsigned integer
Returns
The log of the next highest power of 2

◆ ilog_2()

static uint32_t ilog_2 ( uint32_t  v)
inlinestatic

Returns the integer part of the log to base 2 of a number.

Parameters
[in]vA 32-bit unsigned integer
Returns
The log to the base 2

◆ next_power_of_2()

static uint32_t next_power_of_2 ( uint32_t  v)
inlinestatic

Returns the next highest power of 2 of a value.

Parameters
[in]vA 32-bit unsigned integer
Returns
The next highest power of 2

◆ is_power_of_2()

static bool is_power_of_2 ( uint32_t  v)
inlinestatic

Returns True if the value is a power of 2.

Parameters
[in]vA 32-bit unsigned integer
Returns
True if the value is a power of 2, False if not