// Callbacks void timer_callback(uint unused0, uint unused1) { use(unused0); use(unused1); time++; log_debug("Timer tick %d", time); if ((infinite_run != TRUE) && (time == simulation_ticks)) { simulation_handle_pause_resume(NULL); log_info("Simulation complete.\n"); simulation_ready_to_read(); } // Process the incoming spikes spike_t s; uint32_t nid; while (in_spikes_get_next_spike(&s)) { nid = (s & NEURON_ID_MASK); if (nid < N_COUNTERS) { counters[nid] += 1; } else { log_debug("Received spike from unknown neuron %d", nid); } } // Work out if there is any motion if ((time % sample_time) == 0) { // Do motion in pairs do_motion(MOTION_FORWARD, MOTION_BACK, "Forwards", "Backwards"); do_motion(MOTION_LEFT, MOTION_RIGHT, "Left", "Right"); do_motion(MOTION_CLOCKWISE, MOTION_C_CLOCKWISE, "Clockwise", "Anti-clockwise"); // Reset the counters for (uint32_t i = 0; i < N_COUNTERS; i++) { counters[i] = 0; } } else if ((time % update_time) == 0) { // Do updates in pairs do_update(MOTION_FORWARD, MOTION_BACK, "Forwards", "Backwards"); do_update(MOTION_LEFT, MOTION_RIGHT, "Left", "Right"); do_update(MOTION_CLOCKWISE, MOTION_C_CLOCKWISE, "Clockwise", "Anti-clockwise"); } }
//! \brief Timer interrupt callback //! \param[in] timer_count the number of times this call back has been //! executed since start of simulation //! \param[in] unused unused parameter kept for API consistency //! \return None void timer_callback(uint timer_count, uint unused) { use(timer_count); use(unused); time++; log_debug("Timer tick %u \n", time); /* if a fixed number of simulation ticks that were specified at startup then do reporting for finishing */ if (infinite_run != TRUE && time >= simulation_ticks) { // Enter pause and resume state to avoid another tick simulation_handle_pause_resume(resume_callback); // Finalise any recordings that are in progress, writing back the final // amounts of samples recorded to SDRAM if (recording_flags > 0) { log_info("updating recording regions"); recording_finalise(); } // Subtract 1 from the time so this tick gets done again on the next // run time -= 1; return; } // otherwise do synapse and neuron time step updates synapses_do_timestep_update(time); neuron_do_timestep_update(time); // trigger buffering_out_mechanism if (recording_flags > 0) { recording_do_timestep_update(time); } }