def reset(self, machine): transform.Transform.reset(self, machine) word_size = self.get_word_size() bits = machine.addr_bits - util.get_bus_shift(word_size) while self.shift < 0: self.shift += bits self.shift %= bits
def random_shift(machine, nxt, rand): word_size = nxt.get_word_size() word_bits = util.get_bus_shift(word_size) bits = machine.addr_bits - word_bits - 1 shift = rand.randint(-bits, bits) result = Shift(join.Join(), nxt, shift) result.reset(machine) return result
def _rotate(self, value, count): word_size = self.get_word_size() word_bits = util.get_bus_shift(word_size) word_mask = word_size - 1 bits = self.machine.addr_bits - word_bits mask = (1 << bits) - 1 shift_part = value >> word_bits word_part = value & word_mask if count >= 0: count2 = bits - count shifted = ((shift_part << count) & mask) | (shift_part >> count2) else: count2 = bits + count shifted = ((shift_part << count2) & mask) | (shift_part >> -count) return (shifted << word_bits) | word_part
def get_addr_width(self, word_size): """Get the number of bits needed for an address bus.""" return self.addr_bits - util.get_bus_shift(word_size)
def permute(self, rand): word_bits = util.get_bus_shift(self.get_word_size()) bits = self.machine.addr_bits - word_bits - 1 self.shift = rand.randint(-bits, bits) return True