Package com.cburch.logisim.data

Examples of com.cburch.logisim.data.Value


          return;
        }
      }
 
      PinState pinState = getState(state);
      Value val = pinState.sending.get(bit);
      if (val == Value.FALSE) {
        val = Value.TRUE;
      } else if (val == Value.TRUE) {
        val = attrs.threeState ? Value.UNKNOWN : Value.FALSE;
      } else {
View Full Code Here


    state.setPort(OUTPUT, computeOutput(state), 1);
  }
 
  private Value computeOutput(InstanceState state) {
    BitWidth width = state.getAttributeValue(StdAttr.WIDTH);
    Value input = state.getPort(INPUT);
    Value gate0 = state.getPort(GATE0);
    Value gate1 = state.getPort(GATE1);

    if (gate0.isFullyDefined() && gate1.isFullyDefined() && gate0 != gate1) {
      if (gate0 == Value.TRUE) {
        return Value.createUnknown(width);
      } else {
        return input;
      }
View Full Code Here

    icon.paintIcon(painter.getDestination(), painter.getGraphics(), 2, 2);
  }
 
  @Override
  public void paintGhost(InstancePainter painter) {
    Value pull = getPullValue(painter.getAttributeSet());
    paintBase(painter, pull, null, null);
  }
View Full Code Here

    Location loc = painter.getLocation();
    int x = loc.getX();
    int y = loc.getY();
    Graphics g = painter.getGraphics();
    g.translate(x, y);
    Value pull = getPullValue(painter.getAttributeSet());
    Value actual = painter.getPort(0);
    paintBase(painter, pull, pull.getColor(), actual.getColor());
    g.translate(-x, -y);
    painter.drawPorts();
  }
View Full Code Here

    }
  }

  @Override
  public void propagate(InstanceState state) {
    Value in = state.getPort(1);
    BitWidth wout = state.getAttributeValue(ATTR_OUT_WIDTH);
    String type = getType(state.getAttributeSet());
    Value extend;
    if (type.equals("one")) {
      extend = Value.TRUE;
    } else if (type.equals("sign")) {
      int win = in.getWidth();
      extend = win > 0 ? in.get(win - 1) : Value.ERROR;
    } else if (type.equals("input")) {
      extend = state.getPort(2);
      if (extend.getWidth() != 1) extend = Value.ERROR;
    } else {
      extend = Value.FALSE;
    }
   
    Value out = in.extendWidth(wout.getWidth(), extend);
    state.setPort(0, out, 1);
  }
View Full Code Here

    public void propagate(InstanceState state) {
        // get attributes
        BitWidth dataWidth = state.getAttributeValue(StdAttr.WIDTH);

        // compute outputs
        Value a = state.getPort(IN0);
        Value b = state.getPort(IN1);
        Value c_in = state.getPort(C_IN);
        Value[] outs = Adder.computeSum(dataWidth, a, b, c_in);

        // propagate them
        int delay = (dataWidth.getWidth() + 2) * PER_DELAY;
        state.setPort(OUT,   outs[0], delay);
View Full Code Here

                return new Value[] { Value.createKnown(width, sum),
                    ((sum >> w) & 1) == 0 ? Value.FALSE : Value.TRUE };
            }
        } else {
            Value[] bits = new Value[w];
            Value carry = c_in;
            for (int i = 0; i < w; i++) {
                if (carry == Value.ERROR) {
                    bits[i] = Value.ERROR;
                } else if (carry == Value.UNKNOWN) {
                    bits[i] = Value.UNKNOWN;
                } else {
                    Value ab = a.get(i);
                    Value bb = b.get(i);
                    if (ab == Value.ERROR || bb == Value.ERROR) {
                        bits[i] = Value.ERROR;
                        carry = Value.ERROR;
                    } else if (ab == Value.UNKNOWN || bb == Value.UNKNOWN) {
                        bits[i] = Value.UNKNOWN;
View Full Code Here

class GateFunctions {
    private GateFunctions() { }

    static Value computeOr(Value[] inputs, int numInputs) {
        Value ret = inputs[0];
        for (int i = 1; i < numInputs; i++) {
            ret = ret.or(inputs[i]);
        }
        return ret;
    }
View Full Code Here

        }
        return ret;
    }

    static Value computeAnd(Value[] inputs, int numInputs) {
        Value ret = inputs[0];
        for (int i = 1; i < numInputs; i++) {
            ret = ret.and(inputs[i]);
        }
        return ret;
    }
View Full Code Here

        }
        return ret;
    }

    static Value computeOddParity(Value[] inputs, int numInputs) {
        Value ret = inputs[0];
        for (int i = 1; i < numInputs; i++) {
            ret = ret.xor(inputs[i]);
        }
        return ret;
    }
View Full Code Here

TOP

Related Classes of com.cburch.logisim.data.Value

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.