拉着朋友捡了 ZYNQ 的垃圾,本着拉人入坑的精神,顺带着自己补全一下知识,做一做有关于 ZYNQ 的总结与教程。

以下内容都以 ZYNQ7020/7010 为例。

PS 与 PL

ZYNQ 的亮点就是在普通的 FPGA 中缝上一块处理器。

  • PS (Processing System)
    • 双核 Cortex A9
    • 硬核处理器
  • PL (Programmable Logic)
    • 7系同款 FPGA
      • Artix: ZYNQ 7010 / 7020
      • Kintex: ZYNQ 7030 +++

ZYNQ 7020/7010 中内置了两个 Cortex-A9 处理器,ARMv7-A 架构,其中 ARMv7 是指令集架构(Instruction Set Archtecture,ISA),兼容 Thumb 指令集与 NEON 指令集。

对于 Arm 处理器内部的构造及其不暴露至外部的特殊功能及优化在此不便展开。

PS 互联

PS-Interconnect

网上偷的图,低分辨率不要介意

  • Programmable logic to memory
    • Two ports to DDR
    • One port to OCM SRAM
  • Central interconnect
    • Enables other interconnects to communicate
  • Peripheral master
    • USB, GigE, SDIO connects to DDR and PL via the central interconnect
  • Peripheral slave
    • CPU, DMA, and PL access to IOP peripherals
  • Processing system master
    • Two ports from the processing system to programmable logic
    • Connects the CPU block to common peripherals through the central interconnect
  • Processing system slave
    • Two ports from programmable logic to the processing system

PS Memory Map

PS-MemoryMap

Cortex-A9 32位处理器,所有 PS、PL 外设均映射至地址空间中,其中 PL 外设位于 4000_0000 至 7FFF_FFFF (GP0),8000_0000 至 BFFF_FFFF (GP1)。

PS 启动流程

  1. CPU0 从 OCM ROM 启动,此时 CPU1 处于休眠状态
  2. OCM ROM 中 BROM 启动(Stage 0 Boot)
  3. BROM 根据启动配置(引脚高低电平)从选定设备启动 FSBL(First Stage Boot Loader)
  • NOR
  • NAND
  • Quad-SPI
  • SD Card
  • JTAG

PL 加载

PL 配置在 PS 启动之后,内部 DMA 允许同时进行 PL 配置与操作系统加载。

外设

除了常规 IO 外,ZYNQ 中还有 EMIO 用以连接 PS 与 PL。

PS-PL 交互

AXI high-performance slave ports (HP0-HP3)

位宽可选 32-bit 与 64-bit,只能到 OCM 与 DDR。

AXI general-purpose ports (GP0-GP1)

两个 master 两个 slave,只有 32-bit 位宽。

时钟

PS 时钟源由外部提供,同时 PS 有三个 PLL 生成时钟,PS 可输出四个时钟到 PL。 PL 时钟与 7 系 FPGA 相同,可以使用外部时钟源,除此之外还可以使用 PS 输出的四个时钟源。 但 PL 不能向 PS 提供时钟。

重置

ZYNQ 内部有三个重置源:上电重置、三个看门狗、安全重置。

PS 有两个重置源:外部重置 PS_SRST_B 与热重置 SRSTB,其中外部重置会一起重置 PS 与 PL。

PL 同样有两个重置源:四个 PS 端到 PL 端重置源,FCLK_RESET[3:0]

AXI

AXI 由 ARM 发布,是 AMBA(Advanced Microcontroller Bus Architecture)的一部分。AXI4 总线包括 AXI4、AXI4-Lite、AXI4-Stream。

AXI4

AXI4

可 Burst,最多 256,最高 1024-bits。

AXI4-Lite

AXI4-Lite

不能 Burst,可 32-bits 或 64-bits,占用资源少。

AXI4-Stream

AXI4-Stream

无地址,不用读不用写,一直输出,不限 Burst 长度。

总结

  • ZYNQ 结合 PS 与 PL。
  • AXI 为点对点提供高性能连接
  • PS 与 PL 之间通过 AXI 连接
  • PS 通过外部引脚选择启动设备
  • PL 由 PS 在启动后配置
  • PS 可为 PL 提供时钟