Package com.cburch.logisim.data

Examples of com.cburch.logisim.data.BitWidth


    }

    @Override
    public void propagate(InstanceState state) {
        // get attributes
        BitWidth dataWidth = state.getAttributeValue(StdAttr.WIDTH);

        // compute outputs
        Value a = state.getPort(IN0);
        Value b = state.getPort(IN1);
        Value c_in = state.getPort(C_IN);
        Value[] outs = Adder.computeSum(dataWidth, a, b, c_in);

        // propagate them
        int delay = (dataWidth.getWidth() + 2) * PER_DELAY;
        state.setPort(OUT,   outs[0], delay);
        state.setPort(C_OUT, outs[1], delay);
    }
View Full Code Here


        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.getPort(CK), triggerType);

        if (state.getPort(RST) == Value.TRUE) {
            data.reset(state.getAttributeValue(ATTR_SEED));
View Full Code Here

    @Override
    public void paintInstance(InstancePainter painter) {
        Graphics g = painter.getGraphics();
        Bounds bds = painter.getBounds();
        StateData state = (StateData) painter.getData();
        BitWidth widthVal = painter.getAttributeValue(StdAttr.WIDTH);
        int width = widthVal == null ? 8 : widthVal.getWidth();

        // draw boundary, label
        painter.drawBounds();
        painter.drawLabel();
View Full Code Here

    }

    @Override
    public void propagate(InstanceState state) {
        // get attributes
        BitWidth dataWidth = state.getAttributeValue(StdAttr.WIDTH);

        // compute outputs
        Value a = state.getPort(IN0);
        Value b = state.getPort(IN1);
        Value upper = state.getPort(UPPER);
        Value[] outs = Divider.computeResult(dataWidth, a, b, upper);

        // propagate them
        int delay = dataWidth.getWidth() * (dataWidth.getWidth() + 2) * PER_DELAY;
        state.setPort(OUT, outs[0], delay);
        state.setPort(REM, outs[1], delay);
    }
View Full Code Here

            return ret != null && !ret.equals("") ? ret : null;
        }

        @Override
        public Value getLogValue(InstanceState state, Object option) {
            BitWidth dataWidth = state.getAttributeValue(StdAttr.WIDTH);
            if (dataWidth == null) {
                dataWidth = BitWidth.create(0);
            }

            StateData data = (StateData) state.getData();
View Full Code Here

            instance.fireInvalidated();
        }
    }

    private void configurePorts(Instance instance) {
        BitWidth inWidth = instance.getAttributeValue(StdAttr.WIDTH);
        int outWidth = computeOutputBits(inWidth.getWidth() - 1);

        Port[] ps = new Port[3];
        ps[0] = new Port(-2020, Port.OUTPUT, BitWidth.ONE);
        ps[1] = new Port0,   0, Port.OUTPUT, BitWidth.create(outWidth));
        ps[2] = new Port(-40,   0, Port.INPUT,  inWidth);
View Full Code Here

            instance.recomputeBounds();
        }
    }

    private void configurePorts(Instance instance) {
        BitWidth inWidth = instance.getAttributeValue(StdAttr.WIDTH);
        int inputs = instance.getAttributeValue(NUM_INPUTS).intValue();
        int outWidth = computeOutputBits(inWidth.getWidth(), inputs);

        int y;
        int dy = 10;
        switch (inputs) {
        case 1: y = 0; break;
View Full Code Here

        if (data == null) {
            data = new RegisterData();
            state.setData(data);
        }

        BitWidth dataWidth = state.getAttributeValue(StdAttr.WIDTH);
        Object triggerType = state.getAttributeValue(StdAttr.EDGE_TRIGGER);
        int max = state.getAttributeValue(ATTR_MAX).intValue();
        Value clock = state.getPort(CK);
        boolean triggered = data.updateClock(clock, triggerType);
View Full Code Here

    @Override
    public void paintInstance(InstancePainter painter) {
        Graphics g = painter.getGraphics();
        Bounds bds = painter.getBounds();
        RegisterData state = (RegisterData) painter.getData();
        BitWidth widthVal = painter.getAttributeValue(StdAttr.WIDTH);
        int width = widthVal == null ? 8 : widthVal.getWidth();

        // determine text to draw in label
        String a;
        String b = null;
        if (painter.getShowState()) {
            int val = state == null ? 0 : state.value;
            String str = StringUtil.toHexString(width, val);
            if (str.length() <= 4) {
                a = str;
            } else {
                int split = str.length() - 4;
                a = str.substring(0, split);
                b = str.substring(split);
            }
        } else {
            a = getFromLocale("counterLabel");
            b = getFromLocale("registerWidthLabel", "" + widthVal.getWidth());
        }

        // draw boundary, label
        painter.drawBounds();
        painter.drawLabel();
View Full Code Here

            configurePorts(instance);
        }
    }

    private void configurePorts(Instance instance) {
        BitWidth dataWid = instance.getAttributeValue(StdAttr.WIDTH);
        int data = dataWid == null ? 32 : dataWid.getWidth();
        int shift = 1;
        while ((1 << shift) < data) shift++;

        Port[] ps = new Port[3];
        ps[IN0]   = new Port(-40, -10, Port.INPUT,  data);
View Full Code Here

TOP

Related Classes of com.cburch.logisim.data.BitWidth

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.