Package ptolemy.math

Examples of ptolemy.math.FixPoint$Error


     *  the type of the argument is an FixToken.
     *  @param rightArgument The token to multiply this token by.
     *  @return A new FixToken containing the result.
     */
    protected ScalarToken _multiply(ScalarToken rightArgument) {
        FixPoint result = _value
                .multiply(((FixToken) rightArgument).fixValue());
        return new FixToken(result);
    }
View Full Code Here


     *  with a quantization specification.
     *  @param quant The quantization specification.
     *  @return A new FixToken containing the result.
     */
    protected FixToken _quantize(Quantization quant) {
        FixPoint result = _value.quantize(quant);
        return new FixToken(result);
    }
View Full Code Here

     *  the type of the argument is an FixToken.
     *  @param rightArgument The token to subtract from this token.
     *  @return A new FixToken containing the result.
     */
    protected ScalarToken _subtract(ScalarToken rightArgument) {
        FixPoint result = _value
                .subtract(((FixToken) rightArgument).fixValue());
        return new FixToken(result);
    }
View Full Code Here

    /** Return the value in the token as a fixpoint.
     *  @return The value contained in this token as a fixpoint.
     */
    public FixPoint fixValue() {
        // FIXME: Does FixPoint need to specially handle Short?
        return new FixPoint(_value);
    }
View Full Code Here

                    localName, stringTokenClass, stringTokenConstructor,
                    StringConstant.v(((StringToken) token).stringValue()));
            return tokenLocal;
        } else if (token instanceof FixToken) {
            FixToken fixToken = (FixToken) token;
            FixPoint fixValue = fixToken.fixValue();
            List args = new ArrayList(3);

            // Some possible loss of precision?
            args.add(DoubleConstant.v(fixValue.doubleValue()));
            args.add(IntConstant.v(fixValue.getPrecision().getNumberOfBits()));
            args.add(IntConstant.v(fixValue.getPrecision()
                    .getIntegerBitLength()));

            Local tokenLocal = _buildConstantTokenLocal(body, insertPoint,
                    localName, fixTokenClass, fixTokenThreeArgConstructor, args);
            return tokenLocal;
View Full Code Here

            if (!address.hasToken(0)) {
                return;
            }

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

            _checkFixTokenWidth(addressToken, _addressWidth);

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

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

            ArrayToken valuesArray = (ArrayToken) values.getToken();
            FixPoint value = new FixPoint(((ScalarToken) valuesArray
                    .getElement(addressValue)).intValue());
            Token result = new FixToken(value);
            if (result == null) {
                result = Token.NIL;
            }
View Full Code Here

        }

        //FIXME: what do we do if input is negative?
        //bits = bits.replace('-', '1');

        FixPoint result = new FixPoint(new BigDecimal(new BigInteger(bits
                .toString(), 2)), new FixPointQuantization(precision, overflow,
                rounding));

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

                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

TOP

Related Classes of ptolemy.math.FixPoint$Error

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.