public override Value Resolve(Value other) { WidthMismatchException.Check(width, other.Width); ValueLong o = other as ValueLong; if (o == null) { return(other.Resolve(this)); } else if (o.value == this.value) { return(this); } else { Value[] vs = new Value[width]; long src = this.value; long diff = this.value ^ o.value; for (int i = 0; i < vs.Length; i++) { if (((diff >> i) & 1) != 0) { vs[i] = Value.X; } else { vs[i] = ((src >> i) & 1) != 0 ? Value.One : Value.Zero; } } return(new ValueMultiBit(key, vs)); } }
public override Value Or(Value other) { Value[] v0s = values; WidthMismatchException.Check(v0s.Length, other.Width); Value[] ret = new Value[v0s.Length]; bool v0Same = true; bool v1Same = true; for (int i = 0; i < ret.Length; i++) { Value v0 = v0s[i]; Value v1 = other[i]; Value vx = v0.Or(v1); ret[i] = vx; if (vx != v0) { v0Same = false; } if (vx != v1) { v1Same = false; } } return(v0Same ? this : v1Same ? this : Value.Create(ret)); }
public override Value Or(Value other) { WidthMismatchException.Check(width, other.Width); ValueLong o = other as ValueLong; if (o == null) { return(other.Resolve(this)); } else if (o.value == this.value) { return(this); } else { return(new ValueLong(key, width, value | o.value)); } }
public override Value Or(Value other) { WidthMismatchException.Check(1, other.Width); Value a = this.Pull3; Value b = other.Pull3 as ValueOneBit; if (a == _One || b == _One) { return(_One); } else if (a == _X || b == _X) { return(_X); } else { return(_Zero); } }
public override Value Resolve(Value other) { /* | U X 0 1 Z W L H - * --+------------------ * U | U U U U U U U U U s5 * X | U X X X X X X X X s4 * 0 | U X 0 X 0 0 0 0 X s2 * 1 | U X X 1 1 1 1 1 X s2 * Z | U X 0 1 Z W L H X s0 * W | U X 0 1 W W W W X s1 * L | U X 0 1 L W L W X s1 * H | U X 0 1 H W W H X s1 * - | U X X X X X X X X s3 */ WidthMismatchException.Check(1, other.Width); ValueOneBit o = other as ValueOneBit; if (this.strength > o.strength) { return(this == _DontCare ? _X : this); } else if (o.strength > this.strength) { return(o == _DontCare ? _X : other); } else if (this == other) { return(this); } else if (this.strength == 1) { return(_W); } else { return(_X); } }