Dsp Add Rs Modes

Embed Size (px)

Citation preview

  • 8/3/2019 Dsp Add Rs Modes

    1/47

  • 8/3/2019 Dsp Add Rs Modes

    2/47

    Data addressing modes providevarious ways to access operands to

    execute instructions and placeresults in the memory or theregisters.

  • 8/3/2019 Dsp Add Rs Modes

    3/47

    In immediate addressing, the instruction syntaxcontains the specific value of the operand.

    Two types of values can be encoded in aninstruction:

    Short immediate values can be 3, 5, 8, or 9 bits inlength.

    Long immediate values are always 16 bits inlength.

    Immediate values can be encoded in 1-word or 2-word instructions. The 3-, 5-, 8-, or 9-bit values are encoded into 1-

    word instructions; 16-bit values are encoded into 2-word instructions.

  • 8/3/2019 Dsp Add Rs Modes

    4/47

    The length of the immediate value encoded in aninstruction depends on the type of instruction used.

  • 8/3/2019 Dsp Add Rs Modes

    5/47

    The syntax for immediate addressing uses anumber sign (#) immediately preceding the

    value or symbol to indicate that it is animmediate value.

    For example, to load accumulator A with thevalue 80 in hexadecimal, LD #80h, A

    RPT instruction: a long-immediate (#lk) valueis encoded in instructions that use immediateaddressing.

    The opcode of the instruction is encoded in the

    high half of the instruction, bits 015 of thehigh word of a 2-word encoding.

    The value of the constant is in the remaininginstruction space.

  • 8/3/2019 Dsp Add Rs Modes

    6/47

  • 8/3/2019 Dsp Add Rs Modes

    7/47

    Data-memory address (dmad) addressing: MVDK Smem, dmad, MVDM dmad, MMR, MVKD dmad,

    Smem MVMD MMR, dmad Program-memory address (pmad) addressing:

    FIRS Xmem, Ymem, pmad MACD Smem, pmad, src MACP Smem, pmad, src MVDP Smem, pmad MVPD

    pmad, Smem Port address (PA) addressing: PORTR PA, Smem PORTW Smem, PA

    *(lk) addressing is used with all instructions that support theuse of a single data-memory (Smem) operand. Absolute addresses are always encoded with a length of 16

    bits, so instructions that encode absolute addresses arealways at least two words in length.

  • 8/3/2019 Dsp Add Rs Modes

    8/47

    dmad Addressing

    Data-memory address (dmad) addressing uses aspecific value to specify an address in data space.

    The syntax for dmad addressing uses a symbol ora number to specify an address in data space.

    For example, to copy the value contained at theaddress labeled SAMPLE in data space to thememory location in data space pointed to by AR5,one would write:

    MVKD SAMPLE, *AR5 In this example, the address referenced by

    SAMPLE is the dmad value.

  • 8/3/2019 Dsp Add Rs Modes

    9/47

    pmad Addressing

    Program-memory address (pmad) addressing usesa specific value to specify an address in programspace.

    The syntax for pmad addressing uses a symbol or a

    number to specify an address in program space. For example, to copy a word in the program

    memory location labeled TABLE to a data-memorylocation specified by AR7, one would write:

    MVPD TABLE, *AR7 In this example, the address referenced by TABLE

    is the pmad value.

  • 8/3/2019 Dsp Add Rs Modes

    10/47

    PA Addressing

    Port address (PA) addressing uses a specificvalue to specify an external I/O port address.

    The syntax for PA addressing uses a symbol ora number to specify the port address.

    For example, to copy a value from the I/O portat port address FIFO to a data-memory locationpointed to by AR5, one would write:

    PORTR FIFO, *AR5

    In the example, FIFO refers to the port address.

  • 8/3/2019 Dsp Add Rs Modes

    11/47

    *(lk) Addressing

    *(lk) addressing uses a specific value to specify anaddress in data space.

    The syntax for *(lk) addressing uses a symbol or anumber to specify an address in data space.

    For example, to load accumulator A with the valuecontained in address BUFFER in data space, onewould write:

    LD *(BUFFER),A

    The syntax for *(lk) addressing allows allinstructions that use Smem addressing to accessany location in data space without changing theDP or initializing an AR.

  • 8/3/2019 Dsp Add Rs Modes

    12/47

    Accumulator Addressing: Accumulator addressing uses the value in the

    accumulator as an address. This addressing mode is used to address program

    memory as data. Two instructions allow to use the accumulator as

    an address: READA Smem, WRITA Smem READA transfers a word from a program-memory

    location specified by accumulator A to a data-memory location specified by the single data-

    memory (Smem) operand of the instruction. WRITA transfers a word from a data-memorylocation specified by the Smem operand of theinstruction to a program-memory locationspecified by accumulator A.

  • 8/3/2019 Dsp Add Rs Modes

    13/47

    Direct Addressing

    In direct addressing, the instruction containsthe lower seven bits of the data memory

    address (dma).

    The 7-bit dma is an address offset that is

    combined with a base address, with the data-page pointer (DP), or with the stack pointer(SP) to form a 16-bit data-memory address.

    Using this form of addressing, you can access

    any of 128 locations in random order withoutchanging the DP or the SP.

  • 8/3/2019 Dsp Add Rs Modes

    14/47

    Either DP or SP can be combined with the dma offset to generate theactual

    address. The compiler mode bit (CPL), located in status register ST1,selects

    which method is used to generate the address: When CPL = 0, the dma field is concatenated with the 9-bit DP field to

    form the 16-bit data-memory address. When CPL = 1, the dma field is added (positive offset) to SP to form

    the

    16-bit data-memory address. The syntax for direct addressing uses a symbol or a number to specify the

    offset value. For example, to add the contents of the memory location SAMPLE to accumulator B, provided that the correct base address is in DP (CPL =

    0) or SP (CPL = 1), you would write: ADD SAMPLE, B The lower seven bits of the address of SAMPLE are stored in the

    instruction word.

  • 8/3/2019 Dsp Add Rs Modes

    15/47

  • 8/3/2019 Dsp Add Rs Modes

    16/47

  • 8/3/2019 Dsp Add Rs Modes

    17/47

    In DP-referenced direct addressing, the 7-bit dma inthe instruction register is concatenated with the 9-bit

    DP to form the address. DP-referenced direct addressing divides memoryinto 512 pages, because the DPs range is from 0 to511 (29 1). Each page has 128 addressable locations,because the dma ranges from 0 to 127 (27 1).

    In other words, the DP points to one of 512 possible128-word data-memory pages; the dma points to thespecific location within that page.

    The only difference between an access to location 0on page 1 and to location 0 on page 2 is the value ofthe DP.

    The DP is loaded by the LD instruction.

  • 8/3/2019 Dsp Add Rs Modes

    18/47

    SP-ReferencedDirect Addressing

    In SP-referenced direct addressing, the 7-bitdma in the instruction register is added as apositive offset to the SP to form the effective 16-bit data-memory address.

    The SP points to any address in memory. Thedma points to the specific location on the page,allowing you to access a contiguous 128-word(2^7 1) block in memory from any base

    address. SP can also add or remove items from the

    stack.

  • 8/3/2019 Dsp Add Rs Modes

    19/47

    Indirect Addressing:

    In indirect addressing, any location in the 64K-word data space can be accessed using the 16-bit address contained in an auxiliary register.

    The C54xDSP has eight 16-bit auxiliary

    registers (AR0AR7). Indirect addressing is used mainly when there

    is a need to step through sequential locations inmemory in fixed-size steps.

  • 8/3/2019 Dsp Add Rs Modes

    20/47

    When memory is addressed with indirectaddressing, the auxiliary register and the

    address can be optionally modified by adecrement, an increment, an offset, or an index.

    Special modes offer circular and bit-reversedaddressing. A circular buffer size register (BK)

    is used with circular addressing. The AR0 register is used for indexed and bit-

    reversed addressing modes in addition tobeing used to point to memory as the otherauxiliary registers do.

  • 8/3/2019 Dsp Add Rs Modes

    21/47

    Indirect addressing is flexible enough not onlyto read or write a single 16-bit data operandfrom memory with one instruction, but also toaccess two data memory locations with oneinstruction.

    Accesses of two data-memory locations includereads of two independent memory locations,reads and writes of two consecutive memorylocations, and a read of one memory

    location combined with a write to a memorylocation.

  • 8/3/2019 Dsp Add Rs Modes

    22/47

  • 8/3/2019 Dsp Add Rs Modes

    23/47

    ARAU and Address-Generation Operation

    Two auxiliary register arithmetic units(ARAU0 and ARAU1) operate on the contentsof the auxiliary registers.

    The ARAUs perform unsigned, 16-bit auxiliary

    register arithmetic operations.

    Some addresses can be obtained bypremodifying the auxiliary register.

  • 8/3/2019 Dsp Add Rs Modes

    24/47

  • 8/3/2019 Dsp Add Rs Modes

    25/47

  • 8/3/2019 Dsp Add Rs Modes

    26/47

  • 8/3/2019 Dsp Add Rs Modes

    27/47

    Memory-mapped register addressing is used tomodify the memory-mapped registers withoutaffecting either the current data-page pointer(DP) value or the current stack-pointer (SP)

    value. Because DP and SP do not need to be modified

    in this mode, the overhead for writing to aregister is minimal.

    Memory-mapped register addressing works forboth direct and indirect addressing.

  • 8/3/2019 Dsp Add Rs Modes

    28/47

    Addresses are generated by:

    Forcing the nine most significant bits (MSBs) ofdata-memory address to 0, regardless of thecurrent value of DP or SP when directaddressing is used

    Using the seven LSBs of the current auxiliaryregister value when indirect addressing is used

    If AR1 is used to point to a memory-mappedregister in memory mapped registeraddressing mode and it contains a value ofFF25h.

  • 8/3/2019 Dsp Add Rs Modes

    29/47

    Then AR1 points to the timer period register

    (PRD), since the seven LSBs of AR1 are 25h

    and the address of the PRD is 0025h. After execution, the value remaining in AR1 is

    0025h.

  • 8/3/2019 Dsp Add Rs Modes

    30/47

    The system stack is used to automatically storethe program counter during interrupts andsubroutines.

    The stack is filled from the highest to the

    lowest memory address. The processor uses a16-bit memory mapped register, the stackpointer (SP), to address the stack.

    SP always points to the last element stored

    onto the stack.

  • 8/3/2019 Dsp Add Rs Modes

    31/47

    Four instructions access the stack using thestack addressing mode:

    PSHD pushes a data-memory value onto thestack.

    PSHM pushes a memory-mapped register onto

    the stack. POPD pops a data-memory value from the

    stack.

    POPM pops a memory-mapped register fromthe stack.

  • 8/3/2019 Dsp Add Rs Modes

    32/47

    A push predecrements and a pop postincrements

    the address in the SP.

  • 8/3/2019 Dsp Add Rs Modes

    33/47

    Other operations also affect the stack and the

    stack pointer. The stack is used during interrupts and

    subroutines to save and restore the PCcontents.

    When a subroutine is called or an interruptoccurs, the return address is automaticallysaved in the stack using a push operation.

    When a subroutine returns, the return addressis retrieved from the stack using a popoperation and loaded into the PC.

  • 8/3/2019 Dsp Add Rs Modes

    34/47

    Circular Addressing:

    Many algorithms, such as convolution,correlation, and FIR filters, require theimplementation of a circular buffer in memory.

    In these algorithms, a circular buffer is a sliding

    window containing the most recent data. Asnew data comes in, the buffer overwrites theoldest data.

    The key to the implementation of a circular

    buffer is the implementation of circularaddressing.

  • 8/3/2019 Dsp Add Rs Modes

    35/47

    The circular-buffer size register (BK) specifiesthe size of the circular buffer.

    A circular buffer of size R must start on a N-bitboundary (that is, the N LSBs of the baseaddress of the circular buffer must be 0), whereN is the smallest integer that satisfies 2N> R.

    The value R must be loaded into BK. For eg, a31-word circular buffer must start at an addresswhose five LSBs are 0 (that is, XXXX XXXXXXX0 00002), and the value 31 must be loadedinto BK.

  • 8/3/2019 Dsp Add Rs Modes

    36/47

    A 32-word circular buffer must start at anaddress whose six LSBs are 0 (that is, XXXX

    XXXX XX00 00002), and the value 32 must beloaded into BK.

    The effective base address (EFB) of the circularbuffer is determined by zeroing the N LSBs of auser-selected auxiliary register (ARx).

    The end of buffer address (EOB) of the circularbuffer is determined by replacing the N LSBs of

    ARx with the N LSBs of BK.

  • 8/3/2019 Dsp Add Rs Modes

    37/47

    The index of the circular buffer is simply the NLSBs of ARx and the step is the quantity being

    added to or subtracted from the auxiliaryregister.

    RULES: Place the first (lowest) address of thecircular buffer on a 2N boundary where 2N is

    larger than the circular buffer size. Use a step less than or equal to the circular

    buffer size.

    The first time the circular queue is addressed,the auxiliary register must point to an elementin the circular queue.

  • 8/3/2019 Dsp Add Rs Modes

    38/47

    The algorithm for circular addressing is asfollows: If 0

  • 8/3/2019 Dsp Add Rs Modes

    39/47

  • 8/3/2019 Dsp Add Rs Modes

    40/47

  • 8/3/2019 Dsp Add Rs Modes

    41/47

    Bit-reversed addressing enhances executionspeed and program memory for FFTalgorithms that use a variety of radixes. In thisaddressing mode, AR0 specifies one half of the

    size of the FFT. The value contained in AR0 must be equal to

    2N1, where N is an integer, and the FFT size is2N.

    An auxiliary register points to the physicallocation of a data value.

  • 8/3/2019 Dsp Add Rs Modes

    42/47

    When you add AR0 to the auxiliary registerusing bit-reversed addressing, the address isgenerated in a bit-reversed fashion, with thecarry bit propagating from left to right, insteadof the normal right to left.

  • 8/3/2019 Dsp Add Rs Modes

    43/47

    Dual data-memory operand addressing is usedfor instructions that perform two reads or asingle read and a parallel store (indicated by

    two vertical bars, ||) at the same time. Theseinstructions are all one word long and operatein indirect addressing mode only.

    Two data-memory operands are represented

    by Xmem and Ymem: Xmem is a read operand with access through

    the D bus.

  • 8/3/2019 Dsp Add Rs Modes

    44/47

    Ymem is used as a read operand in instructions

    with dual reads (accessed through the C bus)or as a write operand in instructions with aparallel store (accessed through the E bus).

    Because only two bits are available for

    selecting each auxiliary register in this mode,only four of the auxiliary registers can be used,AR2 AR5.

  • 8/3/2019 Dsp Add Rs Modes

    45/47

  • 8/3/2019 Dsp Add Rs Modes

    46/47

  • 8/3/2019 Dsp Add Rs Modes

    47/47