byucc.jhdl.util.BVFormat
Class FieldFormatInteger

java.lang.Object
  extended bybyucc.jhdl.util.BVFormat.FieldFormat
      extended bybyucc.jhdl.util.BVFormat.FieldFormatInteger
Direct Known Subclasses:
FieldFormatBinary, FieldFormatCustom, FieldFormatHex, FieldFormatSignedDecimal, FieldFormatUnsignedDecimal

public abstract class FieldFormatInteger
extends FieldFormat

Abstract class used as the base for all Integer (non-fixed point) fields.


Field Summary
protected  int bottom
          Bottom bit of range of field.
protected  int top
          Top bit of range of field.
 
Fields inherited from class byucc.jhdl.util.BVFormat.FieldFormat
minWidth
 
Constructor Summary
FieldFormatInteger(int top, int bottom, int minWidth)
          Constructs a new FieldFormatInteger object with the specified range.
 
Method Summary
protected  java.lang.String formatField(BV field, boolean fractional)
          Method required to be implemented by FieldFormat.
protected abstract  java.lang.String formatFieldInteger(BV field, boolean fractional)
          Abstract method to be implemented by subclasses.
static java.lang.String fraction2DecimalString(BV fraction)
          Takes a BV which represents a fractional portion of a number and converts it to a decimal string.
 int getBottom()
          Gets the bottom bit of the range of the field.
 int getTop()
          Gets the top bit of the range of the field.
 
Methods inherited from class byucc.jhdl.util.BVFormat.FieldFormat
formatField, getMinWidth
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

top

protected int top
Top bit of range of field.


bottom

protected int bottom
Bottom bit of range of field.

Constructor Detail

FieldFormatInteger

public FieldFormatInteger(int top,
                          int bottom,
                          int minWidth)
Constructs a new FieldFormatInteger object with the specified range.

Parameters:
top - Top (most-significant) bit of the range.
bottom - Bottom (lease-significant) bit of the range.
minWidth - Optional minimum width. A value less than or equal to zero means that there is no minumum width.
Method Detail

getTop

public int getTop()
Gets the top bit of the range of the field.

Returns:
Top bit of the range of the field.

getBottom

public int getBottom()
Gets the bottom bit of the range of the field.

Returns:
Top bit of the range of the field.

formatField

protected final java.lang.String formatField(BV field,
                                             boolean fractional)
Method required to be implemented by FieldFormat. This field is made final in this class. It will simply get the appropriate range from the BV and pass it to the formatFieldInteger() method required to be implemented by subclasses.

Specified by:
formatField in class FieldFormat
Parameters:
field - This BV is the entire BV. The correct ranges will need to be gotten by subclasses of this class.
fractional - Tells whether or not this field represents a fraction (if true) or a whole number (if false).

formatFieldInteger

protected abstract java.lang.String formatFieldInteger(BV field,
                                                       boolean fractional)
Abstract method to be implemented by subclasses. The BV passed to this method will be trimmed to include only the field.

Parameters:
field - BV representing the field.
fractional - Tells whether or not this field represents a fraction (if true) or a whole number (if false).

fraction2DecimalString

public static java.lang.String fraction2DecimalString(BV fraction)
Takes a BV which represents a fractional portion of a number and converts it to a decimal string. The binary point is assumed to be to the left of the MSB of the BV. Note that the length of the decimal string will, in general, be the same as the length of the BV, however, trailing zeros will not be displayed.

Parameters:
fraction - BV representing the fraction to be converted.
Returns:
Decimal string representing the fraction.


Copyright ? 2006 Brigham Young University, Configurable Computing Laboratory. All Rights Reserved.