21 #ifndef _CURRENT_SOURCE_NOISY_H_
22 #define _CURRENT_SOURCE_NOISY_H_
34 mars_kiss64_seed_t seed;
39 static bool current_source_noisy_init(uint32_t n_noisy_sources, uint32_t *next) {
40 noisy_source = spin1_malloc(n_noisy_sources *
sizeof(uint32_t*));
41 for (uint32_t n_noisy=0; n_noisy < n_noisy_sources; n_noisy++) {
43 if (noisy_source[n_noisy] == NULL) {
44 log_error(
"Unable to allocate DC source parameters - out of DTCM");
52 static bool current_source_noisy_load_parameters(
53 address_t cs_address, uint32_t n_noisy_sources, uint32_t *next) {
54 for (uint32_t n_noisy=0; n_noisy < n_noisy_sources; n_noisy++) {
61 static REAL current_source_noisy_get_offset(uint32_t cs_index, uint32_t
time) {
62 if ((
time >= noisy_source[cs_index]->start) && (
time < noisy_source[cs_index]->stop)) {
64 REAL random_value = norminv_urt(mars_kiss64_seed(noisy_source[cs_index]->
seed));
65 REAL noisy_current_offset = noisy_source[cs_index]->mean + (
66 noisy_source[cs_index]->stdev * random_value);
67 return noisy_current_offset;
static uint32_t time
Simulation time.
accum REAL
Type used for "real" numbers.
static mars_kiss64_seed_t seed
YUCK copy and pasted RNG to allow inlining and also to avoid horrific executable bloat.