def process_sig(self, chip_name, sig): """This computes and records some greedy statistics on a given signature""" # add this chip if it is unknown if chip_name not in self.signatureMap.keys(): self.add(chip_name, sig) else: # update unstable bit map if chip_name not in self.unstableBits: self.unstableBits[chip_name] = BitStream(uint=0, length=self.nb) if self.measCount[chip_name] > 0: self.unstableBits[chip_name] = self.unstableBits[chip_name] | ( self.signatureMap[chip_name] ^ sig) # Increment the measurement count for this chip self.measCount[chip_name] += 1 # record 1 noise distance if chip_name not in self.noiseDistMap.keys(): self.noiseDistMap[chip_name] = [] else: # assume that if we didn't have a list, that this is the first measurement, # and therefore we need to wait for a subsequent one before we can compute a noise distance self.noiseDistMap[chip_name].append( bitstringutils.hd(sig, self.signatureMap[chip_name])) # for scalability, should truncate this list if len(self.noiseDistMap[chip_name]) > self.max_num_dists: self.noiseDistMap[chip_name] = self.noiseDistMap[chip_name][ -self.max_num_dists:] # and record (N_C - 1) inter-chip distances for other_chip_name in self.signatureMap.keys(): if other_chip_name == chip_name: # don't compare to self continue if chip_name not in self.interChipDistMap.keys(): self.interChipDistMap[chip_name] = dict() if other_chip_name not in self.interChipDistMap[chip_name].keys(): self.interChipDistMap[chip_name][other_chip_name] = [] self.interChipDistMap[chip_name][other_chip_name].append( bitstringutils.hd(sig, self.signatureMap[other_chip_name])) # for scalability, I truncate this list if len(self.interChipDistMap[chip_name] [other_chip_name]) > self.max_num_dists: self.interChipDistMap[chip_name][ other_chip_name] = self.interChipDistMap[chip_name][ other_chip_name][-self.max_num_dists:]
def MatchMap(self, bits): "This compares a bit string against all known chip signatures" hd_dict = dict() for key, value in self.signatureMap.items(): relhd = float(bitstringutils.hd(bits, value)) / self.nb hd_dict[key] = relhd return hd_dict
def MatchMap(self, bits): "This compares a bit string against all known chip signatures" hd_dict = dict() for key, value in self.signatureMap.items(): relhd = float(bitstringutils.hd(bits, value))/self.nb hd_dict[key] = relhd return hd_dict
def process_sig (self, chip_name, sig): """This computes and records some greedy statistics on a given signature""" # add this chip if it is unknown if chip_name not in self.signatureMap.keys(): self.add(chip_name, sig) else: # update unstable bit map if chip_name not in self.unstableBits: self.unstableBits[chip_name] = BitStream(uint=0, length=self.nb) if self.measCount[chip_name] > 0: self.unstableBits[chip_name] = self.unstableBits[chip_name] | (self.signatureMap[chip_name] ^ sig) # Increment the measurement count for this chip self.measCount[chip_name] += 1 # record 1 noise distance if chip_name not in self.noiseDistMap.keys(): self.noiseDistMap[chip_name] = [] else: # assume that if we didn't have a list, that this is the first measurement, # and therefore we need to wait for a subsequent one before we can compute a noise distance self.noiseDistMap[chip_name].append(bitstringutils.hd(sig, self.signatureMap[chip_name])) # for scalability, should truncate this list if len(self.noiseDistMap[chip_name]) > self.max_num_dists: self.noiseDistMap[chip_name] = self.noiseDistMap[chip_name][-self.max_num_dists:] # and record (N_C - 1) inter-chip distances for other_chip_name in self.signatureMap.keys(): if other_chip_name == chip_name: # don't compare to self continue if chip_name not in self.interChipDistMap.keys(): self.interChipDistMap[chip_name] = dict() if other_chip_name not in self.interChipDistMap[chip_name].keys(): self.interChipDistMap[chip_name][other_chip_name] = [] self.interChipDistMap[chip_name][other_chip_name].append( bitstringutils.hd(sig, self.signatureMap[other_chip_name])) # for scalability, I truncate this list if len(self.interChipDistMap[chip_name][other_chip_name]) > self.max_num_dists: self.interChipDistMap[chip_name][other_chip_name] = self.interChipDistMap[chip_name][other_chip_name][-self.max_num_dists:]