Package com.cburch.logisim.data

Examples of com.cburch.logisim.data.Value


    }
    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


    int width = inputs[0].getWidth();
    Value[] ret = new Value[width];
    for (int i = 0; i < width; i++) {
      int count = 0;
      for (int j = 0; j < numInputs; j++) {
        Value v = inputs[j].get(i);
        if (v == Value.TRUE) {
          count++;
        } else if (v == Value.FALSE) {
          ; // do nothing
        } else {
View Full Code Here

    Instance[] pins = attrs.getPinInstances();
    for (int i = 0; i < pins.length; i++) {
      Instance pin = pins[i];
      InstanceState pinState = subState.getInstanceState(pin);
      if (Pin.FACTORY.isInputPin(pin)) {
        Value newVal = superState.getPort(i);
        Value oldVal = Pin.FACTORY.getValue(pinState);
        if (!newVal.equals(oldVal)) {
          Pin.FACTORY.setValue(pinState, newVal);
          Pin.FACTORY.propagate(pinState);
        }
      } else { // it is output-only
        Value val = pinState.getPort(0);
        superState.setPort(i, val, 1);
      }
    }
  }
View Full Code Here

        if (errorIfUndefined) {
          error = true;
        }
      }
    }
    Value out = null;
    if (numInputs == 0 || error) {
      out = Value.createError(attrs.width);
    } else {
      out = computeOutput(inputs, numInputs, state);
      out = pullOutput(out, attrs.out);
View Full Code Here

  @Override
  public void propagate(InstanceState state) {
    MemState myState = getState(state);
    BitWidth dataBits = state.getAttributeValue(DATA_ATTR);

    Value addrValue = state.getPort(ADDR);
    boolean chipSelect = state.getPort(CS) != Value.FALSE;
   
    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);
    }
View Full Code Here

    for (int j = 0; j < rows; j++) {
      for (int i = 0; i < cols; i++) {
        int x = bds.getX() + 10 * i;
        int y = bds.getY() + 10 * j;
        if (showState) {
          Value val = data.get(j, i, ticks);
          Color c;
          if (val == Value.TRUE) c = onColor;
          else if (val == Value.FALSE) c = offColor;
          else c = Value.ERROR_COLOR;
          g.setColor(c);
View Full Code Here

      }
    }
   
    private Value get(int row, int col, long curTick) {
      int index = row * cols + col;
      Value ret = grid[index];
      if (ret == Value.FALSE && persistTo[index] - curTick >= 0) {
        ret = Value.TRUE;
      }
      return ret;
    }
View Full Code Here

    private void setRow(int index, Value rowVector, long persist) {
      int gridloc = (index + 1) * cols - 1;
      int stride = -1;
      Value[] vals = rowVector.getAll();
      for (int i = 0; i < vals.length; i++, gridloc += stride) {
        Value val = vals[i];
        if (grid[gridloc] == Value.TRUE) {
          persistTo[gridloc] = persist - 1;
        }
        grid[gridloc] = vals[i];
        if (val == Value.TRUE) {
View Full Code Here

    private void setColumn(int index, Value colVector, long persist) {
      int gridloc = (rows - 1) * cols + index;
      int stride = -cols;
      Value[] vals = colVector.getAll();
      for (int i = 0; i < vals.length; i++, gridloc += stride) {
        Value val = vals[i];
        if (grid[gridloc] == Value.TRUE) {
          persistTo[gridloc] = persist - 1;
        }
        grid[gridloc] = val;
        if (val == Value.TRUE) {
View Full Code Here

    private void setSelect(Value rowVector, Value colVector, long persist) {
      Value[] rowVals = rowVector.getAll();
      Value[] colVals = colVector.getAll();
      int gridloc = 0;
      for (int i = rowVals.length - 1; i >= 0; i--) {
        Value wholeRow = rowVals[i];
        if (wholeRow == Value.TRUE) {
          for (int j = colVals.length - 1; j >= 0; j--, gridloc++) {
            Value val = colVals[colVals.length - 1 - j];
            if (grid[gridloc] == Value.TRUE) {
              persistTo[gridloc] = persist - 1;
            }
            grid[gridloc] = val;
            if (val == Value.TRUE) {
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.