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);
}
}
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");
}
}
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;
}
Aggregations