Search in sources :

Example 91 with BitWidth

use of com.cburch.logisim.data.BitWidth in project logisim-evolution by reds-heig.

the class Decoder method paintGhost.

@Override
public void paintGhost(InstancePainter painter) {
    Direction facing = painter.getAttributeValue(StdAttr.FACING);
    BitWidth select = painter.getAttributeValue(Plexers.ATTR_SELECT);
    Bounds bds = painter.getBounds();
    if (select.getWidth() == 1) {
        if (facing == Direction.EAST || facing == Direction.WEST) {
            Plexers.drawTrapezoid(painter.getGraphics(), Bounds.create(bds.getX(), bds.getY() + 5, bds.getWidth(), bds.getHeight() - 10), facing.reverse(), 10);
        } else {
            Plexers.drawTrapezoid(painter.getGraphics(), Bounds.create(bds.getX() + 5, bds.getY(), bds.getWidth() - 10, bds.getHeight()), facing.reverse(), 10);
        }
    } else {
        Plexers.drawTrapezoid(painter.getGraphics(), bds, facing.reverse(), 20);
    }
}
Also used : BitWidth(com.cburch.logisim.data.BitWidth) Bounds(com.cburch.logisim.data.Bounds) Direction(com.cburch.logisim.data.Direction)

Example 92 with BitWidth

use of com.cburch.logisim.data.BitWidth in project logisim-evolution by reds-heig.

the class RamAttributes method setValue.

@Override
public <V> void setValue(Attribute<V> attr, V value) {
    if (attr == Mem.ADDR_ATTR) {
        BitWidth newAddr = (BitWidth) value;
        if (addrBits == newAddr) {
            return;
        }
        addrBits = newAddr;
        contents.setDimensions(addrBits.getWidth(), dataBits.getWidth(), false);
        fireAttributeValueChanged(attr, value, null);
    } else if (attr == Mem.DATA_ATTR) {
        BitWidth newData = (BitWidth) value;
        if (dataBits == newData) {
            return;
        }
        dataBits = newData;
        contents.setDimensions(addrBits.getWidth(), dataBits.getWidth(), false);
        fireAttributeValueChanged(attr, value, null);
    } else if (attr == Ram.CONTENTS_ATTR) {
        MemContents newContents = (MemContents) value;
        if (contents.equals(newContents)) {
            return;
        }
        if ((newContents.getLogLength() != addrBits.getWidth()) || (newContents.getValueWidth() != dataBits.getWidth())) {
            newContents.setDimensions(addrBits.getWidth(), dataBits.getWidth(), false);
        }
        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.TRIGGER) {
        AttributeOption newTrigger = (AttributeOption) value;
        if (Trigger.equals(newTrigger)) {
            return;
        }
        Trigger = newTrigger;
        fireAttributeValueChanged(attr, value, null);
    } else if (attr == ATTR_DBUS) {
        AttributeOption NewStyle = (AttributeOption) value;
        if (BusStyle.equals(NewStyle)) {
            return;
        }
        BusStyle = NewStyle;
        fireAttributeValueChanged(attr, value, null);
    } 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);
    } else if (attr == ATTR_ByteEnables) {
        AttributeOption NewBE = (AttributeOption) value;
        if (ByteEnables.equals(NewBE)) {
            return;
        }
        if (dataBits.getWidth() < 9) {
            NewBE = BUS_WITHOUT_BYTEENABLES;
        }
        ByteEnables = NewBE;
        fireAttributeValueChanged(attr, value, null);
    }
}
Also used : BitWidth(com.cburch.logisim.data.BitWidth) Font(java.awt.Font) AttributeOption(com.cburch.logisim.data.AttributeOption)

Example 93 with BitWidth

use of com.cburch.logisim.data.BitWidth in project logisim-evolution by reds-heig.

the class RamState method attributeValueChanged.

@Override
public void attributeValueChanged(AttributeEvent e) {
    AttributeSet attrs = e.getSource();
    BitWidth addrBits = attrs.getValue(Mem.ADDR_ATTR);
    BitWidth dataBits = attrs.getValue(Mem.DATA_ATTR);
    getContents().setDimensions(addrBits.getWidth(), dataBits.getWidth(), false);
}
Also used : BitWidth(com.cburch.logisim.data.BitWidth) AttributeSet(com.cburch.logisim.data.AttributeSet)

Example 94 with BitWidth

use of com.cburch.logisim.data.BitWidth in project logisim-evolution by reds-heig.

the class Random method propagate.

@Override
public void propagate(InstanceState state) {
    StateData data = (StateData) state.getData();
    if (data == null) {
        data = new StateData(state.getAttributeValue(ATTR_SEED));
        state.setData(data);
    }
    BitWidth dataWidth = state.getAttributeValue(StdAttr.WIDTH);
    Object triggerType = state.getAttributeValue(StdAttr.EDGE_TRIGGER);
    boolean triggered = data.updateClock(state.getPortValue(CK), triggerType);
    if (state.getPortValue(RST) == Value.TRUE) {
        data.reset(state.getAttributeValue(ATTR_SEED));
    } else if (triggered && state.getPortValue(NXT) != Value.FALSE) {
        data.step();
    }
    state.setPort(OUT, Value.createKnown(dataWidth, data.value), 4);
}
Also used : BitWidth(com.cburch.logisim.data.BitWidth)

Example 95 with BitWidth

use of com.cburch.logisim.data.BitWidth in project logisim-evolution by reds-heig.

the class Demultiplexer method getOffsetBounds.

@Override
public Bounds getOffsetBounds(AttributeSet attrs) {
    Direction facing = attrs.getValue(StdAttr.FACING);
    BitWidth select = attrs.getValue(Plexers.ATTR_SELECT);
    int outputs = 1 << select.getWidth();
    Bounds bds;
    if (outputs == 2) {
        bds = Bounds.create(0, -25, 30, 50);
    } else {
        bds = Bounds.create(0, -(outputs / 2) * 10 - 10, 40, outputs * 10 + 20);
    }
    return bds.rotate(Direction.EAST, facing, 0, 0);
}
Also used : BitWidth(com.cburch.logisim.data.BitWidth) Bounds(com.cburch.logisim.data.Bounds) Direction(com.cburch.logisim.data.Direction)

Aggregations

BitWidth (com.cburch.logisim.data.BitWidth)106 Value (com.cburch.logisim.data.Value)30 Bounds (com.cburch.logisim.data.Bounds)21 Direction (com.cburch.logisim.data.Direction)20 Location (com.cburch.logisim.data.Location)16 Graphics (java.awt.Graphics)15 Port (com.cburch.logisim.instance.Port)12 EndData (com.cburch.logisim.comp.EndData)3 AttributeSet (com.cburch.logisim.data.AttributeSet)3 Font (java.awt.Font)3 FontMetrics (java.awt.FontMetrics)3 AttributeOption (com.cburch.logisim.data.AttributeOption)2 Graphics2D (java.awt.Graphics2D)2 ArrayList (java.util.ArrayList)2 TreeMap (java.util.TreeMap)2 WidthIncompatibilityData (com.cburch.logisim.circuit.WidthIncompatibilityData)1 Attribute (com.cburch.logisim.data.Attribute)1 Instance (com.cburch.logisim.instance.Instance)1 InstanceState (com.cburch.logisim.instance.InstanceState)1 Dimension (java.awt.Dimension)1