caoss.simulator.hardware

## Class CPUCore

- java.lang.Object
- - caoss.simulator.hardware.CPUCore

- All Implemented Interfaces:
    Clockable
  Direct Known Subclasses:
    SimpleCPUCore

      public abstract class CPUCore
      extends java.lang.Object
      implements Clockable

  Base class for the implementation of a CPU core
  Author:
    Herve Paulino

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `CPUCore()`

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `Context` | `getContext()` Obtain the context currently running in the core
    `abstract <T> T` | `getRegister(int number)` Obtain the value of a given register
    `abstract java.lang.Object[]` | `getRegisters()` Obtain the core's register array
    `abstract void` | `handleInterrupt(Interrupt interrupt)` Handle an interrupt
    `void` | `load(Context context)` Load context to the core
    `abstract void` | `setRegisters(int register, java.lang.Object... values)` Set the value of a sequence of registers

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface caoss.simulator.hardware.Clockable

      `getDescription, tick`

- - ### Constructor Detail

    - #### CPUCore

          public CPUCore()

  - ### Method Detail

    - #### load

          public void load(Context context)

      Load context to the core
      Parameters:
        `context` - The context

    - #### getContext

          public Context getContext()

      Obtain the context currently running in the core
      Returns:
        The context

    - #### handleInterrupt

          public abstract void handleInterrupt(Interrupt interrupt)
                                        throws java.lang.Exception

      Handle an interrupt
      Parameters:
        `interrupt` - The interrupt to handle
      Throws:
        `java.lang.Exception`

    - #### setRegisters

          public abstract void setRegisters(int register,
                                            java.lang.Object... values)
                                     throws InvalidRegisterException

      Set the value of a sequence of registers
      Parameters:
        `register` - The initial register to affect
        `values` - The values to store
      Throws:
        `InvalidRegisterException` - Thrown if the sequence of registers to affect goes beyond the number of registers supported by the CPU core

    - #### getRegisters

          public abstract java.lang.Object[] getRegisters()

      Obtain the core's register array
      Returns:
        The array of registers

    - #### getRegister

          public abstract <T> T getRegister(int number)
                                     throws InvalidRegisterException

      Obtain the value of a given register
      Parameters:
        `number` - The number of the register to read
      Returns:
        The value stored in register(number)
      Throws:
        `InvalidRegisterException` - Thrown if number is not a valid register