Digital Signal Processor C5X Addressing Modes

40
TMS320C5X Addressing Modes 01/15/2022 1 Abhishek KumarSrivastava

description

Addressing Modes of C5X DSP Processor.

Transcript of Digital Signal Processor C5X Addressing Modes

Page 1: Digital Signal Processor C5X Addressing Modes

04/17/2023 Abhishek KumarSrivastava 1

TMS320C5X Addressing Modes

Page 2: Digital Signal Processor C5X Addressing Modes

04/17/2023 Abhishek KumarSrivastava 2

Assembly Language Syntax

• A source statement can contain four ordered fields. Those are:[label] [:] mnemonic [operand list] [;comment]• Rules to be followed:1. All statement begin with label, blank, asterisk or semicolon.2. Labels (optional); must begin in column 13. Labels either placed before instruction in same line or on the

preceding line in first column.4. Blank separate each fields of statement.5. Comments are optional; begins with ‘*’ or ‘;’.

Page 3: Digital Signal Processor C5X Addressing Modes

04/17/2023 Abhishek KumarSrivastava 3

Addressing Modes

• C5X processors can address 64K words of program memory and 96K words of data memory.

• C5X supports following 6 addressing modes:1. Direct addressing2. Memory-mapped register addressing3. Indirect addressing4. Immediate addressing5. Dedicated-register addressing6. Circular addressing

Page 4: Digital Signal Processor C5X Addressing Modes

04/17/2023 Abhishek KumarSrivastava 4

Direct Memory Addressing

• In the direct memory addressing mode, the instruction contains the lower 7 bits of the data memory address (dma).

• The 7-bit dma is concatenated with the 9 bits of the data memory page pointer (DP) in status register 0 to form the full 16-bit data memory address.

• This 16-bit data memory address is placed on an internal direct data memory address bus (DAB).

• The DP points to one of 512 possible data memory pages and the 7-bit address in the instruction points to one of 128 words within that data memory page.

• You can load the DP bits by using the LDP or the LST #0 instruction.

Page 5: Digital Signal Processor C5X Addressing Modes

04/17/2023 Abhishek KumarSrivastava 5

Page 6: Digital Signal Processor C5X Addressing Modes

04/17/2023 Abhishek KumarSrivastava 6

Data memory address, points to word 010h=16d in page 19Dh

Data memory page pointer, points to page number 19Dh = 413d

Shift left by 5 bits then added to ACC.

0 = Direct addressing mode

Page 7: Digital Signal Processor C5X Addressing Modes

04/17/2023 Abhishek KumarSrivastava 7

Indirect Addressing• Uses Eight 16-bit auxiliary registers (AR0–AR7).• In indirect addressing, any location in the 64K-word data

memory space can be accessed using a 16-bit address contained in an AR.

• To select a specific AR, load the ARP with a value from 0 through 7, designating AR0 through AR7, respectively.

• The register pointed to by the ARP is referred to as the current auxiliary register (current AR).

• You can load the address into the AR using the LAR instruction.

Page 8: Digital Signal Processor C5X Addressing Modes

04/17/2023 Abhishek KumarSrivastava 8

Page 9: Digital Signal Processor C5X Addressing Modes

04/17/2023 Abhishek KumarSrivastava 9

• You can change the content of the AR by the:• ADRK instruction (The 8-bit immediate value, right-justified, is

added to current AR using ARAU. The result is stored in the AR.)

• MAR instruction (The MAR instruction modifies the ARs or the ARP bits, and the old ARP bits are copied to the ARB bits.)

• SBRK instruction (The 8-bit immediate value, right-justified, is subtracted from the current AR using ARAU. The result is stored in the current AR.)

Page 10: Digital Signal Processor C5X Addressing Modes

04/17/2023 Abhishek KumarSrivastava 10

• The content of the current AR is used as the address of the data memory operand.

• After the instruction uses the data value, the content of the current AR can be incremented or decremented by the auxiliary register arithmetic unit (ARAU), which implements unsigned 16-bit arithmetic.

• The ARAU performs auxiliary register arithmetic operations in the decode phase of the pipeline.

• This allows the address to be generated before the decode phase of the next instruction.

Page 11: Digital Signal Processor C5X Addressing Modes

04/17/2023 Abhishek KumarSrivastava 11

• The content of the current AR is incremented or decremented after it is used in the current instruction.

• You can load the ARs via the data bus by using memory-mapped writes to the ARs.

• Be careful when using these memory-mapped loads of the ARs because, in this case, the memory-mapped ARs are modified in the execute phase of the pipeline, causing a pipeline conflict, if one of the next two instruction words modifies same AR (without memory mapped).

Page 12: Digital Signal Processor C5X Addressing Modes

04/17/2023 Abhishek KumarSrivastava 12

• There are two ways to use the ARs for purposes other than referencing data memory addresses:

1. Use the ARs to support conditional branches, calls, and returns by using the CMPR instruction.

• This instruction compares the content of the current AR with the content of the auxiliary register compare register (ARCR) and puts the result in the test/control (TC) flag bit of status register ST1.

2. Use the ARs for temporary storage by using the LAR instruction to load a value into the AR and the SAR instruction to store the AR value to a data memory location.

Page 13: Digital Signal Processor C5X Addressing Modes

04/17/2023 Abhishek KumarSrivastava 13

Indirect Addressing Options

• Here, the instruction uses the content of the current AR as the data memory address.

• The ’C5x provides four indirect addressing options:1. No increment or decrement (*) in AR content.2. Increment or decrement by one (*+ or *-) in AR content.3. Increment or decrement by an index amount (*0+ or *0-) in

AR content.4. Increment or decrement by an index amount using reverse

carry added or subtracted (*BR0+ or *BR0-) (carry propagating in the reverse direction from MSB to the LSB) in AR content.

Page 14: Digital Signal Processor C5X Addressing Modes

04/17/2023 Abhishek KumarSrivastava 14

Indirect Addressing Opcode Format

Page 15: Digital Signal Processor C5X Addressing Modes

04/17/2023 Abhishek KumarSrivastava 15

Page 16: Digital Signal Processor C5X Addressing Modes

04/17/2023 Abhishek KumarSrivastava 16

Page 17: Digital Signal Processor C5X Addressing Modes

04/17/2023 Abhishek KumarSrivastava 17

Page 18: Digital Signal Processor C5X Addressing Modes

04/17/2023 Abhishek KumarSrivastava 18

Page 19: Digital Signal Processor C5X Addressing Modes

04/17/2023 Abhishek KumarSrivastava 19

Bit-Reversed Addressing• In the bit-reversed addressing mode, INDX specifies one-half the

size of the FFT. • The value contained in the current AR must be equal to 2n-1, where

n is an integer, and the FFT size is 2n. • An auxiliary register points to the physical location of a data value. • When you add INDX to the current AR using bit-reversed

addressing, addresses are generated in a bit-reversed fashion.• When you add INDX to the current AR using bit-reversed

addressing, addresses are generated in a bit-reversed fashion.• Assume that the auxiliary registers are eight bits long, AR2

represents the base address of the data in memory (0110 00002), and that INDX contains the value 0000 10002.

Page 20: Digital Signal Processor C5X Addressing Modes

04/17/2023 Abhishek KumarSrivastava 20

Page 21: Digital Signal Processor C5X Addressing Modes

04/17/2023 Abhishek KumarSrivastava 21

Immediate Addressing

• In immediate addressing, the instruction word(s) contains the value of the immediate operand.

• The ’C5x has both 1-word (8-bit, 9-bit, and 13-bit constant) short immediate instructions and 2-word (16-bit constant) long immediate instructions.

Page 22: Digital Signal Processor C5X Addressing Modes

04/17/2023 Abhishek KumarSrivastava 22

Short Immediate Addressing

• In short immediate instructions, the operand is contained within the instruction machine code.

• In this example, the lower 8 bits are the operand and will be added to the ACC by the CALU.

Page 23: Digital Signal Processor C5X Addressing Modes

04/17/2023 Abhishek KumarSrivastava 23

Long Immediate Addressing

• In long immediate instructions, the operand is contained in the second word of a two-word instruction.

Page 24: Digital Signal Processor C5X Addressing Modes

04/17/2023 Abhishek KumarSrivastava 24

Data memory page pointer, points to page number 19Dh = 413d

Data memory address, points to word 012h=18d in page 19Dh

Page 25: Digital Signal Processor C5X Addressing Modes

04/17/2023 Abhishek KumarSrivastava 25

Dedicated-Register Addressing

• The dedicated-registered addressing mode operates like the long immediate addressing mode, except that the address comes from one of two special-purpose memory-mapped registers in the CPU: the block move address register (BMAR) and the dynamic bit manipulation register (DBMR).

• The advantage of this addressing mode is that the address of the block of memory to be acted upon can be changed during execution of the program.

Page 26: Digital Signal Processor C5X Addressing Modes

04/17/2023 Abhishek KumarSrivastava 26

The PLU executes a read-modify-write operation on data stored in data space.First, one operand is fetched from data memory space, and the second is fetched from a long immediate on the program bus or from the dynamic bit manipulationregister (DBMR). Then, the PLU executes a logical operation on the two operands as defined by the instruction. The result is written to the same data memory location from which the first operand was fetched, without affecting ACC or PREG.

DP=6; 6X128 = 768d + 10d = 778d=030Ah

Page 27: Digital Signal Processor C5X Addressing Modes

04/17/2023 Abhishek KumarSrivastava 27

Using the Contents of the BMAR

• The BLDD, BLDP, and BLPD instructions use the BMAR (holds an address value for use with block moves or multiply/ accumulates).

Page 28: Digital Signal Processor C5X Addressing Modes

04/17/2023 Abhishek KumarSrivastava 28

Role of PFC• A 16-bit counter used to prefetch program instructions. • The PFC contains the address of the instruction currently being

prefetched and is updated when a new prefetch is initiated.• Once an instruction is prefetched, the instruction is loaded into the

IREG, unless the IREG still contains an instruction currently executing, in which case the prefetched instruction is stored in the QIR (Queue Instruction Register).

• The PFC is then incremented, and after the current instruction has completed execution, the instruction in the QIR is loaded into the IREG to be executed.

• The PFC is also used to address program memory when using the block move (BLPD), multiply-accumulate (MAC/MACD), and table read/write (TBLR/TBLW) instructions and to address data memory when using the block move (BLDD) instruction.

Page 29: Digital Signal Processor C5X Addressing Modes

04/17/2023 Abhishek KumarSrivastava 29

Role of PFC• The long immediate addressing or BMAR also could apply for

a “second data memory access” for the execution of the instruction (Immediate Addressing Mode).

• The prefetch counter (PFC) is pushed onto the microcall stack (MCS), and the long immediate value or BMAR is loaded into the PFC.

• The program address/data bus is then used for the operand fetch or write.

• At the completion of the instruction, the MCS is popped back to the PFC, the program counter (PC) is incremented by two (long immediate operand), and execution continues.

Page 30: Digital Signal Processor C5X Addressing Modes

04/17/2023 Abhishek KumarSrivastava 30

Page 31: Digital Signal Processor C5X Addressing Modes

04/17/2023 Abhishek KumarSrivastava 31

Using the Contents of the DBMR

• The APL, CPL, OPL, XPL instructions use the PLU and the contents of the DBMR when an immediate value is not specified as one of the operands.

• APL (AND data memory value with DBMR, and store result in data memory location)

• CPL (Compare data memory value with DBMR)• OPL (OR data memory value with DBMR and store result in

data memory location)• XPL (Exclusive-OR data memory value with DBMR and store

result in data memory location)

Page 32: Digital Signal Processor C5X Addressing Modes

04/17/2023 Abhishek KumarSrivastava 32

Memory-Mapped Register Addressing

• With memory-mapped register addressing, you can modify the memory mapped registers without affecting the current data page pointer value.

• In addition, you can modify any scratch pad RAM (DARAM B2) location or data page 0.

• The memory-mapped register addressing mode operates like the direct addressing mode, except that the 9 MSBs of the address are forced to 0 instead of being loaded with the contents of the DP.

• This allows you to address the memory-mapped registers of data page 0 directly without the overhead of changing the DP or auxiliary register.

Page 33: Digital Signal Processor C5X Addressing Modes

04/17/2023 Abhishek KumarSrivastava 33

• Using these instructions does not affect the contents of the DP:

LAMM — Load accumulator with memory-mapped register

LMMR — Load memory-mapped register with the contents of the data memory location addressed by the 16-bit source address, #addr.

SAMM — Store accumulator in memory-mapped register SMMR — Store memory-mapped register with the

contents of the data memory location addressed by the 16-bit source address, #addr.

Page 34: Digital Signal Processor C5X Addressing Modes

04/17/2023 Abhishek KumarSrivastava 34

PMST: A MMR that contains status and control bits.

Page 35: Digital Signal Processor C5X Addressing Modes

04/17/2023 Abhishek KumarSrivastava 35

Page 36: Digital Signal Processor C5X Addressing Modes

04/17/2023 Abhishek KumarSrivastava 36

Circular Addressing

• The ’C5x supports two concurrent circular buffers (for algorithms such as convolution, correlation, and FIR filters) operating via the ARs.

• The following five memory-mapped registers control the circular buffer operation:

1. CBSR1 — Circular buffer 1 start register2. CBSR2 — Circular buffer 2 start register3. CBER1 — Circular buffer 1 end register4. CBER2 — Circular buffer 2 end register5. CBCR — Circular buffer control register

Page 37: Digital Signal Processor C5X Addressing Modes

04/17/2023 Abhishek KumarSrivastava 37

Page 38: Digital Signal Processor C5X Addressing Modes

04/17/2023 Abhishek KumarSrivastava 38

• The 8-bit CBCR enables and disables the circular buffer operation.• To define circular buffers, we first load the start and end addresses

into the corresponding buffer registers; next, load a value between the start and end registers for the circular buffer into an AR.

• Load the proper AR value, and set the corresponding circular buffer enable bit in the CBCR.

• If (ARn = CBER) and (any AR modification),Then: ARn = CBSR.Else: ARn = ARn + step.

• Circular buffers can be used in increment- or decrement-type updates.

Page 39: Digital Signal Processor C5X Addressing Modes

04/17/2023 Abhishek KumarSrivastava 39

Modify ARStore long immediate in data memory location

Load AR

Load ACC with content available at address held in AR6

Add short immediate to AR

Page 40: Digital Signal Processor C5X Addressing Modes

04/17/2023 Abhishek KumarSrivastava 40

Thank you for listening !