* @param bitA The bit of {@link Wire} a to be fused
* @param bitB The bit of {@link Wire} b to be fused
*/
- private static void fuse(Wire a, Wire b, int bitA, int bitB)
+ public static void fuse(Wire a, Wire b, int bitA, int bitB)
{
if (bitA >= a.width)
throw new IllegalArgumentException("No bit " + bitA + " in " + a + " (width " + a.width + ")");
gc.setForeground(ColorManager.current().toColor(c));
double outLineY = posY + (logicWidth - 1) * heightPerPin / 2;
gc.drawLine(posX + width / 2, outLineY, posX + width, outLineY);
- double inputHeight = posY + (logicWidth - 1) * heightPerPin;
- for (int i = 0; i < logicWidth; i++, inputHeight -= 10)
+ double inputHeight = posY;
+ for (int i = 0; i < logicWidth; i++, inputHeight += 10)
{
c = BitVectorFormatter.formatAsColor(inputEnds[i]);
if (c != null)
gc.setForeground(ColorManager.current().toColor(c));
double inLineY = posY + (logicWidth - 1) * heightPerPin / 2;
gc.drawLine(posX, inLineY, posX + width / 2, inLineY);
- double outputHeight = posY + (logicWidth - 1) * heightPerPin;
- for (int i = 0; i < logicWidth; i++, outputHeight -= 10)
+ double outputHeight = posY;
+ for (int i = 0; i < logicWidth; i++, outputHeight += 10)
{
c = BitVectorFormatter.formatAsColor(outputEnds[i]);
if (c != null)
*/
public class Pin
{
- // TODO introduce input/output/tristate hints
/**
* The {@link GUIComponent} this pin belongs to.
*/
ReadEnd[] inputEnds = new ReadEnd[guiComponent.logicWidth];
for (int i = 0; i < guiComponent.logicWidth; i++)
{
- Wire input = logicWiresPerPin.get(guiComponent.getPin("I" + i));
- Wire.fuse(input, output, 0, guiComponent.logicWidth - 1 - i, 1);
+ Wire input = logicWiresPerPin.get(guiComponent.getPin("I" + (guiComponent.logicWidth - 1 - i)));
+ Wire.fuse(input, output, 0, i);
inputEnds[i] = input.createReadOnlyEnd();
}
guiComponent.setLogicModelBinding(inputEnds, output.createReadOnlyEnd());
ReadEnd[] outputEnds = new ReadEnd[guiComponent.logicWidth];
for (int i = 0; i < guiComponent.logicWidth; i++)
{
- Wire output = logicWiresPerPin.get(guiComponent.getPin("O" + i));
- Wire.fuse(input, output, guiComponent.logicWidth - 1 - i, 0, 1);
+ Wire output = logicWiresPerPin.get(guiComponent.getPin("O" + (guiComponent.logicWidth - 1 - i)));
+ Wire.fuse(input, output, i, 0);
outputEnds[i] = output.createReadOnlyEnd();
}
guiComponent.setLogicModelBinding(input.createReadOnlyEnd(), outputEnds);