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