Package com.cburch.logisim.data

Examples of com.cburch.logisim.data.Value


  @Override
  public void propagate(InstanceState circState) {
    Object trigger = circState.getAttributeValue(StdAttr.EDGE_TRIGGER);
    KeyboardData state = getKeyboardState(circState);
    Value clear = circState.getPort(CLR);
    Value clock = circState.getPort(CK);
    Value enable = circState.getPort(RE);
    char c;
   
    synchronized(state) {
      Value lastClock = state.setLastClock(clock);
      if (clear == Value.TRUE) {
        state.clear();
      } else if (enable != Value.FALSE) {
        boolean go;
        if (trigger == StdAttr.TRIG_FALLING) {
          go = lastClock == Value.TRUE && clock == Value.FALSE;
        } else {
          go = lastClock == Value.FALSE && clock == Value.TRUE;
        }
        if (go) state.dequeue();
      }
   
      c = state.getChar(0);
    }
    Value out = Value.createKnown(BitWidth.create(7), c & 0x7F);
    circState.setPort(OUT, out, DELAY0);
    circState.setPort(AVL, c != '\0' ? Value.TRUE : Value.FALSE, DELAY1);
  }
View Full Code Here


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

    // compute outputs
    Value gt = Value.FALSE;
    Value eq = Value.TRUE;
    Value lt = Value.FALSE;

    Value a = state.getPort(IN0);
    Value b = state.getPort(IN1);
    Value[] ax = a.getAll();
    Value[] bx = b.getAll();
    int maxlen = Math.max(ax.length, bx.length);
    for (int pos = maxlen - 1; pos >= 0; pos--) {
      Value ab = pos < ax.length ? ax[pos] : Value.ERROR;
      Value bb = pos < bx.length ? bx[pos] : Value.ERROR;
      if (pos == ax.length - 1 && ab != bb) {
        Object mode = state.getAttributeValue(MODE_ATTRIBUTE);
        if (mode != UNSIGNED_OPTION) {
          Value t = ab;
          ab = bb;
          bb = t;
        }
      }
View Full Code Here

    boolean triggered = data.updateClock(state.getPort(CK), triggerType);

    if (state.getPort(CLR) == Value.TRUE) {
      data.value = 0;
    } else if (triggered && state.getPort(EN) != Value.FALSE) {
      Value in = state.getPort(IN);
      if (in.isFullyDefined()) data.value = in.toIntValue();
    }

    state.setPort(OUT, Value.createKnown(dataWidth, data.value), DELAY);
  }
View Full Code Here

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

    // compute outputs
    Value a = state.getPort(IN0);
    Value b = state.getPort(IN1);
    Value b_in = state.getPort(B_IN);
    if (b_in == Value.UNKNOWN || b_in == Value.NIL) b_in = Value.FALSE;
    Value[] outs = Adder.computeSum(data, a, b.not(), b_in.not());

    // propagate them
    int delay = (data.getWidth() + 4) * Adder.PER_DELAY;
    state.setPort(OUT,   outs[0],       delay);
    state.setPort(B_OUT, outs[1].not(), delay);
View Full Code Here

      return null;
    }
  }
 
  public Value setLastClock(Value newClock) {
    Value ret = lastClock;
    lastClock = newClock;
    return ret;
  }
View Full Code Here

    BitWidth dataBits = state.getAttributeValue(DATA_ATTR);
    Object busVal = state.getAttributeValue(ATTR_BUS);
    boolean asynch = busVal == null ? false : busVal.equals(BUS_ASYNCH);
    boolean separate = busVal == null ? false : busVal.equals(BUS_SEPARATE);

    Value addrValue = state.getPort(ADDR);
    boolean chipSelect = state.getPort(CS) != Value.FALSE;
    boolean triggered = asynch || myState.setClock(state.getPort(CLK), StdAttr.TRIG_RISING);
    boolean outputEnabled = state.getPort(OE) != Value.FALSE;
    boolean shouldClear = state.getPort(CLR) == Value.TRUE;
   
    if (shouldClear) {
      myState.getContents().clear();
    }
   
    if (!chipSelect) {
      myState.setCurrent(-1);
      state.setPort(DATA, Value.createUnknown(dataBits), DELAY);
      return;
    }

    int addr = addrValue.toIntValue();
    if (!addrValue.isFullyDefined() || addr < 0)
      return;
    if (addr != myState.getCurrent()) {
      myState.setCurrent(addr);
      myState.scrollToShow(addr);
    }

    if (!shouldClear && triggered) {
      boolean shouldStore;
      if (separate) {
        shouldStore = state.getPort(WE) != Value.FALSE;
      } else {
        shouldStore = !outputEnabled;
      }
      if (shouldStore) {
        Value dataValue = state.getPort(separate ? DIN : DATA);
        myState.getContents().set(addr, dataValue.toIntValue());
      }
    }

    if (outputEnabled) {
      int val = myState.getContents().get(addr);
View Full Code Here

      ValueLog log = model.getValueLog(item);
      int radix = item.getRadix();
      int offs = rowCount - log.size();
      y = y0 + Math.max(offs, firstRow) * cellHeight;
      for (int row = Math.max(offs, firstRow); row < lastRow; row++) {
        Value val = log.get(row - offs);
        String label = val.toDisplayString(radix);
        int width = bodyMetric.stringWidth(label);
        g.drawString(label, x + (cellWidth - width) / 2,
            y + bodyMetric.getAscent());
        y += cellHeight;
      }
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 = Multiplier.computeProduct(dataWidth, a, b, c_in);

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

    BitWidth select = state.getAttributeValue(Plexers.ATTR_SELECT);
    int n = 1 << select.getWidth();
    boolean enabled = state.getPort(n + EN_IN) != Value.FALSE;
   
    int out = -1;
    Value outDefault;
    if (enabled) {
      outDefault = Value.createUnknown(select);
      for (int i = n - 1; i >= 0; i--) {
        if (state.getPort(i) == Value.TRUE) {
          out = i;
          break;
        }
      }
    } else {
      Object opt = state.getAttributeValue(Plexers.ATTR_DISABLED);
      Value base = opt == Plexers.DISABLED_ZERO ? Value.FALSE : Value.UNKNOWN;
      outDefault = Value.repeat(base, select.getWidth());
    }
    if (out < 0) {
      state.setPort(n + OUT, outDefault, Plexers.DELAY);
      state.setPort(n + EN_OUT, enabled ? Value.TRUE : Value.FALSE, Plexers.DELAY);
View Full Code Here

        x, y, halign, valign);
  }

  @Override
  public void propagate(InstanceState state) {
    Value val = state.getPort(0);
    InstanceDataSingleton data = (InstanceDataSingleton) state.getData();
    if (data == null) {
      state.setData(new InstanceDataSingleton(val));
    } else {
      data.setValue(val);
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.