Package ptolemy.math

Examples of ptolemy.math.FixPoint


                Rounding rounding = Rounding
                        .getName(((Parameter) getAttribute("outputRounding"))
                                .getExpression().toLowerCase());

                FixPoint result = new FixPoint(((ScalarToken) valuesArray
                        .getElement(_currentIndex)).doubleValue(),
                        new FixPointQuantization(precision, overflow, rounding));
                sendOutput(output, 0, new FixToken(result));
                _outputProduced = true;
            }
View Full Code Here


            BigInteger intResult = null;
            Precision precision = new Precision(
                    ((Parameter) getAttribute("outputPrecision"))
                            .getExpression());
            if (A.hasToken(0) && B.hasToken(0)) {
                FixPoint valueA = ((FixToken) A.get(0)).fixValue();
                FixPoint valueB = ((FixToken) B.get(0)).fixValue();
                if (valueA.getPrecision().getNumberOfBits() != precision
                        .getNumberOfBits()) {
                    throw new IllegalActionException(this,
                            "Input A has different width than the output port");
                }
                if (valueB.getPrecision().getNumberOfBits() != precision
                        .getNumberOfBits()) {
                    throw new IllegalActionException(this,
                            "Input B has different width than the output port");
                }
                BigInteger bigIntA = valueA.getUnscaledValue();
                BigInteger bigIntB = valueB.getUnscaledValue();
                if (operation.getExpression().equals("AND")) {
                    intResult = bigIntA.and(bigIntB);
                } else if (operation.getExpression().equals("OR")) {
                    intResult = bigIntA.or(bigIntB);
                } else if (operation.getExpression().equals("NAND")) {
                    intResult = bigIntA.and(bigIntB).not();
                } else if (operation.getExpression().equals("NOR")) {
                    intResult = bigIntA.or(bigIntB).not();
                } else if (operation.getExpression().equals("XOR")) {
                    intResult = bigIntA.xor(bigIntB);
                } else if (operation.getExpression().equals("XNOR")) {
                    intResult = bigIntA.xor(bigIntB).not();
                }
            }

            if (intResult != null) {
                Overflow overflow = Overflow
                        .getName(((Parameter) getAttribute("outputOverflow"))
                                .getExpression().toLowerCase());

                Rounding rounding = Rounding
                        .getName(((Parameter) getAttribute("outputRounding"))
                                .getExpression().toLowerCase());
                FixPoint result = new FixPoint(intResult.doubleValue(),
                        new FixPointQuantization(precision, overflow, rounding));
                sendOutput(output, 0, new FixToken(result));
            }
        } else {
            output.resend(0);
View Full Code Here

            // Consume tokens from all input ports.
            FixToken in = ((FixToken) dataIn.get(0));

            FixToken addressToken = (FixToken) address.get(0);
            FixPoint addressFixValue = addressToken.fixValue();

            FixToken writeEnableToken = (FixToken) writeEnable.get(0);
            FixPoint writeEnableValue = writeEnableToken.fixValue();

            _checkFixTokenWidth(writeEnableToken, 1);
            _checkFixTokenWidth(addressToken, _addressWidth);
            _checkFixTokenWidth(in, _dataWidth);

            addressValue = addressFixValue.getUnscaledValue().intValue();

            if (addressValue >= _capacity) {
                throw new IllegalActionException(this,
                        "Address is out of range.");
            }

            if (writeEnableValue.toBitString().equals("1")) {
                _storage[addressValue] = in;
            }

            Token result = _storage[addressValue];
            if (result == null) {
View Full Code Here

     @param integerBits The number of bits used for the integer part.
     *  @return a double with value that is quantized.
     */
    public static double quantize(double value, int numberOfBits,
            int integerBits) {
        FixPoint fixValue = Quantizer.round(value, new Precision(numberOfBits,
                integerBits));
        return fixValue.doubleValue();
    }
View Full Code Here

                    _currentCount = 0;
                }
            }

            // Produce an output if we consumed an input.
            FixPoint result = new FixPoint(_currentCount);
            Token outputToken = new FixToken(result);
            sendOutput(output, 0, outputToken);

        } else {
View Full Code Here

        super.fire();
        BigInteger intResult = null;
        int bitsInResult = 0;

        if (A.isKnown() && A.hasToken(0)) {
            FixPoint valueA = ((FixToken) A.get(0)).fixValue();
            bitsInResult = valueA.getPrecision().getNumberOfBits();
            BigInteger bigIntA = valueA.getUnscaledValue();
            intResult = bigIntA.not();
            Precision precision = new Precision(1, bitsInResult, 0);
            FixToken result = new FixToken(intResult.doubleValue(), precision);
            sendOutput(output, 0, result);
        } else {
View Full Code Here

        Rounding rounding = Rounding
                .getName(((Parameter) getAttribute("outputRounding"))
                        .getExpression().toLowerCase());

        FixPoint result = new FixPoint(((ScalarToken) value.getToken())
                .doubleValue(), new FixPointQuantization(precision, overflow,
                rounding));

        sendOutput(output, 0, new FixToken(result));
    }
View Full Code Here

     * @exception IllegalActionException If there is no director.
     */
    public void fire() throws IllegalActionException {
        super.fire();
        FixToken in = (FixToken) input.get(0);
        FixPoint value = in.fixValue();
        output.send(0, new DoubleToken(value.doubleValue()));
    }
View Full Code Here

     @exception IllegalActionException If there is no director.
     */
    public void fire() throws IllegalActionException {
        super.fire();
        DoubleToken in = (DoubleToken) input.get(0);
        FixPoint fixValue = new FixPoint(in.doubleValue(), _quantization);
        FixToken result = new FixToken(fixValue);
        output.send(0, result);
    }
View Full Code Here

     @exception IllegalActionException If there is no director.
     */
    public void fire() throws IllegalActionException {
        super.fire();
        FixToken in = (FixToken) input.get(0);
        FixPoint fixValue = in.fixValue().quantize(_quantization);
        FixToken result = new FixToken(fixValue);
        output.send(0, result);
    }
View Full Code Here

TOP

Related Classes of ptolemy.math.FixPoint

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.