sPyNNaker neural_modelling development
Loading...
Searching...
No Matches
c_main_neuron_common.h
1/*
2 * Copyright (c) 2017 The University of Manchester
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * https://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16#ifndef _C_MAIN_NEURON_COMMON_H_
17#define _C_MAIN_NEURON_COMMON_H_
18
19#include <stdbool.h>
20#include <stdint.h>
21#include <debug.h>
22
23#include <data_specification.h>
24
25#include "neuron.h"
26
27uint64_t udiv64(uint64_t num, uint64_t den) {
28
29 uint64_t quot = 0;
30 uint64_t qbit = 1;
31
32 if (den == 0) {
33 /* Intentional divide by zero, without
34 triggering a compiler warning which
35 would abort the build */
36 return 1/((unsigned)den);
37 }
38
39 /* Left-justify denominator and count shift */
40 while ((int64_t) den >= 0) {
41 den <<= 1;
42 qbit <<= 1;
43 }
44
45 while (qbit) {
46 if (den <= num) {
47 num -= den;
48 quot += qbit;
49 }
50 den >>= 1;
51 qbit >>= 1;
52 }
53 return quot;
54}
55
61 uint32_t n_tdma_misses;
63 uint32_t earliest_send;
65 uint32_t latest_send;
66};
67
81
83extern uint32_t time;
84
86extern uint32_t latest_send_time;
87
89extern uint32_t earliest_send_time;
90
93static inline void store_neuron_provenance(struct neuron_provenance *prov) {
95 prov->n_tdma_misses = 0;
96 prov->earliest_send = earliest_send_time;
97 prov->latest_send = latest_send_time;
98}
99
105static inline bool initialise_neuron_regions(
107 struct neuron_regions regions, uint32_t *n_rec_regions_used) {
108
109 // Set up the neurons
111 data_specification_get_region(regions.core_params, ds_regions),
112 data_specification_get_region(regions.neuron_params, ds_regions),
113 data_specification_get_region(regions.current_source_params, ds_regions),
114 data_specification_get_region(regions.neuron_recording, ds_regions),
115 data_specification_get_region(regions.initial_values, ds_regions),
116 n_rec_regions_used)) {
117 return false;
118 }
119
120 return true;
121}
122
123#endif // _C_MAIN_NEURON_COMMON_H_
uint32_t time
The current timer tick value.
Definition c_main.c:94
bool neuron_initialise(void *core_params_address, void *neuron_params_address, void *current_sources_address, void *recording_address, void *initial_values_address, uint32_t *n_rec_regions_used)
translate the data stored in the NEURON_PARAMS data region in SDRAM and convert it into c based objec...
Definition neuron.c:105
interface for neurons
The provenance information provided by neurons.
uint32_t current_timer_tick
The current time.
uint32_t earliest_send
Earliest send time within any time step.
uint32_t n_tdma_misses
The number of times a TDMA slot was missed.
uint32_t latest_send
Latest send time within any time step.
The region IDs used by the neuron processing.
uint32_t neuron_params
The neuron parameters.
uint32_t initial_values
The initial values at time 0.
uint32_t neuron_recording
The neuron recording details.
uint32_t current_source_params
The current source parameters.
uint32_t core_params
The core parameters.