Search in sources :

Example 11 with InstanceState

use of com.cburch.logisim.instance.InstanceState in project logisim-evolution by reds-heig.

the class DipSwitch method propagate.

@Override
public void propagate(InstanceState state) {
    State pins = (State) state.getData();
    if (pins == null || pins.size != state.getAttributeValue(ATTR_SIZE)) {
        int val = (pins == null) ? 0 : pins.Value;
        pins = new State(val, state.getAttributeValue(ATTR_SIZE));
        state.setData(pins);
    }
    for (int i = 0; i < pins.size; i++) {
        Value pinstate = (pins.BitSet(i)) ? Value.TRUE : Value.FALSE;
        state.setPort(i, pinstate, 1);
    }
}
Also used : InstanceState(com.cburch.logisim.instance.InstanceState) Value(com.cburch.logisim.data.Value)

Example 12 with InstanceState

use of com.cburch.logisim.instance.InstanceState in project logisim-evolution by reds-heig.

the class DotMatrix method propagate.

@Override
public void propagate(InstanceState state) {
    Object type = state.getAttributeValue(ATTR_INPUT_TYPE);
    int rows = state.getAttributeValue(ATTR_MATRIX_ROWS).intValue();
    int cols = state.getAttributeValue(ATTR_MATRIX_COLS).intValue();
    long clock = state.getTickCount();
    long persist = clock + state.getAttributeValue(ATTR_PERSIST).intValue();
    State data = getState(state);
    if (type == INPUT_ROW) {
        for (int i = 0; i < rows; i++) {
            data.setRow(i, state.getPortValue(i), persist);
        }
    } else if (type == INPUT_COLUMN) {
        for (int i = 0; i < cols; i++) {
            data.setColumn(i, state.getPortValue(i), persist);
        }
    } else if (type == INPUT_SELECT) {
        data.setSelect(state.getPortValue(1), state.getPortValue(0), persist);
    } else {
        throw new RuntimeException("unexpected matrix type");
    }
}
Also used : InstanceState(com.cburch.logisim.instance.InstanceState)

Example 13 with InstanceState

use of com.cburch.logisim.instance.InstanceState in project logisim-evolution by reds-heig.

the class DotMatrix method getState.

private State getState(InstanceState state) {
    int rows = state.getAttributeValue(ATTR_MATRIX_ROWS).intValue();
    int cols = state.getAttributeValue(ATTR_MATRIX_COLS).intValue();
    long clock = state.getTickCount();
    State data = (State) state.getData();
    if (data == null) {
        data = new State(rows, cols, clock);
        state.setData(data);
    } else {
        data.updateSize(rows, cols, clock);
    }
    return data;
}
Also used : InstanceState(com.cburch.logisim.instance.InstanceState)

Aggregations

InstanceState (com.cburch.logisim.instance.InstanceState)13 Component (com.cburch.logisim.comp.Component)5 Value (com.cburch.logisim.data.Value)5 Instance (com.cburch.logisim.instance.Instance)4 CircuitState (com.cburch.logisim.circuit.CircuitState)3 TestException (com.cburch.logisim.data.TestException)2 FileNotFoundException (java.io.FileNotFoundException)2 IOException (java.io.IOException)2 PrintWriter (java.io.PrintWriter)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2 ArrayList (java.util.ArrayList)2 Date (java.util.Date)2 Entry (com.cburch.logisim.analyze.model.Entry)1 Propagator (com.cburch.logisim.circuit.Propagator)1 BitWidth (com.cburch.logisim.data.BitWidth)1 FailException (com.cburch.logisim.data.FailException)1 Port (com.cburch.logisim.instance.Port)1 Keyboard (com.cburch.logisim.std.io.Keyboard)1 Tty (com.cburch.logisim.std.io.Tty)1 Ram (com.cburch.logisim.std.memory.Ram)1