Добавил:
ИВТ (советую зайти в "Несортированное") Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
interfeysy_1 / ИДЗ_машинка / даташиты / esp32_technical_reference_manual_en.pdf
Скачиваний:
13
Добавлен:
26.01.2024
Размер:
9.62 Mб
Скачать

30 ULP Coprocessor (ULP)

30.3Functional Description

The ULP coprocessor is a programmable FSM (Finite State Machine) that can work during deep sleep. Like general-purpose CPUs, ULP coprocessor also has some instructions which can be useful for a relatively complex logic, and also some special commands for RTC controllers/peripherals. The 8 KB of SRAM RTC slow memory can be accessed by both the ULP coprocessor and the CPU; hence, it is usually used to store instructions and share data between the ULP coprocessor and the CPU.

The ULP coprocessor can be started by software or a periodically-triggered timer. The operation of the ULP coprocessor is ended by executing the HALT instruction. Meanwhile, it can access almost every module in RTC domain, either through built-in instructions or RTC registers. In many cases the ULP coprocessor can be a good supplement to, or replacement of, the CPU, especially for power-sensitive applications. Figure 30-1 shows the overall layout of a ULP coprocessor.

30.4Instruction Set

The ULP coprocessor provides the following instructions:

Perform arithmetic and logic operations - ALU

Load and store data - LD, ST, REG_RD and REG_WR

Jump to a certain address - JUMP

Manage program execution - WAIT/HALT

Control sleep period of ULP coprocessor - SLEEP

Wake up/communicate with SoC - WAKE

Take measurements - ADC

Communicate using I²C - I2C_RD/I2C_WR

The ULP coprocessor’s instruction format is shown in Figure 30-2.

31

28

27

0

OpCode

 

Operands

 

 

 

 

Figure 30­2. The ULP Coprocessor Instruction Format

An instruction, which has one OpCode, can perform various different operations, depending on the setting of

Operands bits. A good example is the ALU instruction, which is able to perform 10 arithmetic and logic operations; or the JUMP instruction, which may be conditional or unconditional, absolute or relative.

Each instruction has a fixed width of 32 bits. A series of instructions can make a program be executed by the ULP coprocessor. The execution flow inside the program uses 32-bit addressing. The program is stored in a dedicated region called Slow Memory (RTC_SLOW_MEM), which is visible to the main CPUs as one that has an address range of 0x5000_0000 to 0x5000_1FFF (8 KB).

The OpCode in this chapter is represented by 4’dx, where 4 stands for 4-bit width, ’d is a decimal symbol, x stands for the value of OpCode (x: 0 ~ 15).

30.4.1 ALU ­ Perform Arithmetic/Logic Operations

The ALU (Arithmetic and Logic Unit) performs arithmetic and logic operations on values stored in ULP coprocessor registers, and on immediate values stored in the instruction itself.

Espressif Systems

657

ESP32 TRM (Version 5.0)

Submit Documentation Feedback

30 ULP Coprocessor (ULP)

The following operations are supported:

Arithmetic: ADD and SUB

Logic: bitwise logical AND and bitwise logical OR

Bit shifting: LSH and RSH

Moving data to register: MOVE

Stage count register manipulation: STAGE_RST, STAGE_INC and STAGE_DEC

The ALU instruction, which has one OpCode, can perform various different arithmetic and logic operations, depending on the setting of the instruction’s bits [27:21] accordingly.

30.4.1.1

Operations Among Registers

 

 

 

 

 

 

31

28

27

25

24

21

 

5

4

3

2

1

0

 

 

 

 

 

 

 

 

 

 

 

4’d7

3’b0

ALU_sel

 

Rsrc2Rsrc1

Rdst

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Figure 30­3. Instruction Type — ALU for Operations Among Registers

When bits [27:25] of the instruction in Figure 30-3 are set to 3’b0, ALU performs operations, using the ULP coprocessor register R[0-3]. The types of operations depend on the setting of the instruction’s bits [24:21] presented in Table 30-1.

Operand

Description - see Figure 30-3

ALU_sel

Type of ALU operation

Rdst

Register R[0-3], destination

Rsrc1

Register R[0-3], source

Rsrc2

Register R[0-3], source

ALU_sel

Instruction

Operation

Description

0

ADD

Rdst = Rsrc1 + Rsrc2

Add to register

1

SUB

Rdst = Rsrc1 - Rsrc2

Subtract from register

2

AND

Rdst = Rsrc1 & Rsrc2

Bitwise logical AND of two operands

3

OR

Rdst = Rsrc1 | Rsrc2

Bitwise logical OR of two operands

4

MOVE

Rdst = Rsrc1

Move to register

5

LSH

Rdst = Rsrc1 << Rsrc2

Bit shifting Left

6

RSH

Rdst = Rsrc1 >> Rsrc2

Bit shifting Right

Table 30­1. ALU Operations Among Registers

Note:

ADD/SUB operations can be used to set/clear the overflow flag in ALU.

All ALU operations can be used to set/clear the zero flag in ALU.

Espressif Systems

658

ESP32 TRM (Version 5.0)

Submit Documentation Feedback

30 ULP Coprocessor (ULP)

30.4.1.2 Operations with Immediate Value

31

28

27

25

24

21

19

4

3

2

1

0

4’d7

 

3’b1

ALU_sel

 

 

Imm

Rsrc1

Rdst

 

 

 

 

 

 

 

 

 

 

 

 

 

Figure 30­4. Instruction Type — ALU for Operations with Immediate Value

When bits [27:25] of the instruction in Figure 30-4 are set to 3’b1, ALU performs operations, using register R[0-3] and the immediate value stored in [19:4]. The types of operations depend on the setting of the instruction’s bits [24:21] presented in Table 30-2.

Operand

Description - see Figure 30-4

 

ALU_sel Type of ALU operation

 

 

Rdst

Register R[0-3], destination

 

Rsrc1

Register R[0-3], source

 

 

Imm

16-bit signed value

 

 

 

ALU_sel

Instruction

Operation

Description

 

 

 

 

 

 

0

ADD

Rdst = Rsrc1 + Imm

Add to register

 

1

SUB

Rdst = Rsrc1 - Imm

Subtract from register

 

2

AND

Rdst = Rsrc1 & Imm

Bitwise logical AND of two operands

 

3

OR

Rdst = Rsrc1 | Imm

Bitwise logical OR of two operands

 

4

MOVE

Rdst = Imm

Move to register

 

5

LSH

Rdst = Rsrc1 << Imm

Bit shifting left

 

6

RSH

Rdst = Rsrc1 >> Imm

Bit shifting right

Table 30­2. ALU Operations with Immediate Value

Note:

ADD/SUB operations can be used to set/clear the overflow flag in ALU.

All ALU operations can be used to set/clear the zero flag in ALU.

30.4.1.3 Operations with Stage Count Register

31

28

27

25

24

21

11

4

 

4’d7

 

3’d2

ALU_sel

 

 

Imm

 

 

 

 

 

 

 

 

 

 

 

Figure 30­5. Instruction Type — ALU for Operations with Stage Count Register

ALU is also able to increment/decrement by a given value, or reset the 8-bit register Stage_cnt. To do so, bits [27:25] of instruction in Figure 30-5 should be set to 3’b2. The type of operation depends on the setting of the instruction’s bits [24:21] presented in Table 30-3. The Stage_cnt is a separate register and is not a part of the instruction in Figure 30-5.

Operand

Description - see Figure 30-5

 

 

ALU_sel

Type of ALU operation

 

 

Stage_cnt

Stage count register, a separate register [7:0] used to store variables, such as loop index

Imm

8-bit value

 

 

Espressif Systems

659

ESP32 TRM (Version 5.0)

Submit Documentation Feedback

30 ULP Coprocessor (ULP)

ALU_sel

Instruction

Operation

Description

0

STAGE_INC

Stage_cnt = Stage_cnt + Imm

Increment stage count register

1

STAGE_DEC

Stage_cnt = Stage_cnt - Imm

Decrement stage count register

2

STAGE_RST

Stage_cnt = 0

Reset stage count register

Table 30­3. ALU Operations with Stage Count Register

30.4.2 ST – Store Data in Memory

31

28

27

25

 

20

10

 

3

2

1

0

 

 

4’d6

3’b100

4’b0

 

Offset

 

6’b0

Rdst

Rsrc

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Figure 30­6. Instruction Type — ST

 

 

 

 

Operand

Description - see Figure 30-6

 

 

 

 

 

 

Offset

10-bit signed value, offset expressed in 32-bit words

 

 

 

 

 

 

Rsrc

Register R[0-3], 16-bit value to store

 

 

 

 

 

 

Rdst

Register R[0-3], address of the destination, expressed in 32-bit words

 

 

 

 

Description

The instruction stores the 16-bit value of Rsrc in the lower half-word of memory with address Rdst + Offset. The upper half-word is written with the current program counter (PC) (expressed in words and shifted to the left by 5 bits) OR’d with Rdst (0..3):

Mem [ Rdst + Offset ]{31:0} = {PC[10:0], 3’b0, Rdst, Rsrc[15:0]}

The application can use the higher 16 bits to determine which instruction in the ULP program has written any particular word into memory.

Note:

This instruction can only access 32-bit memory words.

Data from Rsrc is always stored in the lower 16 bits of a memory word. Differently put, it is not possible to store Rsrc in the upper 16 bits of memory.

The ”Mem” written is the RTC_SLOW_MEM memory. Address 0, as seen by the ULP coprocessor, corresponds to address 0x50000000, as seen by the main CPUs.

30.4.3 LD – Load Data from Memory

31

28

20

10

 

3

2

1

0

 

 

 

4’d13

 

 

Offset

 

 

Rsrc

Rdst

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Figure 30­7. Instruction Type — LD

 

 

 

 

 

 

Operand

Description - see Figure 30-7

 

 

 

 

 

 

 

 

Offset

10-bit signed value, offset expressed in 32-bit words

 

 

 

 

 

 

Rsrc

Register R[0-3], address of destination memory, expressed in 32-bit words

 

 

 

 

Rdst

Register R[0-3], destination

 

 

 

 

 

 

 

 

Description

 

 

 

 

 

 

 

 

 

 

Espressif Systems

 

 

660

 

ESP32 TRM (Version 5.0)

Submit Documentation Feedback

Соседние файлы в папке даташиты