static bool initialize(uint32_t *timer_period) { log_info("initialise: started"); // Get the address this core's DTCM data starts at from SRAM address_t address = data_specification_get_data_address(); // Read the header if (!data_specification_read_header(address)) { return false; } // Get the timing details and set up the simulation interface if (!simulation_initialise( data_specification_get_region(0, address), APPLICATION_NAME_HASH, timer_period, &simulation_ticks, &infinite_run, SDP, DMA)) { return false; } // Get the parameters read_parameters(data_specification_get_region(1, address)); log_info("initialise: completed successfully"); return true; }
static bool initialize(uint32_t *timer_period) { log_info("initialize: started"); // Get the address this core's DTCM data starts at from SRAM address_t address = data_specification_get_data_address(); // Read the header if (!data_specification_read_header(address)) { return false; } // Get the timing details if (!simulation_read_timing_details( data_specification_get_region(0, address), APPLICATION_MAGIC_NUMBER, timer_period, &simulation_ticks)) { return false; } // Get the parameters if (!read_parameters(data_specification_get_region(1, address))) { return false; } log_info("initialize: completed successfully"); return true; }
void c_main(void) { sark_cpu_state(CPU_STATE_RUN); // Register each of the components register_connection_generators(); register_param_generators(); // Get the addresses of the regions log_info("Starting To Build Delays"); address_t core_address = data_specification_get_data_address(); address_t delay_params_address = data_specification_get_region( DELAY_PARAMS, core_address); address_t params_address = data_specification_get_region( EXPANDER_REGION, core_address); log_info("\tReading SDRAM delay params at 0x%08x," " expander params at 0x%08x", delay_params_address, params_address); // Run the expander if (!read_sdram_data( (address_t) delay_params_address, (address_t) params_address)) { log_info("!!! Error reading SDRAM data !!!"); rt_error(RTE_ABORT); } log_info("Finished On Machine Delays!"); }
//! \brief runs any functions needed at resume time. //! \return None void resume_callback() { recording_reset(); address_t address = data_specification_get_data_address(); if (!read_poisson_parameters( data_specification_get_region(POISSON_PARAMS, address))){ log_error("failed to reread the Poisson parameters from SDRAM"); rt_error(RTE_SWERR); } // Loop through slow spike sources and initialise 1st time to spike for (index_t s = 0; s < global_parameters.n_spike_sources; s++) { if (!poisson_parameters[s].is_fast_source && poisson_parameters[s].time_to_spike_ticks == 0) { poisson_parameters[s].time_to_spike_ticks = slow_spike_source_get_time_to_spike( poisson_parameters[s].mean_isi_ticks); } } log_info("Successfully resumed Poisson spike source at time: %u", time); // print spike sources for debug purposes // print_spike_sources(); }
//! Initialises the model by reading in the regions and checking recording //! data. //! \param[out] timer_period a pointer for the memory address where the timer //! period should be stored during the function. //! \param[out] update_sdp_port The SDP port on which to listen for rate //! updates //! \return boolean of True if it successfully read all the regions and set up //! all its internal data structures. Otherwise returns False static bool initialize() { log_info("Initialise: started"); // Get the address this core's DTCM data starts at from SRAM address_t address = data_specification_get_data_address(); // Read the header if (!data_specification_read_header(address)) { return false; } // Get the timing details and set up the simulation interface if (!simulation_initialise( data_specification_get_region(SYSTEM, address), APPLICATION_NAME_HASH, &timer_period, &simulation_ticks, &infinite_run, SDP, DMA)) { return false; } simulation_set_provenance_data_address( data_specification_get_region(PROVENANCE_REGION, address)); // setup recording region if (!initialise_recording()){ return false; } // Setup regions that specify spike source array data if (!read_global_parameters( data_specification_get_region(POISSON_PARAMS, address))) { return false; } if (!read_poisson_parameters( data_specification_get_region(POISSON_PARAMS, address))) { return false; } // Loop through slow spike sources and initialise 1st time to spike for (index_t s = 0; s < global_parameters.n_spike_sources; s++) { if (!poisson_parameters[s].is_fast_source) { poisson_parameters[s].time_to_spike_ticks = slow_spike_source_get_time_to_spike( poisson_parameters[s].mean_isi_ticks); } } // print spike sources for debug purposes // print_spike_sources(); // Set up recording buffer n_spike_buffers_allocated = 0; n_spike_buffer_words = get_bit_field_size( global_parameters.n_spike_sources); spike_buffer_size = n_spike_buffer_words * sizeof(uint32_t); log_info("Initialise: completed successfully"); return true; }
//! \brief Initialises the recording parts of the model //! \return True if recording initialisation is successful, false otherwise static bool initialise_recording(){ // Get the address this core's DTCM data starts at from SRAM address_t address = data_specification_get_data_address(); // Get the system region address_t recording_region = data_specification_get_region( SPIKE_HISTORY_REGION, address); bool success = recording_initialize(recording_region, &recording_flags); log_info("Recording flags = 0x%08x", recording_flags); return success; }
//! \brief Initialises the recording parts of the model //! \return True if recording initialisation is successful, false otherwise static bool initialise_recording(){ address_t address = data_specification_get_data_address(); address_t system_region = data_specification_get_region( SYSTEM_REGION, address); regions_e regions_to_record[] = { BUFFERING_OUT_SPIKE_RECORDING_REGION, BUFFERING_OUT_POTENTIAL_RECORDING_REGION, BUFFERING_OUT_GSYN_RECORDING_REGION }; uint8_t n_regions_to_record = NUMBER_OF_REGIONS_TO_RECORD; uint32_t *recording_flags_from_system_conf = &system_region[SIMULATION_N_TIMING_DETAIL_WORDS]; regions_e state_region = BUFFERING_OUT_CONTROL_REGION; bool success = recording_initialize( n_regions_to_record, regions_to_record, recording_flags_from_system_conf, state_region, TIMER_AND_BUFFERING, &recording_flags); log_info("Recording flags = 0x%08x", recording_flags); return success; }
//! \brief stores the Poisson parameters back into SDRAM for reading by the //! host when needed //! \return None bool store_poisson_parameters() { log_info("stored_parameters: starting"); // Get the address this core's DTCM data starts at from SRAM address_t address = data_specification_get_data_address(); address = data_specification_get_region(POISSON_PARAMS, address); // Copy the global_parameters back to SDRAM spin1_memcpy(address, &global_parameters, sizeof(global_parameters)); // store spike source parameters into array into SDRAM for reading by // the host if (global_parameters.n_spike_sources > 0) { uint32_t spikes_offset = sizeof(global_parameters) / BYTE_TO_WORD_CONVERTER; spin1_memcpy( &address[spikes_offset], poisson_parameters, global_parameters.n_spike_sources * sizeof(spike_source_t)); } log_info("stored_parameters : completed successfully"); return true; }
//! \brief Initialises the model by reading in the regions and checking //! recording data. //! \param[in] timer_period a pointer for the memory address where the timer //! period should be stored during the function. //! \return True if it successfully initialised, false otherwise static bool initialise(uint32_t *timer_period) { log_info("Initialise: started"); // Get the address this core's DTCM data starts at from SRAM address_t address = data_specification_get_data_address(); // Read the header if (!data_specification_read_header(address)) { return false; } // Get the timing details address_t system_region = data_specification_get_region( SYSTEM_REGION, address); if (!simulation_read_timing_details( system_region, APPLICATION_NAME_HASH, timer_period)) { return false; } // setup recording region if (!initialise_recording()){ return false; } // Set up the neurons uint32_t n_neurons; uint32_t incoming_spike_buffer_size; if (!neuron_initialise( data_specification_get_region(NEURON_PARAMS_REGION, address), recording_flags, &n_neurons, &incoming_spike_buffer_size)) { return false; } // Set up the synapses input_t *input_buffers; uint32_t *ring_buffer_to_input_buffer_left_shifts; if (!synapses_initialise( data_specification_get_region(SYNAPSE_PARAMS_REGION, address), n_neurons, &input_buffers, &ring_buffer_to_input_buffer_left_shifts)) { return false; } neuron_set_input_buffers(input_buffers); // Set up the population table uint32_t row_max_n_words; if (!population_table_initialise( data_specification_get_region(POPULATION_TABLE_REGION, address), data_specification_get_region(SYNAPTIC_MATRIX_REGION, address), &row_max_n_words)) { return false; } // Set up the synapse dynamics if (!synapse_dynamics_initialise( data_specification_get_region(SYNAPSE_DYNAMICS_REGION, address), n_neurons, ring_buffer_to_input_buffer_left_shifts)) { return false; } if (!spike_processing_initialise( row_max_n_words, MC, SDP_AND_DMA_AND_USER, SDP_AND_DMA_AND_USER, incoming_spike_buffer_size)) { return false; } log_info("Initialise: finished"); return true; }
//! \brief Initialises the model by reading in the regions and checking //! recording data. //! \param[in] timer_period a pointer for the memory address where the timer //! period should be stored during the function. //! \return True if it successfully initialised, false otherwise static bool initialize(uint32_t *timer_period) { log_info("Initialise: started"); // Get the address this core's DTCM data starts at from SRAM address_t address = data_specification_get_data_address(); // Read the header if (!data_specification_read_header(address)) { return false; } // Get the timing details address_t system_region = data_specification_get_region( SYSTEM_REGION, address); if (!simulation_read_timing_details( system_region, APPLICATION_NAME_HASH, timer_period, &simulation_ticks, &infinite_run)) { return false; } regions_e regions_to_record[] = { BUFFERING_OUT_SPIKE_RECORDING_REGION, BUFFERING_OUT_POTENTIAL_RECORDING_REGION, BUFFERING_OUT_GSYN_RECORDING_REGION }; uint8_t n_regions_to_record = NUMBER_OF_REGIONS_TO_RECORD; uint32_t *recording_flags_from_system_conf = &system_region[SIMULATION_N_TIMING_DETAIL_WORDS]; regions_e state_region = BUFFERING_OUT_CONTROL_REGION; recording_initialize( n_regions_to_record, regions_to_record, recording_flags_from_system_conf, state_region, 2, &recording_flags); log_info("Recording flags = 0x%08x", recording_flags); // Set up the neurons uint32_t n_neurons; if (!neuron_initialise( data_specification_get_region(NEURON_PARAMS_REGION, address), recording_flags, &n_neurons)) { return false; } // Set up the synapses input_t *input_buffers; uint32_t *ring_buffer_to_input_buffer_left_shifts; if (!synapses_initialise( data_specification_get_region(SYNAPSE_PARAMS_REGION, address), n_neurons, &input_buffers, &ring_buffer_to_input_buffer_left_shifts)) { return false; } neuron_set_input_buffers(input_buffers); // Set up the population table uint32_t row_max_n_words; if (!population_table_initialise( data_specification_get_region(POPULATION_TABLE_REGION, address), data_specification_get_region(SYNAPTIC_MATRIX_REGION, address), &row_max_n_words)) { return false; } // Set up the synapse dynamics if (!synapse_dynamics_initialise( data_specification_get_region(SYNAPSE_DYNAMICS_REGION, address), n_neurons, ring_buffer_to_input_buffer_left_shifts)) { return false; } if (!spike_processing_initialise(row_max_n_words)) { return false; } log_info("Initialise: finished"); return true; }