KM3NeT CLB  2.0
KM3NeT CLB v2 Embedded Software
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
varid.h File Reference

Defines the variable ID format. More...

#include "util/macro.h"
#include "stdbool.h"

Go to the source code of this file.

Macros

#define VID_SUBSYS_MASK   0x70000000
 
#define VID_SUBSYS_SHIFT   28
 
#define VID_VARIDX_MASK   0x0FF00000
 
#define VID_VARIDX_SHIFT   20
 
#define VID_BASETYP_MASK   0x000C0000
 
#define VID_BASETYP_SHIFT   18
 
#define VID_SCLSIZE_MASK   0x00030000
 
#define VID_SCLSIZE_SHIFT   16
 
#define VID_SCLTYP_MASK   0x000F0000
 
#define VID_SCLTYP_SHIFT   16
 
#define VID_SCLTYP_U8   0x0
 Unsigned 8 bit integer.
 
#define VID_SCLTYP_U16   0x1
 Unsigned 16 bit integer.
 
#define VID_SCLTYP_U32   0x2
 Unsigned 32 bit integer.
 
#define VID_SCLTYP_U64   0x3
 Unsigned 64 bit integer.
 
#define VID_SCLTYP_I8   0x4
 Signed 8 bit integer.
 
#define VID_SCLTYP_I16   0x5
 Signed 16 bit integer.
 
#define VID_SCLTYP_I32   0x6
 Signed 32 bit integer.
 
#define VID_SCLTYP_I64   0x7
 Signed 64 bit integer.
 
#define VID_SCLTYP_BOOL   0x8
 Boolean, encoded as a byte (0 - false, 1 - true)
 
#define VID_SCLTYP_F32   0xA
 32 bit IEEE floating point
 
#define VID_SCLTYP_F64   0xB
 64 bit IEEE double precision floating point
 
#define VID_VIRTUAL   BIT(15)
 Indicates variable is virtual, does not really exist.
 
#define VID_READABLE   BIT(14)
 Variable is writable.
 
#define VID_WRITABLE   BIT(13)
 Variable is readable.
 
#define VID_CONFIG   BIT(12)
 Config variables may not be writable in some states.
 
#define VID_ARRSIZE_MASK   0x00000FFF
 
#define VID_ARRSIZE_SHIFT   0
 

Functions

static int vidArrSize (int varID)
 Returns the number of elements in the array of this variable. More...
 
static int vidSclSize (int varID)
 Returns the size of the scalar part of variable in bytes. More...
 
static int vidType (int varID)
 Returns the type of the variable. More...
 
static int vidVarSize (int varID)
 Returns the total size of the variable. More...
 
static bool vidIsReadable (int varID)
 Checks if a variable is readable. More...
 
static bool vidIsWritable (int varID)
 Checks if a variable is readable. More...
 

Variables

const char *const vidTypeNames [16]
 Types names.
 

Detailed Description

Defines the variable ID format.

A 32 bit variable ID actually contains meta data so introspection can be down without need for additional information.

The following information is encoded:

Bit(s) Name Description 30..28 SubSys Subsystem ID 0: SYS, 1: CLB, 2: NET, 3: OPT, 4: INS, 5: OPT, 6: BSE 7: reserved 27..20 VarIdx Subsystem variable index (max = 255) 19..18 BaseType Basic Type 0: unsigned int, 1: signed int, 2: floating point/bool, 3: reserved 17..16 ScalarSize Size in bytes: 2^ScalarSize, or: 0: 1 byte, 1: 2 bytes, 2: 4 bytes, 4: 8 bytes 19..16* ScalarType Combination of BaseType and ScalarSize make Scalar type. 15 Virtual Variable is virtual 14 Readable Variable can be read 13 Writable Variable can be written 12 Config Variable is a configuration variable 11..0 ArraySize When 0 - not an array, Else the actual array size ArraySize + 1 maximum array size = 2 ^ 12, or 4096

Total size of the variable is 2^ScalarSize * (ArraySize + 1).

Definition in file varid.h.

Function Documentation

static int vidArrSize ( int  varID)
inlinestatic

Returns the number of elements in the array of this variable.

Parameters
varIDVariable ID
Returns
The number of elements in the array, or 1 if its a scalar.

Definition at line 99 of file varid.h.

static bool vidIsReadable ( int  varID)
inlinestatic

Checks if a variable is readable.

Parameters
varIDthe variable ID
Return values
trueIts readable.
falseIts not readable

Definition at line 145 of file varid.h.

static bool vidIsWritable ( int  varID)
inlinestatic

Checks if a variable is readable.

Parameters
varIDthe variable ID
Return values
trueIts writable
falseIts not writable

Definition at line 158 of file varid.h.

static int vidSclSize ( int  varID)
inlinestatic

Returns the size of the scalar part of variable in bytes.

Parameters
varIDVariable ID
Returns
The size of the primitive type in bytes, e.g. U32 -> 4.

Definition at line 110 of file varid.h.

static int vidType ( int  varID)
inlinestatic

Returns the type of the variable.

Parameters
varIDThe variable
Returns
The type ID of the varaible.

Definition at line 121 of file varid.h.

static int vidVarSize ( int  varID)
inlinestatic

Returns the total size of the variable.

So if its an array its the size of the scalar times the size of the array.

Parameters
varIDVariable ID
Returns
Size of the complete variable in bytes

Definition at line 132 of file varid.h.