sPyNNaker neural_modelling 7.1.1
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#include <stdbool.h>
17#include <stdint.h>
18#include <debug.h>
19
20#include <data_specification.h>
21
22#include "neuron.h"
23
24uint64_t udiv64(uint64_t num, uint64_t den) {
25
26 uint64_t quot = 0;
27 uint64_t qbit = 1;
28
29 if (den == 0) {
30 /* Intentional divide by zero, without
31 triggering a compiler warning which
32 would abort the build */
33 return 1/((unsigned)den);
34 }
35
36 /* Left-justify denominator and count shift */
37 while ((int64_t) den >= 0) {
38 den <<= 1;
39 qbit <<= 1;
40 }
41
42 while (qbit) {
43 if (den <= num) {
44 num -= den;
45 quot += qbit;
46 }
47 den >>= 1;
48 qbit >>= 1;
49 }
50 return quot;
51}
52
58 uint32_t n_tdma_misses;
60 uint32_t earliest_send;
62 uint32_t latest_send;
63};
64
78
80extern uint32_t time;
81
83extern uint32_t latest_send_time;
84
86extern uint32_t earliest_send_time;
87
90static inline void store_neuron_provenance(struct neuron_provenance *prov) {
92 prov->n_tdma_misses = 0;
93 prov->earliest_send = earliest_send_time;
94 prov->latest_send = latest_send_time;
95}
96
102static inline bool initialise_neuron_regions(
104 struct neuron_regions regions, uint32_t *n_rec_regions_used) {
105
106 // Set up the neurons
108 data_specification_get_region(regions.core_params, ds_regions),
109 data_specification_get_region(regions.neuron_params, ds_regions),
110 data_specification_get_region(regions.current_source_params, ds_regions),
111 data_specification_get_region(regions.neuron_recording, ds_regions),
112 data_specification_get_region(regions.initial_values, ds_regions),
113 n_rec_regions_used)) {
114 return false;
115 }
116
117 return true;
118}
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.