sPyNNaker neural_modelling 7.3.1
Loading...
Searching...
No Matches
local_only_2d_common.h
1/*
2 * Copyright (c) 2023 The University of Manchester
3 * based on work Copyright (c) The University of Sussex,
4 * Garibaldi Pineda Garcia, James Turner, James Knight and Thomas Nowotny
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * https://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18
20typedef int16_t lc_weight_t;
21
23typedef int16_t lc_dim_t;
24
26typedef struct {
27 lc_dim_t row;
28 lc_dim_t col;
30
32typedef struct {
33 lc_dim_t height;
34 lc_dim_t width;
36
38typedef struct {
39 uint32_t m: 16;
40 uint32_t sh1: 8;
41 uint32_t sh2: 8;
42} div_const;
43
44typedef struct {
46 uint32_t key;
48 uint32_t mask;
50 uint32_t start: 13;
52 uint32_t n_colour_bits: 3;
54 uint32_t count: 16;
56 uint32_t core_mask: 16;
58 uint32_t mask_shift: 16;
59} key_info;
60
62static inline uint32_t div_by_const(uint32_t i, div_const d) {
63 uint32_t t1 = (i * d.m) >> 16;
64 uint32_t isubt1 = (i - t1) >> d.sh1;
65 return (t1 + isubt1) >> d.sh2;
66}
67
68static inline uint32_t get_core_id(uint32_t spike, key_info k_info) {
69 return ((spike >> k_info.mask_shift) & k_info.core_mask);
70}
71
72static inline uint32_t get_local_id(uint32_t spike, key_info k_info) {
73 uint32_t local_mask = ~(k_info.mask | (k_info.core_mask << k_info.mask_shift));
74 uint32_t local = spike & local_mask;
75 return local >> k_info.n_colour_bits;
76}
Structure for constants for precise constant integer division (see div_by_const)
uint32_t n_colour_bits
The number of bits of key used for colour (0 if no colour)
uint32_t start
The index into connectors for this entry.
uint32_t count
The number of entries in connectors for this entry.
uint32_t key
The key to match against the incoming message.
uint32_t mask_shift
The shift to apply to the key to get the core part.
uint32_t mask
The mask to select the relevant bits of key for matching.
uint32_t core_mask
The mask to apply to the key once shifted to get the core index.
A coordinate in terms of rows and columns (y and x)
A shape in terms of height and width.