use of com.cburch.logisim.data.BitWidth in project logisim-evolution by reds-heig.
the class RegisterLogger method getLogValue.
@Override
public Value getLogValue(InstanceState state, Object option) {
BitWidth dataWidth = state.getAttributeValue(StdAttr.WIDTH);
if (dataWidth == null)
dataWidth = BitWidth.create(0);
RegisterData data = (RegisterData) state.getData();
if (data == null)
return Value.createKnown(dataWidth, 0);
return data.value;
}
use of com.cburch.logisim.data.BitWidth in project logisim-evolution by reds-heig.
the class RegisterPoker method keyTyped.
@Override
public void keyTyped(InstanceState state, KeyEvent e) {
int val = Character.digit(e.getKeyChar(), 16);
if (val < 0)
return;
BitWidth dataWidth = state.getAttributeValue(StdAttr.WIDTH);
if (dataWidth == null)
dataWidth = BitWidth.create(8);
curValue = (curValue * 16 + val) & dataWidth.getMask();
RegisterData data = (RegisterData) state.getData();
data.value = Value.createKnown(dataWidth, curValue);
state.fireInvalidated();
}
use of com.cburch.logisim.data.BitWidth in project logisim-evolution by reds-heig.
the class RomAttributes method setValue.
@Override
public <V> void setValue(Attribute<V> attr, V value) {
if (attr == Mem.ADDR_ATTR) {
BitWidth newAddr = (BitWidth) value;
if (newAddr == addrBits)
return;
addrBits = newAddr;
contents.setDimensions(addrBits.getWidth(), dataBits.getWidth(), true);
fireAttributeValueChanged(attr, value, null);
} else if (attr == Mem.DATA_ATTR) {
BitWidth newData = (BitWidth) value;
if (newData == dataBits)
return;
dataBits = newData;
contents.setDimensions(addrBits.getWidth(), dataBits.getWidth(), true);
fireAttributeValueChanged(attr, value, null);
} else if (attr == Rom.CONTENTS_ATTR) {
MemContents newContents = (MemContents) value;
if (contents.equals(newContents))
return;
contents = newContents;
fireAttributeValueChanged(attr, value, null);
} else if (attr == StdAttr.LABEL) {
String NewLabel = (String) value;
if (Label.equals(NewLabel))
return;
@SuppressWarnings("unchecked") V Oldlabel = (V) Label;
Label = NewLabel;
fireAttributeValueChanged(attr, value, Oldlabel);
} else if (attr == StdAttr.LABEL_FONT) {
Font NewFont = (Font) value;
if (LabelFont.equals(NewFont))
return;
LabelFont = NewFont;
fireAttributeValueChanged(attr, value, null);
} else if (attr == StdAttr.LABEL_VISIBILITY) {
Boolean newVis = (Boolean) value;
if (LabelVisable.equals(newVis))
return;
LabelVisable = newVis;
fireAttributeValueChanged(attr, value, null);
}
}
use of com.cburch.logisim.data.BitWidth in project logisim-evolution by reds-heig.
the class Random method paintInstance.
@Override
public void paintInstance(InstancePainter painter) {
Bounds bds = painter.getBounds();
int x = bds.getX();
int y = bds.getY();
StateData state = (StateData) painter.getData();
int val = state == null ? 0 : state.value;
BitWidth widthVal = painter.getAttributeValue(StdAttr.WIDTH);
int width = widthVal == null ? 8 : widthVal.getWidth();
painter.drawLabel();
DrawControl(painter, x, y, width);
DrawData(painter, x, y + 70, width, val);
}
use of com.cburch.logisim.data.BitWidth in project logisim-evolution by reds-heig.
the class Pin method paintGhost.
@Override
public void paintGhost(InstancePainter painter) {
PinAttributes attrs = (PinAttributes) painter.getAttributeSet();
Location loc = painter.getLocation();
Bounds bds = painter.getOffsetBounds();
int x = loc.getX();
int y = loc.getY();
Graphics g = painter.getGraphics();
GraphicsUtil.switchToWidth(g, 2);
boolean output = attrs.isOutput();
if (output) {
BitWidth width = attrs.getValue(StdAttr.WIDTH);
if (width == BitWidth.ONE) {
g.drawOval(x + bds.getX() + 1, y + bds.getY() + 1, bds.getWidth() - 1, bds.getHeight() - 1);
} else {
g.drawRoundRect(x + bds.getX() + 1, y + bds.getY() + 1, bds.getWidth() - 1, bds.getHeight() - 1, 6, 6);
}
} else {
g.drawRect(x + bds.getX() + 1, y + bds.getY() + 1, bds.getWidth() - 1, bds.getHeight() - 1);
}
}
Aggregations