Package com.cburch.logisim.data

Examples of com.cburch.logisim.data.BitWidth


    }
    g.drawLine(0, 0, 5, 0);

    GraphicsUtil.switchToWidth(g, 1);
    if (!isGhost && painter.shouldDrawColor()) {
      BitWidth width = painter.getAttributeValue(StdAttr.WIDTH);
      g.setColor(Value.repeat(Value.FALSE, width.getWidth()).getColor());
    }
    g.drawLine(6, -8, 6, 8);
    g.drawLine(9, -5, 9, 5);
    g.drawLine(12, -2, 12, 2);
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 gate = state.getPort(GATE);
    Value input = state.getPort(INPUT);
    Value desired = state.getAttributeValue(ATTR_TYPE) == TYPE_P
      ? Value.FALSE : Value.TRUE;
View Full Code Here

      .rotate(Direction.EAST, attrs.getValue(StdAttr.FACING), 0, 0);
  }

  @Override
  public void propagate(InstanceState state) {
    BitWidth width = state.getAttributeValue(StdAttr.WIDTH);
    state.setPort(0, Value.repeat(Value.TRUE, width.getWidth()), 1);
  }
View Full Code Here

    }
    g.drawLine(0, 0, 5, 0);

    GraphicsUtil.switchToWidth(g, 1);
    if (!isGhost && painter.shouldDrawColor()) {
      BitWidth width = painter.getAttributeValue(StdAttr.WIDTH);
      g.setColor(Value.repeat(Value.TRUE, width.getWidth()).getColor());
    }
    g.drawPolygon(new int[] { 6, 14, 6 }, new int[] { -8, 0, 8 }, 3);

    g.dispose();
  }
View Full Code Here

  }

  @Override
  public Bounds getOffsetBounds(AttributeSet attrs) {
    Direction facing = attrs.getValue(StdAttr.FACING);
    BitWidth width = attrs.getValue(StdAttr.WIDTH);
    return Probe.getOffsetBounds(facing, width, RadixOption.RADIX_2);
  }
View Full Code Here

  // graphics methods
  //
  @Override
  public void paintIcon(InstancePainter painter) {
    paintIconBase(painter);
    BitWidth w = painter.getAttributeValue(StdAttr.WIDTH);
    if (!w.equals(BitWidth.ONE)) {
      Graphics g = painter.getGraphics();
      g.setColor(ICON_WIDTH_COLOR);
      g.setFont(ICON_WIDTH_FONT);
      GraphicsUtil.drawCenteredText(g, "" + w.getWidth(), 10, 9);
      g.setColor(Color.BLACK);
    }
  }
View Full Code Here

    int y = loc.getY();
    Graphics g = painter.getGraphics();
    GraphicsUtil.switchToWidth(g, 2);
    boolean output = attrs.isOutput();
    if (output) {
      BitWidth width = attrs.getValue(StdAttr.WIDTH);
      if (width == BitWidth.ONE) {
        g.drawOval(x + bds.getX() + 1, y + bds.getY() + 1,
          bds.getWidth() - 1, bds.getHeight() - 1);
      } else {
        g.drawRoundRect(x + bds.getX() + 1, y + bds.getY() + 1,
View Full Code Here

    }
  }
 
  private static PinState getState(InstanceState state) {
    PinAttributes attrs = (PinAttributes) state.getAttributeSet();
    BitWidth width = attrs.width;
    PinState ret = (PinState) state.getData();
    if (ret == null) {
      Value val = attrs.threeState ? Value.UNKNOWN : Value.FALSE;
      if (width.getWidth() > 1) {
        Value[] arr = new Value[width.getWidth()];
        java.util.Arrays.fill(arr, val);
        val = Value.create(arr);
      }
      ret = new PinState(val, val);
      state.setData(ret);
    }
    if (ret.sending.getWidth() != width.getWidth()) {
      ret.sending = ret.sending.extendWidth(width.getWidth(),
          attrs.threeState ? Value.UNKNOWN : Value.FALSE);
    }
    if (ret.receiving.getWidth() != width.getWidth()) {
      ret.receiving = ret.receiving.extendWidth(width.getWidth(), Value.UNKNOWN);
    }
    return ret;
  }
View Full Code Here

    return super.getInstanceFeature(instance, key);
  }

  @Override
  public void propagate(InstanceState state) {
    BitWidth width = state.getAttributeValue(StdAttr.WIDTH);
    int value = state.getAttributeValue(ATTR_VALUE).intValue();
    state.setPort(0, Value.createKnown(width, value), 1);
  }
View Full Code Here

  }

  @Override
  public Bounds getOffsetBounds(AttributeSet attrs) {
    Direction facing = attrs.getValue(StdAttr.FACING);
    BitWidth width = attrs.getValue(StdAttr.WIDTH);
    int chars = (width.getWidth() + 3) / 4;

    Bounds ret = null;
    if (facing == Direction.EAST) {
      switch (chars) {
      case 1: ret = Bounds.create(-16, -8, 16, 16); break;
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.