Examples of BitWidth


Examples of com.cburch.logisim.data.BitWidth

  public Value getValue(Location pt) {
    Value ret = values.get(pt);
    if (ret != null) return ret;

    BitWidth wid = circuit.getWidth(pt);
    return Value.createUnknown(wid);
  }
View Full Code Here

Examples of com.cburch.logisim.data.BitWidth

  }

  private void computeIncompatibilityData(Location loc, LocationData locData) {
    WidthIncompatibilityData error = null;
    if (locData != null) {
      BitWidth width = BitWidth.UNKNOWN;
      for (EndData endData : locData.ends) {
        if (endData != null) {
          BitWidth endWidth = endData.getWidth();
          if (width == BitWidth.UNKNOWN) {
            width = endWidth;
          } else if (width != endWidth && endWidth != BitWidth.UNKNOWN) {
            if (error == null) {
              error = new WidthIncompatibilityData();
View Full Code Here

Examples of com.cburch.logisim.data.BitWidth

      fanout = (byte) newValue;
      configureOptions();
      configureDefaults();
      parameters = null;
    } else if (attr == ATTR_WIDTH) {
      BitWidth width = (BitWidth) value;
      bit_end = new byte[width.getWidth()];
      configureOptions();
      configureDefaults();
    } else if (attr == ATTR_APPEARANCE) {
      appear = (AttributeOption) value;
      parameters = null;
View Full Code Here

Examples of com.cburch.logisim.data.BitWidth

      return ret != null && !ret.equals("") ? ret : null;
    }
 
    @Override
    public Value getLogValue(InstanceState state, Object option) {
      BitWidth dataWidth = state.getAttributeValue(StdAttr.WIDTH);
      if (dataWidth == null) dataWidth = BitWidth.create(0);
      StateData data = (StateData) state.getData();
      if (data == null) return Value.createKnown(dataWidth, 0);
      return Value.createKnown(dataWidth, data.value);
    }
View Full Code Here

Examples of com.cburch.logisim.data.BitWidth

    if (data == null) {
      data = new RegisterData();
      state.setData(data);
    }

    BitWidth dataWidth = state.getAttributeValue(StdAttr.WIDTH);
    Object triggerType = state.getAttributeValue(StdAttr.EDGE_TRIGGER);
    int max = state.getAttributeValue(ATTR_MAX).intValue();
    Value clock = state.getPort(CK);
    boolean triggered = data.updateClock(clock, triggerType);
View Full Code Here

Examples of com.cburch.logisim.data.BitWidth

  @Override
  public void paintInstance(InstancePainter painter) {
    Graphics g = painter.getGraphics();
    Bounds bds = painter.getBounds();
    RegisterData state = (RegisterData) painter.getData();
    BitWidth widthVal = painter.getAttributeValue(StdAttr.WIDTH);
    int width = widthVal == null ? 8 : widthVal.getWidth();

    // determine text to draw in label
    String a;
    String b = null;
    if (painter.getShowState()) {
      int val = state == null ? 0 : state.value;
      String str = StringUtil.toHexString(width, val);
      if (str.length() <= 4) {
        a = str;
      } else {
        int split = str.length() - 4;
        a = str.substring(0, split);
        b = str.substring(split);
      }
    } else {
      a = Strings.get("counterLabel");
      b = Strings.get("registerWidthLabel", "" + widthVal.getWidth());
    }

    // draw boundary, label
    painter.drawBounds();
    painter.drawLabel();
View Full Code Here

Examples of com.cburch.logisim.data.BitWidth

  @Override
  public Bounds getOffsetBounds(AttributeSet attrs) {
    Direction facing = attrs.getValue(StdAttr.FACING);
    Object selectLoc = attrs.getValue(Plexers.ATTR_SELECT_LOC);
    BitWidth select = attrs.getValue(Plexers.ATTR_SELECT);
    int outputs = 1 << select.getWidth();
    Bounds bds;
    boolean reversed = facing == Direction.WEST || facing == Direction.NORTH;
    if (selectLoc == Plexers.SELECT_TOP_RIGHT) reversed = !reversed;
    if (outputs == 2) {
      int y = reversed ? 0 : -40;
View Full Code Here

Examples of com.cburch.logisim.data.BitWidth

  }

  private void updatePorts(Instance instance) {
    Direction facing = instance.getAttributeValue(StdAttr.FACING);
    Object selectLoc = instance.getAttributeValue(Plexers.ATTR_SELECT_LOC);
    BitWidth select = instance.getAttributeValue(Plexers.ATTR_SELECT);
    boolean enable = instance.getAttributeValue(Plexers.ATTR_ENABLE).booleanValue();
    int outputs = 1 << select.getWidth();
    Port[] ps = new Port[outputs + (enable ? 2 : 1)];
    if (outputs == 2) {
      Location end0;
      Location end1;
      if (facing == Direction.NORTH || facing == Direction.SOUTH) {
        int y = facing == Direction.NORTH ? -10 : 10;
        if (selectLoc == Plexers.SELECT_TOP_RIGHT) {
          end0 = Location.create(-30, y);
          end1 = Location.create(-10, y);
        } else {
          end0 = Location.create(10, y);
          end1 = Location.create(30, y);
        }
      } else {
        int x = facing == Direction.WEST ? -10 : 10;
        if (selectLoc == Plexers.SELECT_TOP_RIGHT) {
          end0 = Location.create(x, 10);
          end1 = Location.create(x, 30);
        } else {
          end0 = Location.create(x, -30);
          end1 = Location.create(x, -10);
        }
      }
      ps[0] = new Port(end0.getX(), end0.getY(), Port.OUTPUT, 1);
      ps[1] = new Port(end1.getX(), end1.getY(), Port.OUTPUT, 1);
    } else {
      int dx;
      int ddx;
      int dy;
      int ddy;
      if (facing == Direction.NORTH || facing == Direction.SOUTH) {
        dy = facing == Direction.NORTH ? -20 : 20;
        ddy = 0;
        dx = selectLoc == Plexers.SELECT_TOP_RIGHT ? -10 * outputs : 0;
        ddx = 10;
      } else {
        dx = facing == Direction.WEST ? -20 : 20;
        ddx = 0;
        dy = selectLoc == Plexers.SELECT_TOP_RIGHT ? 0 : -10 * outputs;
        ddy = 10;
      }
      for (int i = 0; i < outputs; i++) {
        ps[i] = new Port(dx, dy, Port.OUTPUT, 1);
        dx += ddx;
        dy += ddy;
      }
    }
    Location en = Location.create(0, 0).translate(facing, -10);
    ps[outputs] = new Port(0, 0, Port.INPUT, select.getWidth());
    if (enable) {
      ps[outputs + 1] = new Port(en.getX(), en.getY(), Port.INPUT, BitWidth.ONE);
    }
    for (int i = 0; i < outputs; i++) {
      ps[i].setToolTip(Strings.getter("decoderOutTip", "" + i));
View Full Code Here

Examples of com.cburch.logisim.data.BitWidth

  }

  @Override
  public void propagate(InstanceState state) {
    // get attributes
    BitWidth data = BitWidth.ONE;
    BitWidth select = state.getAttributeValue(Plexers.ATTR_SELECT);
    Boolean threeState = state.getAttributeValue(Plexers.ATTR_TRISTATE);
    boolean enable = state.getAttributeValue(Plexers.ATTR_ENABLE).booleanValue();
    int outputs = 1 << select.getWidth();
   
    // determine default output values
    Value others; // the default output
    if (threeState.booleanValue()) {
      others = Value.UNKNOWN;
View Full Code Here

Examples of com.cburch.logisim.data.BitWidth

  }

  @Override
  public void paintGhost(InstancePainter painter) {
    Direction facing = painter.getAttributeValue(StdAttr.FACING);
    BitWidth select = painter.getAttributeValue(Plexers.ATTR_SELECT);
    Plexers.drawTrapezoid(painter.getGraphics(), painter.getBounds(),
        facing.reverse(), select.getWidth() == 1 ? 10 : 20);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.