閱讀Cortex-A53 Technical Reference Manual筆記


1. 前言

一顆芯片最主要的就是CPU核了,處理CPU Core之外,還存在很多其他IP,包括Graphical、Multimedia、Memory Controller、USB Controller等等。

ARM products列出了主要產品,其中ArchitectureProcessors需要重點關注。

Architecture擴展的四大領域:

  • Security Extensions (TrustZone technology)------------安全技術
  • Advanced SIMD (NEON technology)---------------------Single Instruction Multiple Data,單指令多數據流技術
  • Virtualization Extensions, introduced in Armv7-A.------虛擬化技術
  • Cryptographic Extensions, introduced in Armv8-A.-----

更具不同的應用場景將處理器分為三大配置:

 

同樣也有對應的A、R、M三大類處理器:

Cortex-ACortex-RCortex-M,重點看Cortex-A系列:Cortex-A75Cortex-A73Cortex-A72Cortex-A57Cortex-A55Cortex-A53Cortex-A35Cortex-A32Cortex-A17Cortex-A15Cortex-A9Cortex-A8Cortex-A7Cortex-A5

其他還包括Corelink、GIC、MMU、DMA、L2 Cache、Memory、IO。

2. Cortex-A53處理器技術參考手冊(ARM Cortex-A53 Processor Technical Reference Manual)

官方文檔位置:https://developer.arm.com/docs/ddi0500/latest/preface

 本書閱讀筆記目錄如下: 

2 Functional Description

3 Programmers Model

5 Memory Management Unit

6 Level 1 Memory System

7 Level 2 Memory System

9 Generic Interrupt Controller CPU Interface

10 Generic Timer

12 Performance Monitor Unit

 

2 Functional Description

2.1 About the Cortex-A53 processor functions

Cortex-A53處理的的框架圖:

 

Core[n]包括 

2.2 Interfaces

2.3 Clocking and resets

2.3.1 Clocks

整個A53處理器公用一個時鍾輸入CLKIN,所有核和SCU使用CLKIN分發的時鍾。

CLKIN經過一些使能信號轉換成不同頻率的時鍾,有的CLKIN:XXX頻比是3:1,有的是1:1。

PCLKENDBG-->PCLK

ACLKENM-->ACLKM

ACLKENS-->ACLKS

SCLKEN-->SCLK

ATCLKEN-->ATCLK

CNTCLKEN-->CNTCLK

2.3.2 Input synchronization

A53包含以下5個低有效復位信號“

nCPUPORESET[CN:0] 

nCORERESET[CN:0] 

nPRESETDBG

nL2RESET

nMBISTRESET  

這5種復位信號產生多種如下組合:

 

2.4 Power management

從Figure 2-1框架圖中可以看出Core<n>包括L1 Cache、FPU、NEON、Crypto、Debug and trace等。核間公用的包括L2 cache、SCU等。

將其划分為四個Power Domain如下:

Power Domain Description More
PDCORTEXA53

This includes the SCU, the optional L2 cache controller, and debug registers described as being in the
debug domain.

此電源域應該是包括SCU、L2 cache除了RAM部分和debug。
PDL2 This includes the L2 data RAM, L2 tag RAM, L2 victim RAM, and the SCU duplicate tag RAM. 主要是L2 cache和SCU里面的RAM部分。
PDCPU<n>

This includes the optional Advanced SIMD and floating-point Extension, the L1 TLB, L1 processor
RAMs, and debug registers described as being in the processor domain.

此部分是單獨Core內部的。
PDCPUADVSIMD<n> This represents the Advanced SIMD and floating-point block of core n. 僅包括某個Core內部的Advanced SIMD和FPU。

下圖每種顏色對應一種電源域,可以看出哪些器件在上面四中電源域中的一種。

 

2.4.2 Power Modes

在上面介紹了四種電源域,這四種電源域可以單獨被打開或者關閉。但並不是所有的組合都是合法或有效的。

每個電源域至此后的狀態有:

那么芯片支持哪幾種組合的狀態呢?分為兩大類:處理器支持的功耗狀態和核支持的功耗狀態,其中核支持的功耗狀態在核間是獨立的。

處理器功耗狀態:

Processor off所有的電源域都關閉’

L2 Cache Dormance Mode只有PDL2處於On/Ret狀態。

其他都是Processor On,然后L2和Core的不同組合。

核的工作狀態除了Core off,必須要在PDCORTEXA53 On和PDL2 On/Ret轉改下才有意義。

基於上面的處理器功耗狀態和核功耗狀態的組合,有下面的功耗模式。

Normal state

處理器所有功能都可用,A53通過門控時鍾和門控來關閉未用功能塊。

Standby state(P42)

Standby state還包括三種情況Core WFI、Core WFE和L2 WFI。

Core WFI:通過關閉核中大部分時鍾但保持核供電以進入低功耗模式。軟件通過執行WFI指令使核進入WFI低功耗模式。

  WFI退出條件:a reset、

Core WFE:也是通過關閉核中大部分時鍾但保留核供電來達到省電,只是觸發的方式不一樣。軟件可以通過執行WFE指令使核進入低功耗模式。

  WFE退出條件:A L2 snoop request that must be serviced by the core L1 data cache

          A cache or TLB maintenance operation that must be serviced by the core L1 icache/dcache/TLB/

          An APB access to the debug or trace registers residing in the core power domain

L2 WFI:在所有核都進入WFI低功耗狀態是,共用的L2也可以進入WFI低功耗狀態。

  L2 WFI退出條件:A physical IRQ or FIQ

          A debug event

          Powerup or Warm reset

Individual core shutdown mode

里面詳細介紹了Power down、Power up一個核的流程。

Cluster shutdown mode without system driven L2 flush

 

Cluster shutdown mode with system driven L2 flush

 

Dormant mode

Dormant模式是Cluster級別的,所有的Core和L2控制邏輯都被關閉,只有L2 cache RAM處於Power up或者retain狀態。

L2 cache RAM包括:L2 tag RAM、L2 data RAM和L2 victim RAM。

Retention state

 

 2.4.4 Communication to the Power Management Controller

A53和系統電源管理控制器之間的通信有兩種方式:分別是Core WFI、L2 WFI和Q-Channel。

STANDBYWFI[n]表示某個核處於idle和低功耗模式,電源管理控制器可以將此核的供電移除。

但是STANDBYWFIL2在所有核和L2都處於idle和低功耗模式才會觸發。

Q-Channel是一個管理設備接口時鍾和電源的控制器。

3 Programmers Model

3.1 About the programmers model

Exception levels:從EL0到EL3

指令集:AArch64執行態A64指令集,AArch32執行態T32和A32指令集。

還可能包含Advanced SIMD、FPU,Cryptography。

5 Memory Management Unit

5.1 About the MMU

TLB:Translation Lookaside Buffer

Cortex-A53支持兩種架構AArch32(LPAE和Virtualization Extension兩種地址轉換)AArch64(Long Descriptor Format地址轉換)

MMU將虛擬地址轉換成物理地址,MMU提供一組虛擬地址轉物理地址映射以及也表中內存屬性來控制存儲系統。

當地址被存取時,這些數據被加載到TLB中。

 

5.2 TLB organization

IPA:Intermediate Physical Address。

Micro TLB是轉換表信息的第一層緩存,在每個指令或者數據側都有一個。

Main TLB處理Micro TLB沒命中的存取,它是512-entry、4-way、set-associative結構。

IPA cache RAM:保存IPA到Physical Address的映射。

 

5.3 TLB match process

每個TLB包含一個VA、block size、PA以及類似存儲類型/存取權限的屬性。

 

 

6 Level 1 Memory System

6.1 About the L1 memory system

 L1包含獨立的指令和數據cache,並且大小可以獨立配置,8KB、16KB、32KB或64KB。

6.4 L1 Instruction memory system

L1指令cache負責提供指令流到DPU,為了提高性能和降低功耗,包括兩個功能:

  • 動態分支預測
  • 指令緩存

程序流程預測主要包括三類:Predicted and non-predicted instructions、T32 state conditional branches、Return stack predictions。

6.5 L1 Data memory system

L1數據cache是物理尋址的cache,內部的TLB在訪問cache之前就將虛擬地址轉化成物理地址。

6.6 Data prefectching

 

7 Level 2 Memory System

7.1 About the L2 memory system

L2存儲系統主要包括SCU(Snoop Control Unit)和L2 Cache。

SCU連接到Cluster中的四個核,SCU中同時保存了L1數據的備份。

L2存儲系統通過AMBA 4 ACE或者AMBA 5 CHI總線和外部存儲器連接,總線寬度128bit。

 

L2 cache大小有128KB、256KB、512KB、1MB。2MB。

 

7.2 Snoop Control Unit

SCP用戶維護A53的核間L1數據一致性。

9 Generic Interrupt Controller CPU Interface

此部分只是關於GIC CPU Interface的概要介紹,GIC的實現細節有專門的技術參考手冊介紹。

GIC CPU Interface與GIC接口,是CPU與GIC的橋梁。GIC CPU Interface和對應的GIC需要符合同樣的規范,比如GICv2、GICv3、GICv4。

9.1 About the GIC CPU Interface

GIC CPU接口和外部中斷分發器件集成提供了整個Cluster支持和管理中斷的資源。

GIC CPU接口提供了管理中斷源、中斷行為、中斷路由到一個或多個核的寄存器。

A53處理器GIC CPU接口實現了GICv4規范,並且和GICv3或GICv4中斷分發器件接口。

GICv4架構提供如下功能:

•Two security states.
•Interrupt virtualization.
• Software-generated Interrupts (SGIs).
•Message Based Interrupts.
•System register access.
•Memory-mapped register access.
•Interrupt masking and prioritization.
•Cluster environments, including systems that contain more than eight cores.
•Wake-up events in power management environments.

 

在復位時將GICCDISABLE拉高,可以將GIC CPU接口關閉。

9.2 GIC programmers model

主要介紹GIC CPU接口相關寄存器,主要包括三部分:CPU Interface、Virtual Interface Control、Virtual CPU Interface。

每個CPU Interface模塊在芯片內部提供A53和GIC分發器的接口。

Virtual Interface Control寄存器提供對A53處理器上軟件配置,使其只被Hypervisor可見。

Virtual CPU Interface將虛擬中斷轉發到A53處理器,也遵守普通的GIC處理和優先級規則。

GIC相關閱讀 - 《閱讀GIC-500 Technical Reference Manual筆記

10 Generic Timer

更詳細的描述在ARMv8架構參考手冊的G6: AArch32 System Register Descriptions

10.1 About the Generic Timer

Generic Timer根據計數遞增值產生event和觸發中斷。

10.2 Generic Timer functional description

A53 cluster中每個核都有一系列timer相關寄存器:EL1 Non-secure physical timer、EL1 Secure physical timer、EL2 physical timer、Virtual Timer。

A53處理器內部並不包含system counter,system counter在SoC中。

A53處理器通過CNTVALUEB[63:0]來讀取system counter的值,CNTCLKEN作為CNTVALUEB時鍾的使能信號。

10.3 Generic Timer register summary

每個核內部都有一組Generic Timer寄存器,這些寄存器有根據32位和64位架構不同分為兩類。

12 Performance Monitor Unit

A53的performance monitor版本是PMUv3,enable you to gather various statistics on the operation of the processor and its memory system during runtime。

PMU包括6個counters,每個counter可以對任何一種時間計數。

12.2 PMU functional description

Event interface從各種外部單元接收事件,Counters對各種事件進行計數。通過PMU register可以對PMU各種行為進行配置,對這些寄存器的配置可以通過APB接口等。

12.5 AArch32 PMU register summary

32位架構下可以通過MCR/MRC指令獲取執行狀態,64位對應MCRR/MRRC。

下面是PMU寄存器列表,更詳細的描述在12.6 AArch32 PMU register descriptions。 

12.9 Events

在對PMU基本架構和寄存器有了了解過后,再來看看都有哪些事件?

Table 12-28  PMU events給出了事件列表,主要包括L1 I、L1 D、L2 D、Exception、Branch、Bus等等。

這些事件只有在事件優化中實踐一次,估計才能有具體感受。在此做個記錄,知道PMU可以統計那些事件。

12.10 Interrupts

PMU產生中斷然后通過觸發nPMUIRQ輸出。

12.11 Exporting PMU events

PMU事件有兩個外部接口,一個是通過PMUEVENT,另一個是通過ETM trace。

通過Figure-14 Debug system components可以看出:

在PMU Events一節可以看出不同事件是否可以輸出到PMUEVENT/Trace,以及其編號。

 如何使用PMU進行性能調優呢?

 

1.Disable performance counters
2.Set what each event counter will count
3.Set cycle counter tick rate
4.Reset performance counters
5.Enable performance counters
6.Call function to profile
7.Disable performance counters
8.Read out performance counters
9.Check that performance counters did not overflow

 

 

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM