System and method for addressing data in memory
A digital signal processor having a CPU with a program counter register and, optionally, an event context stack pointer register for saving and restoring the event handler context when higher priority event preempts a lower priority event handler. The CPU is configured to use a minimized set of addressing modes that includes using the event context stack pointer register and program counter register to compute an address for storing data in memory. The CPU may also eliminate post-decrement, pre-increment and post-decrement addressing and rely only on post-increment addressing.
1 . A device comprising:
a set of control registers that includes a program counter register and a stack pointer register, wherein the stack pointer register includes a first field configured to store a first portion of a base address and a second field configured to store a nested count; and
a set of functional units coupled to the set of control registers and configured to:
in a first mode, load a first set of data from a first address specified by the program counter register; and
in a second mode, load a second set of data from a second address specified by the stack pointer register.
2 . The device of claim 1 further comprising a memory coupled to the set of functional units, wherein the set of functional units is configured to load the first set of data and the second set of data from the memory.
3 . The device of claim 2 , wherein the memory is a level one data (LID) cache.
4 . The device of claim 1 further comprising an interrupt circuit coupled to the set of control registers and configured to detect an event, and based on the event, store a value in the stack pointer register.
5 . The device of claim 1 , wherein the stack pointer register does not specify a second portion of the base address.
6 . The device of claim 1 , wherein:
the set of functional units is configured to:
load the first set of data in response to a first instruction that specifies a first offset; and
load the second set of data in response to a second instruction that specifies a second offset;
the first address is further based on the first offset; and
the second address is further based on the second offset.
7 . The device of claim 1 further comprising interrupt circuitry configured to detect an event, wherein the set of functional units is configured to select between the first mode and the second mode based on the event.
8 . The device of claim 7 , wherein the event is associated with preemption of an event handler.
9 . The device of claim 1 , wherein the set of functional units is configured to:
increment a value stored in the program counter register after the load of the first set of data.
10 . A device comprising:
a set of control registers that includes a program counter register and a stack pointer register, wherein the stack pointer register includes a first field configured to store a first portion of a base address and a second field configured to store a nested count; and
a set of functional units coupled to the set of control registers and configured to:
in a first mode, store a first set of data to a first address specified by the program counter register; and
in a second mode, store a second set of data to a second address specified by the stack pointer register.
11 . The device of claim 10 further comprising a memory coupled to the set of functional units, wherein the set of functional units is configured to store the first set of data and the second set of data to the memory.
12 . The device of claim 11 , wherein the memory is a level one data (LID) cache.
13 . The device of claim 10 further comprising an interrupt circuit coupled to the set of control registers and configured to detect an event, and based on the event, store a value in the stack pointer register.
14 . The device of claim 10 , wherein the stack pointer register does not specify a second portion of the base address.
15 . The device of claim 10 , wherein:
the set of functional units is configured to:
store the first set of data in response to a first instruction that specifies a first offset; and
store the second set of data in response to a second instruction that specifies a second offset;
the first address is further based on the first offset; and
the second address is further based on the second offset.
16 . The device of claim 10 further comprising interrupt circuitry configured to detect an event, wherein the set of functional units is configured to select between the first mode and the second mode based on the event.
17 . A method comprising:
receiving an instruction;
determining whether to generate an address associated with the instruction based on a first value stored in a program counter register or on a second value stored in a stack pointer register, wherein the stack pointer register includes a first field configured to store a first portion of a base address and a second field configured to store a nested count;
generating the address based on a result of the determining step; and
performing the instruction using the address.
18 . The method of claim 17 , wherein the performing of the instruction includes performing at least one of a read of a set of data from a memory using the address or a write of a set of data to the memory using the address.