class ThreeValue(object): """ 71-bit register (for accumlator) """ def __init__(self, high=None, low=None, padding_bit=0): if not high: high = Value() if not low: low = Value() self.high = WideValue() self.padding_bit = padding_bit self.low = Value() def from_number(self, v): assert isinstance(v, int) or isinstance(v, long), v print "v", v low = v & BIT_MASK_17 padding_bit = (v >> 17) & 1 high = v >> 18 print high, padding_bit, low self.high = WideValue.from_number(high) self.low = Value.from_number(low) self.padding_bit = padding_bit def as_number(self): return ((self.high.as_number() << 18) + (self.padding_bit << 17) + self.low.as_number()) def __repr__(self): return "%r %d %s" % (self.high, self.padding_bit, self.low.as_bits_string())
class ThreeValue(object): """ 71-bit register (for accumlator) """ def __init__(self, high=None, low=None, padding_bit=0): if not high: high = Value() if not low: low = Value() self.high = WideValue() self.padding_bit = padding_bit self.low = Value() def from_number(self, v): assert isinstance(v, int) or isinstance(v, long), v print "v", v low = v & BIT_MASK_17 padding_bit = (v >> 17) & 1 high = v >> 18 print high, padding_bit, low self.high = WideValue.from_number(high) self.low = Value.from_number(low) self.padding_bit = padding_bit def as_number(self): return ( (self.high.as_number() << 18) + (self.padding_bit << 17) + self.low.as_number()) def __repr__(self): return "%r %d %s" % ( self.high, self.padding_bit, self.low.as_bits_string())
def from_number(v): assert isinstance(v, int) or isinstance(v, long), v low = v & BIT_MASK_17 padding_bit = (v >> 17) & 1 high = v >> 18 return WideValue(Value.from_number(high), Value.from_number(low), padding_bit)
def from_number(v): assert isinstance(v, int) or isinstance(v, long), v low = v & BIT_MASK_17 padding_bit = (v >> 17) & 1 high = v >> 18 return WideValue( Value.from_number(high), Value.from_number(low), padding_bit)
def load_initial_order(self): i = 0 for line in open("initial_order.txt"): bits_str = line[:20] v = Value.from_bits_string(bits_str) self.set_memory(i, v) i += 1
def from_number(self, v): assert isinstance(v, int) or isinstance(v, long), v print "v", v low = v & BIT_MASK_17 padding_bit = (v >> 17) & 1 high = v >> 18 print high, padding_bit, low self.high = WideValue.from_number(high) self.low = Value.from_number(low) self.padding_bit = padding_bit
def __init__(self, high=None, low=None, padding_bit=0): if not high: high = Value() if not low: low = Value() self.high = WideValue() self.padding_bit = padding_bit self.low = Value()
def Int(n): return Value(('INT', n))