creep 发表于 2016-12-9 21:51:18

【F769IDISCOVERY评测】STM32F7 系列系统架构和性能

    STM32F7xx(STM32官网) 除了一些新增加的外设之外其M7内核也和我们之前接触较多的M3/M4有很大的区别,为了更好的使用F7系列发挥其最大的性能,我们首先要尽可能的了解其M7内核架构。ST官方有个扩展包专门用于测试对比各种架构下性能,下面就简单了解下Cortex-M7内核然后通过测试FFT运算看下不同的配置的性能差别。

   STM32F7 系列器件是首款基于 ARM® Cortex®-M7 的 32 位微控制器。利用 ST 的 ART 加速器 ™ 和 L1 缓存的优势, F7 系列器件实现了 Cortex®-M7 的最大理论性能。基准测试分数稳步达到了 1082 CoreMark 和 462 DMIPS,无论代码是通过嵌入式 Flash 存储器执行,还是通过内部 RAM 或者外部存储器 (SRAM、 SDRAM 或者 Quad SPI Flash 存储器 ) 执行。STM32F7 系列器件的高性能源自:• 强力的超标量流水线和 DSP 性能提供了一个具有低中断时延的快速实时响应• 对大容量外部存储的高效访问• 适合复杂计算的高性能浮点运算能力
1、Cortex®-M7 内核
STM32F7 系列器件基于高性能的 ARM® Cortex®-M7 32 位 RISC 内核,工作频率高达 216MHz。 Cortex®-M7 内核带有高性能单 / 双精度浮点运算单元 (ARM),支持单 / 双精度数据处理指令和数据类型。它还具有一整套 DSP 指令和提高应用安全性的一个存储器保护单元(MPU)。 Cortex®-M4 到 Cortex®-M7 的向上兼容性允许为 Cortex®-M4 编译的二进制数直接在 ®-M7 上运行。
Cortex®-M7 的特性是具有分支预测和双指令执行的 6/7- 级超标量流水线。分支预测允许分支解析以预测下一个分支,因此将循环消耗的周期数从每个循环 4~3 个周期减少为 1 个周期。双指令的特征是允许内核同时执行两条指令,并且与指令的顺序无关,由此来增加指令吞吐率。
2、Cortex®-M7 系统缓存
STM32F7 集成了 Cortex®-M7,其特点是具有 1 级缓存 (L1- 缓存),该缓存分为两个缓
存:数据缓存 (D- 缓存)和指令缓存 (I- 缓存),这样可以实现具有最佳性能的哈佛架构。
这些缓存使得即使在高频率下也可以达到零等待状态。
默认情况下,指令和数据缓存是禁用的。
ARM CMSIS 库提供了两个使能数据和指令缓存的函数:
• SCB_EnableICache() 用于使能指令缓存
• SCB_EnableDCache() 用于使能数据缓存
更多关于怎样使能和停用缓存的信息,请参考 “ARMv7-M 架构参考手册 ”。
STM32F76xxx 和 STM32F77xxx 器件有各 16KB 大小的指令缓存和数据缓存。
3、Cortex®-M7 总线接口Cortex®-M7 具有五个接口: AXIM、 ITCM、 DTCM、 AHBS 和 AHBP。a)AXI 作为高级可扩展接口。 Cortex®-M7 实现了 AXIM AMBA4,它是一个 64 位宽的接口,用以获得更大取指和数据加载带宽。b)TCM接口作为紧密耦合的 TCM 存储器用来提供内核到内部 RAM 存储器的连接。 c)TCM 接口具有哈佛架构,因此这里有一个 ITCM (指令 TCM)和 DTCM (数据 TCM)接口。d) ITCM 是一个 64位的存储接口,而 DTCM 分为两个 32 位端口: D0TCM 和 D1TCM。Cortex®-M7 AHBS (AHB 从设备)是一个 32 位宽接口,可以提供系统到 ITCM、 D1TCM和 D0TCM 的访问。e)AHBP 接口 (AHB 外设)是一个单独的 32 位宽的接口,专门用于 CPU 和外设的连接。它只用于数据访问。取指令从不在该接口上进行。在 STM32F7 架构中,这条总线连接Cortex-M7 内核的 AHBP 外设总线到 AHB 总线矩阵。该总线连接到 AHB1 、AHB2、 APB1和 APB2 外设。
4、STM32F7 总线矩阵
STM32F7 系列器件的特征是具有一个 216 MHz 的总线矩阵,该总线矩阵实现内核、主设备和从设备的互连。该总线矩阵允许内核、主设备和从设备之间的多个并行访问路径存在,即使当几个高速外设同时工作时,也可以实现并发访问和高效运行。 CPU 和它的总线矩阵可以工作在同样的频率,即 216 MHz。一个内部的仲裁器解决了总线矩阵上的冲突和主设备的总线并发访问。仲裁器采用轮询调度算法。
5、内部存储器STM32F769内部 Flash 存储器具有 256/128 位宽的数据读出。可以通过三个主要的接口来进行读或 / 和写访问。1)64 位 ITCM 接口2)64 位 AHB 接口3)32 位 AHB 接口.
内部RAM可以通过四个块1)DTCM-RAM 2)ITCM-RAM 3)SRAM14)SRAM2
除此之外STM32F7还可以通过SDMMC/USB/FMC/Qual SPI进行扩展。6、性能测试
    测试使用 FFT 计算,它受益于 Cortex-M7 的浮点单元,并且包括多个循环、数据载入 / 存储,可以在不同的路径 / 存储空间完成。代码可以从内部或者外部存储执行。包括使用复杂 FFT 算法,复数幅度计算和最大值函数计算输入信号在频域的最大频率点。它使用FFT 1024 点,计算基于单精度浮点。输入信号是一个 10 KHz 的混有白噪声的正弦波。mian函数如下<font face="微软雅黑" size="3">int main(void)
{
arm_status status;
float32_t maxValue;

      /* Initialize the system: Clocks, Cache etc .. */
system_init();
      
/* Init printf target*/
Printf_Init();

/* Print the system configuration of the current project configuration */
Print_config();

/* Count the cycle number consumed by systick handler (it's counted only when a systick overflow occurs) */
TimerCount_Start();
SysTick_Handler();
TimerCount_Stop(cycles_systick_interrupt);

uwTick = 0;
      
/* SysTick Initialization */
TimerCount_Start();

status = ARM_MATH_SUCCESS;

/* Process the data through the CFFT/CIFFT module */
arm_cfft_f32(&arm_cfft_sR_f32_len1024, testInput_f32_10khz, ifftFlag, doBitReverse);

/* Process the data through the Complex Magnitude Module for
calculating the magnitude at each bin */
arm_cmplx_mag_f32(testInput_f32_10khz, testOutput, fftSize);

/* Calculates maxValue and returns corresponding BIN value */
arm_max_f32(testOutput, fftSize, &maxValue, &testIndex);

/* SysTick Stop */
TimerCount_Stop(cycles);

/* Compute the number of cycles consumed by the FFT algorithm */
/* 0x1000000 -> systick is 24-bit counter */
cycles_result = (uint64_t)(0x1000000-cycles_systick_interrupt)*uwTick + (uint64_t)cycles;   

/* Display the results on the given target: LCD-TFT, Hyperterminal or IDE-viewer */
printf("- Systick interrupt cycles = %lu\n\r- Total number of cycles = %lu\n\r",cycles_systick_interrupt,cycles_result);
      
if(testIndex !=refIndex)
{
    status = ARM_MATH_TEST_FAILURE;
}
      
printf("maxValue = %f status = %d\n\r",maxValue,status);
      </font>测试代码通过加载不同的Scatter文件来进行不同的配置分散加载文件格式如下,具体使用方法参考帖子后面的附件 《mdk_armlink_user_guide.pdf》第七章 Scatter-loading Features <font face="微软雅黑" size="3">; *************************************************************
; *** Scatter-Loading Description File generated by uVision ***
; *************************************************************

LR_FLASHTCM   0x00200000 0x00200000{   ; load region size_region
ER_FLASHTCM0x00200000 0x00200000{; load address = execution address
   *.o (RESET, +First)
   *(InRoot$Sections)
   ; Place all remained code and const data in Flach TCM.
   .ANY (+RO)
}
; Execute main in the RAM_ITCM (16k)
;   NOTE: if Keil finds that the load region (LR_XXX) value settled by the user is different from
;execute region (ER_YYY) value it generates a little routine that copy the code from load region
;to Execute region and then allows the CPU to jump to the new region to execute the code (it jumps to
;execute region address). Here the load region is 0x00200000 (internal flash throgh TCM ) and the
;execute region is 0x00000000 (internal RAM: RAM-ITCM).
ER_RAMITCM 0x00000000 0x4000{
      main.o (+RO-CODE)
    arm_bitreversal2.o (+RO-CODE)
    arm_cfft_f32.o (+RO-CODE)
    arm_cfft_radix8_f32.o (+RO-CODE)
    arm_cmplx_mag_f32.o (+RO-CODE)
    arm_max_f32.o(+RO-CODE)
      
    ; Place also const data in RAM-ITCM. Note that the files arm_bitreversal2_keil.c,
      ; arm_cfft_f32.c, arm_cfft_radix8_f32.c, arm_cmplx_mag_f32.c and arm_max_f32.c don't
    ; contain const data.
      main.o (+RO-DATA)
    arm_common_tables.o (+RO-DATA)
    arm_const_structs.o (+RO-DATA)
}

RAMDTCM_RW_ZI0x200000000x4000{ ; The RW and Zero Initialized data will be in DTCM (0x4000 = 16k)
    .ANY (+RW +ZI)               ; All global variables will be located in this section.
}
   
RAMDTCM_STACK0x200040000x4000{ ; The Stack of the main application will be in DTCM (0x4000 = 16k)
    .ANY (STACK)                   ; All internal variables of called functions will be located in this region.
}                              ; Note that the size of this region (in this case 0x4000) should be greater
                                 ; than or equal to the Stack size defined in "Option for target" menu
                                                                   ; -> "Asm" tab -> "Define" field: STACK_SIZE_APPLICATION=
                                                                   ; Note also that the size of the region RAM_STACK is not considered as the
                                                                   ; stack size of the main application, that's why the stack size is defined
                                                                   ; in Asm menu. STACK_SIZE_APPLICATION can be modified to fit the need of your
                                                                   ; application.

RAMDTCM_HEAP   0x200080000x18000{ ; The Heap of the main application will be in DTCM (0x18000 = 96k)
    .ANY (HEAP)                  ; All dynamic allocations data got by malloc, realloc, calloc... will be located         
}                              ; in this region. Note that the size of this region (in this case 0x18000) should
}                                  ; be greater than or equal to the Heap size defined in "Option for target" menu
                                 ; -> "Asm" tab -> "Define" field: HEAP_SIZE_APPLICATION=
                                                                   ; Note also that the size of the region RAM_HEAP is not considered as the
                                                                   ; heap size of the main application, that's why the heap size is defined
                                                                   ; in Asm menu. HEAP_SIZE_APPLICATION can be modified to fit the need of your
                                                                   ; application.
</font>分散加载文件可以在下面的设置中打开编辑

1)FlashITCM_rwRAM-DTCM:程序从 FLASH-ITCM 执行有 7 个等待周期, ART 和 ART预取使能并且数据载入 / 存储在 DTCM-RAM ,测试结果如下


2)FlashITCM_rwSRAM1




3)FlashAXI_rwRAM-DTCM




4)FlashAXI_rwSRAM1




5)RamITCM_rwRAM-DTCM




在官方的测试中还加入了QualSPI和SDRAM,总的结果如下:





      由于内核功能复杂,上面的测试只是简单的进行FFT运算下最优的配置对比。 扩展包文档中还详细的分析了各种配置的得出测试结果原因并给出了合理使用的建议,另外还进行了DMA模式下的对比。对于每一个使用F7的都应该仔细的参考下官方的这个扩展包中的文档和测试代码,这对于我们充分了解掌握并充分利用STM32F7XX的性能是必不可少的。


测试代码:

参考文档:






官方连接:STM32F7 performance software expansion for STM32Cube

wolfgang2015 发表于 2016-12-9 22:33:23

不错,支持

creep 发表于 2016-12-9 22:46:05

wolfgang2015 发表于 2016-12-9 22:33
不错,支持

感谢大神打赏!:)
还好今晚社区网站没有像昨天那样402挂掉,要不又白忙活了,昨晚已经杯具了一次了。

netlhx 发表于 2016-12-9 22:51:48

好贴,必顶

Paderboy 发表于 2016-12-9 22:52:53

赞,咱来学习了。。。

leo121_3006061 发表于 2016-12-10 00:05:25

谢谢分享,很详细:)

jackten 发表于 2016-12-10 00:28:22

谢谢分享                        

peter001 发表于 2016-12-10 02:05:45

学习了:lol

斜阳__ 发表于 2016-12-10 09:24:42

橙子的帖子总是这么有技术含量

5265325 发表于 2016-12-10 10:07:31

:lol:lol:lol:lol
页: [1] 2 3
查看完整版本: 【F769IDISCOVERY评测】STM32F7 系列系统架构和性能