예제 #1
0
파일: main.c 프로젝트: Thomsen/test
int main(int argc, char *argv[])
{

  printf("command argument: %s\n", argv[1]);
  // io_tools
  //gpchar();

  // data_type
  printf("------------ data_type example ------------\n");
  print_sizeof ();

  // pointer
  printf("\n------------ pointer example --------------\n");
  address();

  // string
  printf("\n------------ string example ---------------\n");
  char_to_string();

  // struct
  printf("\n------------ struct example ---------------\n");
  structure();

  // union
  printf("\n------------ union example ----------------\n");
  union_test();

  // bit_field
  printf("\n------------ bit_field example -----------\n");
  bit_field_test();

  // file_io
  printf("\n------------ file_io example -------------\n");
  file_io_test();

  // recursion
  printf("\n------------ recusion example -------------\n");
  recursion_test();

  // variable_args
  printf("\n------------ valist example -------------\n");
  varargs_test();

  // memory
  printf("\n------------ memory example -------------\n");
  memory_mgmt_test();

  return 0;
}
예제 #2
0
bool out_spike_test (index_t n)
{ 
  return (bit_field_test (out_spikes, n)); 
}
예제 #3
0
//! \brief Check if a given neuron has been recorded to spike
//! \param[in] spike_source_index The index of the neuron.
//! \return true if the spike source has been recorded to spike
bool out_spikes_is_spike(index_t neuron_index) {
    return (bit_field_test(out_spikes, neuron_index));
}
예제 #4
0
void timer_callback(uint unused0, uint unused1) {
    use(unused0);
    use(unused1);

    time++;

    log_debug("Timer tick %u", time);

    // If a fixed number of simulation ticks are specified and these have passed
    if (simulation_ticks != UINT32_MAX && time >= simulation_ticks) {
        log_info("Simulation complete.\n");
        spin1_exit(0);
    }

    // Loop through delay stages
    for (uint32_t d = 0; d < num_delay_stages; d++) {

        // If any neurons emit spikes after this delay stage
        bit_field_t delay_stage_config = neuron_delay_stage_config[d];
        if (nonempty_bit_field(delay_stage_config, neuron_bit_field_words)) {

            // Get key mask for this delay stage and it's time slot
            uint32_t delay_stage_delay = (d + 1) * DELAY_STAGE_LENGTH;
            uint32_t delay_stage_time_slot =
                ((time - delay_stage_delay) & num_delay_slots_mask);
            uint8_t *delay_stage_spike_counters =
                spike_counters[delay_stage_time_slot];

            log_debug("Checking time slot %u for delay stage %u",
                      delay_stage_time_slot, d);

            // Loop through neurons
            for (uint32_t n = 0; n < num_neurons; n++) {

                // If this neuron emits a spike after this stage
                if (bit_field_test(delay_stage_config, n)) {

                    // Calculate key all spikes coming from this neuron will be
                    // sent with
                    uint32_t spike_key = ((d * num_neurons) + n) | key;

#if LOG_LEVEL >= LOG_DEBUG
                    if (delay_stage_spike_counters[n] > 0) {
                        log_debug("Neuron %u sending %u spikes after delay"
                                  "stage %u with key %x",
                                  n, delay_stage_spike_counters[n], d,
                                  spike_key);
                    }
#endif  // DEBUG

                    // Loop through counted spikes and send
                    for (uint32_t s = 0; s < delay_stage_spike_counters[n];
                            s++) {
                        while (!spin1_send_mc_packet(spike_key, 0,
                                                     NO_PAYLOAD)) {
                            spin1_delay_us(1);
                        }
                    }
                }
            }
        }
    }

    // Zero all counters in current time slot
    uint32_t current_time_slot = time & num_delay_slots_mask;
    uint8_t *current_time_slot_spike_counters =
        spike_counters[current_time_slot];
    memset(current_time_slot_spike_counters, 0, sizeof(uint8_t) * num_neurons);
}