예제 #1
0
        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));
            }
        }
예제 #2
0
        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));
            }
        }
예제 #3
0
        public override bool Equals(object other)
        {
            ValueLong o = other as ValueLong;

            return(o != null && this.width == o.width && this.value == o.value);
        }