Package ptolemy.math
Class Precision.VHDLPrecisionFormat
- java.lang.Object
-
- ptolemy.math.Precision.PrecisionFormat
-
- ptolemy.math.Precision.VHDLPrecisionFormat
-
- Enclosing class:
- Precision
public static class Precision.VHDLPrecisionFormat extends Precision.PrecisionFormat
Defines a Precision string format using the VHDL MSB:LSB precision format. The MSB value specifies the location of the most significant bit and LSB specifies the location of the least significant bit. Negative values are allowed for both MSB and LSB so long as the MSB is greater than the LSB.This format supports the specification of either signed or unsigned values. The character 'U' must precede the MSB:LSB format to specify an unsigned value. An 'S' character may be applied to specify a signed number. If no 'U' or 'S' signed specification is provided, the precision will default to a signed value.
Parenthesis or brackets are optional around this specification. Examples:
- (2:3)
- (4:-3)
- [7:0]
- [-3:-8]
- 4:3
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.String
_regex
Regular expression for IntegerFractionPrecisionFormat.-
Fields inherited from class ptolemy.math.Precision.PrecisionFormat
COMMA_OR_FORWARDSLASH, OPTIONAL_L_PARAN, OPTIONAL_L_PARANBRACKET, OPTIONAL_R_PARAN, OPTIONAL_R_PARANBRACKET, OPTIONAL_U_OR_S_GROUP, OPTIONAL_WHITE_SPACE, PERIOD, SIGNED_INTEGER_GROUP, UNSIGNED_INTEGER_GROUP
-
-
Constructor Summary
Constructors Constructor Description VHDLPrecisionFormat()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Precision
parseString(java.lang.String str)
Parse the given String argument using the rules of the specific PrecisionFormat that is defined.java.lang.String
printPrecisionFormat(Precision p)
Creates a valid String representation of the Precision object based on the rules of the given string format.-
Methods inherited from class ptolemy.math.Precision.PrecisionFormat
parseInteger, parseSignString
-
-
-
-
Field Detail
-
_regex
protected final java.lang.String _regex
Regular expression for IntegerFractionPrecisionFormat. Example ([US]{digit}:{digit})- See Also:
- Constant Field Values
-
-
Method Detail
-
parseString
public Precision parseString(java.lang.String str)
Description copied from class:Precision.PrecisionFormat
Parse the given String argument using the rules of the specific PrecisionFormat that is defined. This method will return a valid Precision object from the String. If the String parsing does not produce a valid match, this method will return a null. If the String match is successful but there is a problem in the interpretation of the match, this method will throw a IllegalArgumentException.- Specified by:
parseString
in classPrecision.PrecisionFormat
- Parameters:
str
- String to parse- Returns:
- A Precision object. Returns a null if the String does not match the particular string format.
-
printPrecisionFormat
public java.lang.String printPrecisionFormat(Precision p)
Description copied from class:Precision.PrecisionFormat
Creates a valid String representation of the Precision object based on the rules of the given string format. The format of this String should be consistent with the format used in the parseString method.- Specified by:
printPrecisionFormat
in classPrecision.PrecisionFormat
- Parameters:
p
- Precision object to represent as a String.- Returns:
- String representing the Precision object
-
-