Class Coprocessor1

java.lang.Object
mars.mips.hardware.Coprocessor1

public class Coprocessor1 extends Object
Represents Coprocessor 1, the Floating Point Unit (FPU)
Author:
Pete Sanderson, July 2005
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    Set condition flag to 0 (false).
    static int
    getConditionFlag(int flag)
    Get value of specified condition flag (0-7).
    static int
    Get count of condition flags.
    static double
    getDoubleFloat(int number)
    Gets the double value stored in the given FPU register.
    static long
    getPairValue(int number)
    Gets a long representing the double value stored in the given double precision FPU register.
    static Register
    Get the register corresponding to a given register name.
    static int
    Get the register number corresponding to a given register name.
    static Register[]
    For returning the set of registers.
    static float
    getSingleFloat(int number)
    Gets the float value stored in the given FPU register.
    static int
    getValue(int number)
    Returns the value of the FPU register whose number is given.
    static void
    Method to reinitialize the values of the registers.
    static void
    setConditionFlag(int flag)
    Set condition flag to 1 (true).
    static void
    setDoubleFloat(int number, double value)
    Sets the value of the FPU register given to the double value given.
    static void
    setPairValue(int number, long value)
    Sets the value of the FPU register pair given to the long value containing 64 bit pattern given.
    static void
    setSingleFloat(int reg, float val)
    Sets the value of the FPU register given to the value given.
    static int
    setValue(int number, int value)
    This method updates the FPU register value whose number is given.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Coprocessor1

      public Coprocessor1()
  • Method Details

    • setSingleFloat

      public static void setSingleFloat(int reg, float val)
      Sets the value of the FPU register given to the value given.
      Parameters:
      reg - Register to set the value of.
      val - The desired float value for the register.
    • setDoubleFloat

      public static void setDoubleFloat(int number, double value) throws InvalidRegisterAccessException
      Sets the value of the FPU register given to the double value given. The register must be even-numbered, and the low order 32 bits are placed in it. The high order 32 bits are placed in the (odd numbered) register that follows it.
      Parameters:
      number - Register to set the value of.
      value - The desired double value for the register.
      Throws:
      InvalidRegisterAccessException - if register ID is invalid or odd-numbered.
    • setPairValue

      public static void setPairValue(int number, long value) throws InvalidRegisterAccessException
      Sets the value of the FPU register pair given to the long value containing 64 bit pattern given. The register must be even-numbered, and the low order 32 bits from the long are placed in it. The high order 32 bits from the long are placed in the (odd numbered) register that follows it.
      Parameters:
      number - Register to set the value of. Must be even register of even/odd pair.
      value - The desired long value for the register.
      Throws:
      InvalidRegisterAccessException - if register ID is invalid or odd-numbered.
    • getSingleFloat

      public static float getSingleFloat(int number)
      Gets the float value stored in the given FPU register.
      Parameters:
      number - Register to get the value of.
      Returns:
      The float value stored by that register.
    • getDoubleFloat

      public static double getDoubleFloat(int number) throws InvalidRegisterAccessException
      Gets the double value stored in the given FPU register. The register must be even-numbered.
      Parameters:
      number - Register to get the value of. Must be even number of even/odd pair.
      Throws:
      InvalidRegisterAccessException - if register ID is invalid or odd-numbered.
    • getPairValue

      public static long getPairValue(int number) throws InvalidRegisterAccessException
      Gets a long representing the double value stored in the given double precision FPU register. The register must be even-numbered.
      Parameters:
      number - Register to get the value of. Must be even number of even/odd pair.
      Throws:
      InvalidRegisterAccessException - if register ID is invalid or odd-numbered.
    • setValue

      public static int setValue(int number, int value)
      This method updates the FPU register value whose number is given. Note the registers themselves hold an int value. There are helper methods available to which you can give a float or double to store.
      Parameters:
      number - FPU register to set the value of.
      value - The desired int value for the register.
      Returns:
      The previous value of the register.
    • getValue

      public static int getValue(int number)
      Returns the value of the FPU register whose number is given. Returns the raw int value actually stored there. If you need a float, use Float.intBitsToFloat() to get the equivent float.
      Parameters:
      number - The FPU register number.
      Returns:
      The int value of the given register.
    • getRegisterNumber

      public static int getRegisterNumber(String name)
      Get the register number corresponding to a given register name.
      Parameters:
      name - The name of the register to search for.
      Returns:
      The number of the register, or -1 if not found.
    • getRegisters

      public static Register[] getRegisters()
      For returning the set of registers.
      Returns:
      The set of registers.
    • getRegister

      public static Register getRegister(String name)
      Get the register corresponding to a given register name.
      Parameters:
      name - The name of the register to search for, e.g. $f0.
      Returns:
      The register, or null if not found.
    • reset

      public static void reset()
      Method to reinitialize the values of the registers.
    • setConditionFlag

      public static void setConditionFlag(int flag)
      Set condition flag to 1 (true).
      Parameters:
      flag - condition flag number (0-7)
    • clearConditionFlag

      public static void clearConditionFlag(int flag)
      Set condition flag to 0 (false).
      Parameters:
      flag - condition flag number (0-7)
    • getConditionFlag

      public static int getConditionFlag(int flag)
      Get value of specified condition flag (0-7).
      Parameters:
      flag - condition flag number (0-7)
      Returns:
      0 if condition is false, 1 if condition is true
    • getConditionFlagCount

      public static int getConditionFlagCount()
      Get count of condition flags.
      Returns:
      number of condition flags