Package com.cburch.logisim.instance

Examples of com.cburch.logisim.instance.InstanceState


   
    boolean found = false;
    for (Component comp : circState.getCircuit().getNonWires()) {
      if (comp.getFactory() instanceof Ram) {
        Ram ramFactory = (Ram) comp.getFactory();
        InstanceState ramState = circState.getInstanceState(comp);
        ramFactory.loadImage(ramState, loadFile);
        found = true;
      }
    }
   
View Full Code Here


    boolean found = false;
    for (Component comp : circState.getCircuit().getNonWires()) {
      Object factory = comp.getFactory();
      if (factory instanceof Tty) {
        Tty ttyFactory = (Tty) factory;
        InstanceState ttyState = circState.getInstanceState(comp);
        ttyFactory.sendToStdout(ttyState);
        found = true;
      } else if (factory instanceof Keyboard) {
        keybStates.add(circState.getInstanceState(comp));
        found = true;
View Full Code Here

    ArrayList<Value> prevOutputs = null;
    Propagator prop = circState.getPropagator();
    while (true) {
      ArrayList<Value> curOutputs = new ArrayList<Value>();
      for (Instance pin : outputPins) {
        InstanceState pinState = circState.getInstanceState(pin);
        Value val = Pin.FACTORY.getValue(pinState);
        if (pin == haltPin) {
          halted |= val.equals(Value.TRUE);
        } else if (showTable) {
          curOutputs.add(val);
View Full Code Here

    CircuitAttributes attrs = (CircuitAttributes) superState.getAttributeSet();
    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

   
    for (int i = 0; i < rowCount; i++) {
      CircuitState circuitState = new CircuitState(proj, circuit);
      for (int j = 0; j < inputCount; j++) {
        Instance pin = inputPins.get(j);
        InstanceState pinState = circuitState.getInstanceState(pin);
        boolean value = TruthTable.isInputSet(i, j, inputCount);
        Pin.FACTORY.setValue(pinState, value ? Value.TRUE : Value.FALSE);
      }
     
      Propagator prop = circuitState.getPropagator();
      prop.propagate();
      /* TODO for the SimulatorPrototype class
      do {
        prop.step();
      } while (prop.isPending()); */
      // TODO: Search for circuit state
     
      if (prop.isOscillating()) {
        for (int j = 0; j < columns.length; j++) {
          columns[j][i] = Entry.OSCILLATE_ERROR;
        }
      } 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;
View Full Code Here

        for (int i = 0; i < rowCount; i++) {
            CircuitState circuitState = new CircuitState(proj, circuit);
            for (int j = 0; j < inputCount; j++) {
                Instance pin = inputPins.get(j);
                InstanceState pinState = circuitState.getInstanceState(pin);
                boolean value = TruthTable.isInputSet(i, j, inputCount);
                Pin.FACTORY.setValue(pinState, value ? Value.TRUE : Value.FALSE);
            }

            Propagator prop = circuitState.getPropagator();
            prop.propagate();
            /* TODO for the SimulatorPrototype class
            do {
                prop.step();
            } while (prop.isPending()); */
            // TODO: Search for circuit state

            if (prop.isOscillating()) {
                for (int j = 0; j < columns.length; j++) {
                    columns[j][i] = Entry.OSCILLATE_ERROR;
                }
            } 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;
                    }
View Full Code Here

        boolean found = false;
        for (Component comp : circState.getCircuit().getNonWires()) {
            if (comp.getFactory() instanceof Ram) {
                Ram ramFactory = (Ram) comp.getFactory();
                InstanceState ramState = circState.getInstanceState(comp);
                ramFactory.loadImage(ramState, loadFile);
                found = true;
            }
        }
View Full Code Here

        boolean found = false;
        for (Component comp : circState.getCircuit().getNonWires()) {
            Object factory = comp.getFactory();
            if (factory instanceof Tty) {
                Tty ttyFactory = (Tty) factory;
                InstanceState ttyState = circState.getInstanceState(comp);
                ttyFactory.sendToStdout(ttyState);
                found = true;
            } else if (factory instanceof Keyboard) {
                keybStates.add(circState.getInstanceState(comp));
                found = true;
View Full Code Here

        ArrayList<Value> prevOutputs = null;
        Propagator prop = circState.getPropagator();
        while (true) {
            ArrayList<Value> curOutputs = new ArrayList<Value>();
            for (Instance pin : outputPins) {
                InstanceState pinState = circState.getInstanceState(pin);
                Value val = Pin.FACTORY.getValue(pinState);
                if (pin == haltPin) {
                    halted |= val.equals(Value.TRUE);
                } else if (showTable) {
                    curOutputs.add(val);
View Full Code Here

        CircuitAttributes attrs = (CircuitAttributes) superState.getAttributeSet();
        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);
                }
            // it is output-only
            } else {
                Value val = pinState.getPort(0);
                superState.setPort(i, val, 1);
            }
        }
    }
View Full Code Here

TOP

Related Classes of com.cburch.logisim.instance.InstanceState

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.