def setUp(self): """ Set up the unit test: A full reticle is allocated and complelty configured with zeroed floating gates. """ if None in (self.WAFER, self.DNC): raise unittest.SkipTest("No DNC selected, skipping hardware test") return self.data_adcs = {} # Dump data in case of an error in setup self.save_data() self.wafer = pysthal.Wafer(self.WAFER) self.reset_hicann_config() db = pysthal.MagicHardwareDatabase() self.wafer.connect(db) for hicann_c in self.hicanns: hicann = self.wafer[hicann_c] for analog in Coordinate.iter_all(Coordinate.AnalogOnHICANN): key = self.adc_key(hicann_c, analog) try: cfg = hicann.getADCConfig(analog) self.data_adcs[key] = (cfg.coord.value(), cfg.channel.value(), []) except RuntimeError: self.data_adcs[key] = (None, None, []) self.wafer.configure(pysthal.ParallelHICANNv4Configurator())
# for hicann in p.hicann: # if hicann not in hicanns_in_use: # continue # _BSS_set_hicann_sthal_params(wafer, hicann, 1023) for hicann in hicanns_in_use: print("\n\n\n\n") print(wafer, hicann) _BSS_set_hicann_sthal_params(wafer, hicann, 1023) marocco.skip_mapping = True marocco.backend = PyMarocco.Hardware # Full configuration during first step marocco.hicann_configurator = pysthal.ParallelHICANNv4Configurator() set_digital_weights(start_w, projs, n_input, n_mid * n_per_mid, runtime, digital_w=15) sim.run(duration) in_spikes = [p.getSpikes() for p in in_pops] spikes = [p.getSpikes() for p in mid_pops] for s in in_spikes: print(len(s)) for popid, s in enumerate(spikes): print(popid, len(s)) # print(s)
def run(self, duration, gmax=1023, gmax_div=1, min_max_weights=None, noise_count_threshold=100): """:param noise_count_thres: how many times in the experiment should a neuron spike to be considered a noisy neuron """ MIN, MAX = 0, 1 if self.sim_name == BSS: if self._first_run: # self._do_BSS_placement() # self.marocco.skip_mapping = True seed = 0 self.marocco.l1_routing.shuffle_switches_seed(seed) self.marocco.skip_mapping = False self.marocco.backend = PyMarocco.None sys.stdout.write( '\n-------------FIRST RESET ----------------\n') sys.stdout.flush() self._sim.reset() sys.stdout.write( '\n------ NO HARDWARE RUN / MAPPING %s --------\n\n\n' % seed) sys.stdout.flush() self._sim.run(duration) # self.marocco.skip_mapping = True # set gmax values per hicann wafer = self.BSS_runtime.wafer() hicanns_in_use = wafer.getAllocatedHicannCoordinates() for k in self._populations: p = self._populations[k] if p.hicann is None: continue p_gmax = min(1023, gmax if p.gmax is None else p.gmax) for hicann in p.hicann: if hicann not in hicanns_in_use: continue self._BSS_set_hicann_sthal_params( wafer, hicann, p_gmax) self._bss_blacklists = {} sys.stdout.write( '\n------ HARDWARE RUN / NO MAPPING %s --------\n\n\n' % seed) sys.stdout.flush() # scale into 4-bit res self.marocco.skip_mapping = True self.marocco.backend = PyMarocco.Hardware # Full configuration during first step self.marocco.hicann_configurator = pysthal.ParallelHICANNv4Configurator( ) ### detecting noise neurons ### this shouldn't be here!!! ### or it should only depend on the type of population, i.e. non-source ones ### pop.__class__.__name__.lower().startswith('SpikeSource') <=> continue! # test_time = 500 # init_noise_count = 5 # self.set_digital_weights(zero_all=True) # self._sim.run(test_time) #ms # pre_labels = [k for k in self._populations.keys() \ # if k.lower().startswith('kenyon')] # pre_spikes = { # k: self.get_spikes(self._populations[k]) for k in pre_labels # } # hi_pre = { # k: get_high_spiking(pre_spikes[k], 0, test_time, init_noise_count) for k in pre_spikes # } # post_spikes = self.get_spikes(self._populations['Decision Neurons']) # hi_post = get_high_spiking(post_spikes, 0, test_time, init_noise_count) # k: set(hi_pre[k].keys()) for k in hi_pre # } # self._bss_blacklists['Decision Neurons'] = set(hi_post.keys()) # f = open("black_list_stats.txt", "a+") # lengths = [str(len(self._bss_blacklists[k])) \ # for k in sorted(self._bss_blacklists.keys())] # line = ", ".join(lengths) # f.write(u"%s\n"%line) # f.close() # print(sorted(self._bss_blacklists.keys())) # print(lengths) # sys.exit(0) # self._sim.reset() # self.marocco.hicann_configurator = pysthal.NoResetNoFGConfigurator() ### end of detecting noise neurons self._first_run = False self.set_digital_weights(blacklists=self._bss_blacklists) self._sim.run(duration) else: self._sim.reset() self.marocco.hicann_configurator = pysthal.NoResetNoFGConfigurator( ) self.marocco.verification = PyMarocco.Skip self.marocco.checkl1locking = PyMarocco.SkipCheck self.set_digital_weights(blacklists=self._bss_blacklists) self._sim.run(duration) else: if self._first_run: '''REMOVE THIS!!! just for testing!!!''' # self._wafer = WAL(wafer_id=33) #TODO: REMEMBER TO DELETE THIS!!!! # self._do_BSS_placement() #TODO: REMEMBER TO DELETE THIS!!!! self._first_run = False self._sim.run(duration)