Package com.cburch.logisim.data

Examples of com.cburch.logisim.data.Value


    }
  }

  @Override
  public void propagate(InstanceState state) {
    Value in = state.getPort(1);
    Value out = in.not();
    out = Buffer.repair(state, out);
    state.setPort(0, out, GateAttributes.DELAY);
  }
View Full Code Here


  @Override
  public void propagate(InstanceState circState) {
    Object trigger = circState.getAttributeValue(StdAttr.EDGE_TRIGGER);
    TtyState state = getTtyState(circState);
    Value clear = circState.getPort(CLR);
    Value clock = circState.getPort(CK);
    Value enable = circState.getPort(WE);
    Value in = circState.getPort(IN);
   
    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) {
View Full Code Here

  @Override
  public void propagate(InstanceState state) {
    // First we retrieve the value being fed into the input. Note that in
    // the setPorts invocation above, the component's input was included at
    // index 0 in the parameter array, so we use 0 as the parameter below.
    Value in = state.getPort(0);
   
    // Now compute the output. We've farmed this out to a helper method,
    // since the same logic is needed for the library's other components.
    Value out = nextGray(in);
   
    // Finally we propagate the output into the circuit. The first parameter
    // is 1 because in our list of ports (configured by invocation of
    // setPorts above) the output is at index 1. The second parameter is the
    // value we want to send on that port. And the last parameter is its
    // "delay" - the number of steps it will take for the output to update
    // after its input.
    state.setPort(1, out, out.getWidth() + 1);
  }
View Full Code Here

    catch (CloneNotSupportedException e) { return null; }
  }
 
  /** Updates the last clock observed, returning true if triggered. */
  public boolean updateClock(Value value) {
    Value old = lastClock;
    lastClock = value;
    return old == Value.FALSE && value == Value.TRUE;
  }
View Full Code Here

    if (val < 0 || (val & width.getMask()) != val) return;

    // compute the next value
    CounterData cur = CounterData.get(state, width);
    int newVal = (cur.getValue().toIntValue() * 16 + val) & width.getMask();
    Value newValue = Value.createKnown(width, newVal);
    cur.setValue(newValue);
    state.fireInvalidated();
   
    // You might be tempted to propagate the value immediately here, using
    // state.setPort. However, the circuit may currently be propagating in
View Full Code Here

    Graphics g = context.getGraphics();
    Color oldColor = g.getColor();
    GraphicsUtil.switchToWidth(g, Wire.WIDTH);
    for (int i = 0, n = attrs.fanout; i < n; i++) {
      if (showState) {
        Value val = state.getValue(Location.create(x, y));
        g.setColor(val.getColor());
      }
      g.drawLine(x, y, x + dxEndSpine, y + dyEndSpine);
      x += dx;
      y += dy;
    }
View Full Code Here

      } else {
        for (int j = 0; j < columns.length; j++) {
          Instance pin = outputPins.get(j);
          InstanceState pinState = circuitState.getInstanceState(pin);
          Entry out;
          Value outValue = Pin.FACTORY.getValue(pinState).get(0);
          if (outValue == Value.TRUE) out = Entry.ONE;
          else if (outValue == Value.FALSE) out = Entry.ZERO;
          else if (outValue == Value.ERROR) out = Entry.BUS_ERROR;
          else out = Entry.DONT_CARE;
          columns[j][i] = out;
View Full Code Here

      this.opts = opts;
    }

    @Override
    public void draw(Graphics g) {
      Value v = canvas.getCircuitState().getValue(wire.getEnd0());
      RadixOption radix1 = RadixOption.decode(AppPreferences.POKE_WIRE_RADIX1.get());
      RadixOption radix2 = RadixOption.decode(AppPreferences.POKE_WIRE_RADIX2.get());
      if (radix1 == null) radix1 = RadixOption.RADIX_2;
      String vStr = radix1.toString(v);
      if (radix2 != null && v.getWidth() > 1) {
        vStr += " / " + radix2.toString(v);
      }
     
      FontMetrics fm = g.getFontMetrics();
      g.setColor(caretColor);
View Full Code Here

      Value[] inputs = new Value[n];
      for (int i = 0; i < n; i++) {
        inputs[i] = state.getPort(i);
      }

      Value newVal = computeValue(inputs, data.curValue);
      if (newVal == Value.TRUE || newVal == Value.FALSE) {
        changed |= data.curValue != newVal;
        data.curValue = newVal;
      }
    }
View Full Code Here

    if (widObj.equals(BitWidth.ONE)) {
      int newLoc = computeStage(state, e);
      if (oldLoc == newLoc) {
        ShiftRegisterData data = (ShiftRegisterData) state.getData();
        int i = data.getLength() - 1 - loc;
        Value v = data.get(i);
        if (v == Value.FALSE) v = Value.TRUE;
        else v = Value.FALSE;
        data.set(i, v);
        state.fireInvalidated();
      }
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.