Package com.cburch.logisim.instance

Examples of com.cburch.logisim.instance.Port


        Port[] ps;
        if (parallelObj == null || parallelObj.booleanValue()) {
            Integer lenObj = instance.getAttributeValue(ATTR_LENGTH);
            int len = lenObj == null ? 8 : lenObj.intValue();
            ps = new Port[6 + 2 * len];
            ps[LD] = new Port(10, -20, Port.INPUT, 1);
            ps[LD].setToolTip(getFromLocale("shiftRegLoadTip"));
            for (int i = 0; i < len; i++) {
                ps[6 + 2 * i]     = new Port(20 + 10 * i, -20, Port.INPUT, width);
                ps[6 + 2 * i + 1] = new Port(20 + 10 * i,  20, Port.OUTPUT, width);
            }
        } else {
            ps = new Port[5];
        }
        ps[OUT] = new Port(bds.getWidth(), 0, Port.OUTPUT, width);
        ps[SH= new Port( 0, -10, Port.INPUT, 1);
        ps[IN= new Port( 0,   0, Port.INPUT, width);
        ps[CK= new Port( 010, Port.INPUT, 1);
        ps[CLR] = new Port(1020, Port.INPUT, 1);
        ps[OUT].setToolTip(getFromLocale("shiftRegOutTip"));
        ps[SH].setToolTip(getFromLocale("shiftRegShiftTip"));
        ps[IN].setToolTip(getFromLocale("shiftRegInTip"));
        ps[CK].setToolTip(getFromLocale("shiftRegClockTip"));
        ps[CLR].setToolTip(getFromLocale("shiftRegClearTip"));
View Full Code Here


    void computePorts(Instance instance) {
        GateAttributes attrs = (GateAttributes) instance.getAttributeSet();
        int inputs = attrs.inputs;

        Port[] ports = new Port[inputs + 1];
        ports[0] = new Port(0, 0, Port.OUTPUT, StdAttr.WIDTH);
        for (int i = 0; i < inputs; i++) {
            Location offs = getInputOffset(attrs, i);
            ports[i + 1] = new Port(offs.getX(), offs.getY(), Port.INPUT, StdAttr.WIDTH);
        }
        instance.setPorts(ports);
    }
View Full Code Here

        } else {
            loc2 = loc0.translate(facing.reverse(), 10 + d, -10);
        }

        Port[] ports = new Port[3];
        ports[0] = new Port(0, 0, Port.OUTPUT, StdAttr.WIDTH);
        ports[1] = new Port(loc1.getX(), loc1.getY(), Port.INPUT, StdAttr.WIDTH);
        ports[2] = new Port(loc2.getX(), loc2.getY(), Port.INPUT, 1);
        instance.setPorts(ports);
    }
View Full Code Here

         * the component's anchor location, then whether the port is an
         * input/output/both, and finally the expected bit width for the port.
         * The bit width can be a constant (like 1) or an attribute (as here).
         */
        setPorts(new Port[] {
                new Port(-30, 0, Port.INPUT, StdAttr.WIDTH),
                new Port(0, 0, Port.OUTPUT, StdAttr.WIDTH),
            });
    }
View Full Code Here

class GrayCounter extends InstanceFactory {
    public GrayCounter() {
        super("Gray Counter");
        setOffsetBounds(Bounds.create(-30, -15, 30, 30));
        setPorts(new Port[] {
                new Port(-30, 0, Port.INPUT, 1),
                new Port0, 0, Port.OUTPUT, StdAttr.WIDTH),
        });

        // We'll have width, label, and label font attributes. The latter two
        // attributes allow us to associate a label with the component (though
        // we'll also need configureNewInstance to configure the label's
View Full Code Here

    public SimpleGrayCounter() {
        super("Gray Counter (Simple)");
        setOffsetBounds(Bounds.create(-30, -15, 30, 30));
        setPorts(new Port[] {
                new Port(-30, 0, Port.INPUT, 1),
                new Port0, 0, Port.OUTPUT, BIT_WIDTH.getWidth()),
        });
    }
View Full Code Here

        instance.addAttributeListener();
        updatePorts(instance);
    }

    private void updatePorts(Instance instance) {
        Port[] ps = { new Port(0, 0, Port.OUTPUT, StdAttr.WIDTH) };
        instance.setPorts(ps);
    }
View Full Code Here

            } else {
                end0 = Location.create(30, -10);
                end1 = Location.create(3010);
                sel = Location.create(20,  selMult * 20);
            }
            ps[0] = new Port(end0.getX(), end0.getY(), Port.OUTPUT, data.getWidth());
            ps[1] = new Port(end1.getX(), end1.getY(), Port.OUTPUT, data.getWidth());
        } else {
            int dx = -(outputs / 2) * 10;
            int ddx = 10;
            int dy = dx;
            int ddy = 10;
            if (facing == Direction.WEST) {
                dx = -40; ddx = 0;
                sel = Location.create(-20, selMult * (dy + 10 * outputs));
            } else if (facing == Direction.NORTH) {
                dy = -40; ddy = 0;
                sel = Location.create(selMult * dx, -20);
            } else if (facing == Direction.SOUTH) {
                dy = 40; ddy = 0;
                sel = Location.create(selMult * dx, 20);
            } else {
                dx = 40; ddx = 0;
                sel = Location.create(20, selMult * (dy + 10 * outputs));
            }
            for (int i = 0; i < outputs; i++) {
                ps[i] = new Port(dx, dy, Port.OUTPUT, data.getWidth());
                dx += ddx;
                dy += ddy;
            }
        }
        Location en = sel.translate(facing, -10);
        ps[outputs] = new Port(sel.getX(), sel.getY(), Port.INPUT, select.getWidth());
        if (enable) {
            ps[outputs + 1] = new Port(en.getX(), en.getY(), Port.INPUT, BitWidth.ONE);
        }
        ps[ps.length - 1] = new Port(0, 0, Port.INPUT, data.getWidth());

        for (int i = 0; i < outputs; i++) {
            ps[i].setToolTip(getFromLocale("demultiplexerOutTip", "" + i));
        }
        ps[outputs].setToolTip(getFromLocale("demultiplexerSelectTip"));
View Full Code Here

        Port[] ps = new Port[n + 4];
        if (dir == Direction.NORTH || dir == Direction.SOUTH) {
            int x = -5 * n + 10;
            int y = dir == Direction.NORTH ? 40 : -40;
            for (int i = 0; i < n; i++) {
                ps[i] = new Port(x + 10 * i, y, Port.INPUT, 1);
            }
            ps[n + OUT] = new Port(0, 0, Port.OUTPUT, select.getWidth());
            ps[n + EN_IN] = new Port(x + 10 * n, y / 2, Port.INPUT, 1);
            ps[n + EN_OUT] = new Port(x - 10, y / 2, Port.OUTPUT, 1);
            ps[n + GS] = new Port(10, 0, Port.OUTPUT, 1);
        } else {
            int x = dir == Direction.EAST ? -40 : 40;
            int y = -5 * n + 10;
            for (int i = 0; i < n; i++) {
                ps[i] = new Port(x, y + 10 * i, Port.INPUT, 1);
            }
            ps[n + OUT] = new Port(0, 0, Port.OUTPUT, select.getWidth());
            ps[n + EN_IN] = new Port(x / 2, y + 10 * n, Port.INPUT, 1);
            ps[n + EN_OUT] = new Port(x / 2, y - 10, Port.OUTPUT, 1);
            ps[n + GS] = new Port(0, 10, Port.OUTPUT, 1);
        }

        for (int i = 0; i < n; i++) {
            ps[i].setToolTip(getFromLocale("priorityEncoderInTip", "" + i));
        }
View Full Code Here

    //
    // methods for instances
    //
    @Override
    protected void configureNewInstance(Instance instance) {
        instance.setPorts(new Port[] { new Port(0, 0, Port.INPUT, BitWidth.UNKNOWN) });
        instance.addAttributeListener();
        configureLabel(instance);
    }
View Full Code Here

TOP

Related Classes of com.cburch.logisim.instance.Port

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.