Package com.cburch.logisim.data

Examples of com.cburch.logisim.data.BitWidth


  }
 
  @Override
  public void paintInstance(InstancePainter painter) {
    Bounds bds = painter.getOffsetBounds();
    BitWidth width = painter.getAttributeValue(StdAttr.WIDTH);
    int intValue = painter.getAttributeValue(ATTR_VALUE).intValue();
    Value v = Value.createKnown(width, intValue);
    Location loc = painter.getLocation();
    int x = loc.getX();
    int y = loc.getY();
View Full Code Here


  void ensureComputed() {
    getBundleMap();
  }

  BitWidth getWidth(Location q) {
    BitWidth det = points.getWidth(q);
    if (det != BitWidth.UNKNOWN) return det;

    BundleMap bmap = getBundleMap();
    if (!bmap.isValid()) return BitWidth.UNKNOWN;
    WireBundle qb = bmap.getBundleAt(q);
View Full Code Here

    return BitWidth.UNKNOWN;
  }

  Location getWidthDeterminant(Location q) {
    BitWidth det = points.getWidth(q);
    if (det != BitWidth.UNKNOWN) return q;

    WireBundle qb = getBundleMap().getBundleAt(q);
    if (qb != null && qb.isValid()) return qb.getWidthDeterminant();
View Full Code Here

    // set the width for each bundle whose size is known
    // based on components
    for (Location p : ret.getBundlePoints()) {
      WireBundle pb = ret.getBundleAt(p);
      BitWidth width = points.getWidth(p);
      if (width != BitWidth.UNKNOWN) {
        pb.setWidth(width, p);
      }
    }
View Full Code Here

      pinState.sending = pinState.sending.set(bit, val);
      state.fireInvalidated();
    }
 
    private int getBit(InstanceState state, MouseEvent e) {
      BitWidth width = state.getAttributeValue(StdAttr.WIDTH);
      if (width.getWidth() == 1) {
        return 0;
      } else {
        Bounds bds = state.getInstance().getBounds(); // intentionally with no graphics object - we don't want label included
        int i = (bds.getX() + bds.getWidth() - e.getX()) / 10;
        int j = (bds.getY() + bds.getHeight() - e.getY()) / 20;
        int bit = 8 * j + i;
        if (bit < 0 || bit >= width.getWidth()) {
          return -1;
        } else {
          return bit;
        }
      }
View Full Code Here

    super(Constant.ATTR_VALUE, 0, 0, 0, 16);
  }

  @Override
  public int getMaximumValue(AttributeSet attrs) {
    BitWidth width = attrs.getValue(StdAttr.WIDTH);
    int ret = width.getMask();
    if (ret >= 0) {
      return ret;
    } else {
      return Integer.MAX_VALUE;
    }
View Full Code Here

    }
  }

  @Override
  public int getMinimumValue(AttributeSet attrs) {
    BitWidth width = attrs.getValue(StdAttr.WIDTH);
    if (width.getWidth() < 32) {
      return 0;
    } else {
      return Integer.MIN_VALUE;
    }
  }
View Full Code Here

  public void propagate(InstanceState state) {
    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) {
View Full Code Here

    GraphicsUtil.drawText(g, s0, x, y0,
        GraphicsUtil.H_CENTER, GraphicsUtil.V_BASELINE);
    GraphicsUtil.drawText(g, s1, x, y1,
        GraphicsUtil.H_CENTER, GraphicsUtil.V_BASELINE);
   
    BitWidth w0 = painter.getAttributeValue(ATTR_OUT_WIDTH);
    BitWidth w1 = painter.getAttributeValue(ATTR_IN_WIDTH);
    painter.drawPort(0, "" + w0.getWidth(), Direction.WEST);
    painter.drawPort(1, "" + w1.getWidth(), Direction.EAST);
    if (type.equals("input")) painter.drawPort(2);
  }
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

TOP

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

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.