Search in sources :

Example 76 with BitWidth

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

the class bin2bcd method paintInstance.

public void paintInstance(InstancePainter painter) {
    Graphics g = painter.getGraphics();
    BitWidth nrofbits = painter.getAttributeValue(bin2bcd.ATTR_BinBits);
    int NrOfPorts = (int) (Math.log10(Math.pow(2.0, nrofbits.getWidth())) + 1.0);
    g.setColor(Color.GRAY);
    painter.drawBounds();
    painter.drawPort(BINin, "Bin", Direction.EAST);
    for (int i = NrOfPorts; i > 0; i--) painter.drawPort((NrOfPorts - i) + 1, Integer.toString((int) Math.pow(10.0, NrOfPorts - i)), Direction.NORTH);
}
Also used : Graphics(java.awt.Graphics) BitWidth(com.cburch.logisim.data.BitWidth)

Example 77 with BitWidth

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

the class bin2bcdHDLGeneratorFactory method GetWireList.

@Override
public SortedMap<String, Integer> GetWireList(AttributeSet attrs, Netlist Nets) {
    SortedMap<String, Integer> Wires = new TreeMap<String, Integer>();
    BitWidth nrofbits = attrs.getValue(bin2bcd.ATTR_BinBits);
    int NrOfPorts = (int) (Math.log10(1 << nrofbits.getWidth()) + 1.0);
    switch(NrOfPorts) {
        case 2:
            Wires.put("s_level_0", 7);
            Wires.put("s_level_1", 7);
            Wires.put("s_level_2", 7);
            Wires.put("s_level_3", 7);
            break;
        case 3:
            Wires.put("s_level_0", 11);
            Wires.put("s_level_1", 11);
            Wires.put("s_level_2", 11);
            Wires.put("s_level_3", 11);
            Wires.put("s_level_4", 11);
            Wires.put("s_level_5", 11);
            Wires.put("s_level_6", 11);
            break;
        case 4:
            Wires.put("s_level_0", 16);
            Wires.put("s_level_1", 16);
            Wires.put("s_level_2", 16);
            Wires.put("s_level_3", 16);
            Wires.put("s_level_4", 16);
            Wires.put("s_level_5", 16);
            Wires.put("s_level_6", 16);
            Wires.put("s_level_7", 16);
            Wires.put("s_level_8", 16);
            Wires.put("s_level_9", 16);
            Wires.put("s_level_10", 16);
            break;
    }
    return Wires;
}
Also used : BitWidth(com.cburch.logisim.data.BitWidth) TreeMap(java.util.TreeMap)

Example 78 with BitWidth

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

the class bin2bcdHDLGeneratorFactory method GetOutputList.

@Override
public SortedMap<String, Integer> GetOutputList(Netlist TheNetlist, AttributeSet attrs) {
    SortedMap<String, Integer> Outputs = new TreeMap<String, Integer>();
    BitWidth nrofbits = attrs.getValue(bin2bcd.ATTR_BinBits);
    int NrOfPorts = (int) (Math.log10(1 << nrofbits.getWidth()) + 1.0);
    for (int i = 1; i <= NrOfPorts; i++) {
        Outputs.put("BCD" + Integer.toString((int) (Math.pow(10, i - 1))), 4);
    }
    return Outputs;
}
Also used : BitWidth(com.cburch.logisim.data.BitWidth) TreeMap(java.util.TreeMap)

Example 79 with BitWidth

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

the class Counter method paintInstance.

@Override
public void paintInstance(InstancePainter painter) {
    int Xpos = painter.getLocation().getX();
    int Ypos = painter.getLocation().getY();
    painter.drawLabel();
    DrawControl(painter, Xpos, Ypos);
    BitWidth widthVal = painter.getAttributeValue(StdAttr.WIDTH);
    int width = widthVal == null ? 8 : widthVal.getWidth();
    for (int bit = 0; bit < width; bit++) {
        DrawDataBlock(painter, Xpos, Ypos + 110, bit, width);
    }
}
Also used : BitWidth(com.cburch.logisim.data.BitWidth)

Example 80 with BitWidth

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

the class Counter method configurePorts.

private void configurePorts(Instance instance) {
    Bounds bds = instance.getBounds();
    BitWidth widthVal = instance.getAttributeValue(StdAttr.WIDTH);
    int width = widthVal == null ? 8 : widthVal.getWidth();
    Port[] ps = new Port[8];
    if (width == 1) {
        ps[OUT] = new Port(SymbolWidth(width) + 40, 120, Port.OUTPUT, StdAttr.WIDTH);
        ps[IN] = new Port(0, 120, Port.INPUT, StdAttr.WIDTH);
    } else {
        ps[OUT] = new Port(SymbolWidth(width) + 40, 110, Port.OUTPUT, StdAttr.WIDTH);
        ps[IN] = new Port(0, 110, Port.INPUT, StdAttr.WIDTH);
    }
    ps[CK] = new Port(0, 80, Port.INPUT, 1);
    ps[CLR] = new Port(0, 20, Port.INPUT, 1);
    ps[LD] = new Port(0, 30, Port.INPUT, 1);
    ps[UD] = new Port(0, 50, Port.INPUT, 1);
    ps[EN] = new Port(0, 70, Port.INPUT, 1);
    ps[CARRY] = new Port(40 + SymbolWidth(width), 50, Port.OUTPUT, 1);
    ps[OUT].setToolTip(Strings.getter("counterQTip"));
    ps[IN].setToolTip(Strings.getter("counterDataTip"));
    ps[CK].setToolTip(Strings.getter("counterClockTip"));
    ps[CLR].setToolTip(Strings.getter("counterResetTip"));
    ps[LD].setToolTip(Strings.getter("counterLoadTip"));
    ps[UD].setToolTip(Strings.getter("counterUpDownTip"));
    ps[EN].setToolTip(Strings.getter("counterEnableTip"));
    ps[CARRY].setToolTip(Strings.getter("counterCarryTip"));
    instance.setPorts(ps);
    instance.setTextField(StdAttr.LABEL, StdAttr.LABEL_FONT, bds.getX() + bds.getWidth() / 2, bds.getY() - 3, GraphicsUtil.H_CENTER, GraphicsUtil.V_BASELINE);
}
Also used : BitWidth(com.cburch.logisim.data.BitWidth) Bounds(com.cburch.logisim.data.Bounds) Port(com.cburch.logisim.instance.Port)

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