基于Altera系列FPGA的PCIE(EP)的实现

2022.07.02:

        PCIE对于高速串行通信领域来说,是一个很常见的名字,最近研究了很久的PCIE资料,完成了从一无所知的小白到稍懂一点的小白的转变。当然PCIE的演变历程悠久,涉及到的知识万万千千,实际工作中,我首先追求的是知识储备够用即可,不去强求精通所有的应用,完全的实用主义者,先搞定0->1。

        对于altera系列FPGA系列的PCIE开发来说,结合当前的系统,我只研究了PCIE的EP端知识及rtl实现,看过的文档很多,最重要的两个文档是:《ug_pci_express.pdf》、《PCI+EXPRESS体系结构导读.pdf》。

一.PCIE的基础知识简要说明:

  1. PCIE使用端对端的连接方式,RX&TX差分对;
  2. PCIE传输速率

单lane传输

Gen

Gen1

Gen2

Gen3

Gbpsx1

2.5Gbps

5Gbps

8Gbps

编码方式

8B/10B

8B/10B

128B/130B

有效带宽x1

2Gbps

4Gbps

7.8Gbps

PCIE可由多lane组成,支持总线位宽类型:x1、x2、x4、x8、x12、x16、x32.

传输带宽:单lane带宽*总线位宽。

        3.PCIE总线结构

  • 物理层:8B/10B,链路训练
  • 数据链路层:数据传输
  • 事务层:接收应用层的数据请求(重点研究对象)
  • 应用层:以Altera为例,采用的接口有两种:(a)Avalon-ST Interface;(b)Alvalon-MM Interface.

二.Altera FPGA PCIE IP Core设计

        Altera PCIE采用的接口有两种:Avalon-ST Interface和Alvalon-MM Interface.

        据说Alvalon-MM Interface设计简单,满足常见应用,适合新手快速上手(俗话说,欲速则不达,心急吃不了热豆腐),我简单研究了一下,没搞好(...尬);后续设计选择采用了Avalon-ST Interface类型,选择一条艰难之路。

1.IP参数设计:

        (1)System settings

         (2)PCI Registers

         

        (3)Capabilities

         (4)Buffer Setup

         (5)Power Management

2.PCIE事务层TLP

TLP格式(通用字段4Byte)

Byte3

Byte2

Byte1

Byte0

7

6

5

4

3

2

1

0

7

6

5

4

3

2

1

0

7

6

5

4

3

2

1

0

7

6

5

4

3

2

1

0

R

Fmt

Type

R

TC

R

TD

EP

Attr

AT

Length

PCIE支持很多种事务,对于一般的应用,只要弄懂memory write和memory

read就足够了,可以做普通的寄存器读写、DMA读写。

3.需要注意的地方

  1. RC端初始化扫描设备,FPGA作为EP端时,需要做什么?

        配置好系统时钟、复位、TX、RX即可。

  1. PCIE IP CORE的reconfig接口部分要级联ALTGX_RECONFIG;
  2. 要注意DMA操作过程中的Tag管理;
  3. Memory操作过程的4K边界处理;
  4. 3DW/4DW的处理。
  • 系统RTL设计

FPGA RTL设计,共4个模块:

        遇到的主要问题,是memory read的completion路由ID时序控制错误,导致RC端出现超时ERROR。

        历经各种问题,各种调试,九九八十一难,终于取得真经,调试成功,终成功应用,很有成就感。作为技术人员来说,技术成就感不就是我们一直追求的东西吗?(虽然很早就有人做完了,但闻道有先后,咱就不妄自菲薄了)

  • 后续展望
  1. 当前中断类型采用的还是常规中断,没有使用MSI中断,有时间再研究一下。
  2. 80%多的DMA读取效率还有待于提高,争取搞到90%。
  3. 对于PCIE这个庞然大物来说,自己依然是一个小白,总觉得自己遇到的问题不够多,研究的不够深,还需要虚心学习、深入研究。
├─reference_design │ ├─vhdl │ │ │ stratix_enh_pll.vhd │ │ │ stratix_top.vhd │ │ │ vhdl_components.vhd │ │ │ │ │ ├─001 ddr_cntrl │ │ │ ddr_top.vhd │ │ │ │ │ ├─004 pci_local │ │ │ backend.vhd │ │ │ cnten.vhd │ │ │ datapath_fifo.vhd │ │ │ dma.vhd │ │ │ dma_reg.vhd │ │ │ dma_sm.vhd │ │ │ fifo_128x32.vhd │ │ │ fifo_128x4.vhd │ │ │ fifo_128x64.vhd │ │ │ last_gen.vhd │ │ │ mstr_cntrl.vhd │ │ │ mstr_fifo_cntrl.vhd │ │ │ mstr_perf.vhd │ │ │ targ_cntrl.vhd │ │ │ targ_fifo_cntrl.vhd │ │ │ targ_perf.vhd │ │ │ │ │ ├─002 ddr_intf │ │ │ adr_gen.vhd │ │ │ clk_sync.vhd │ │ │ cntrl_intf.vhd │ │ │ ddr_intf.vhd │ │ │ mr_sm.vhd │ │ │ mw_sm.vhd │ │ │ tr_sm.vhd │ │ │ tw_sm.vhd │ │ │ │ │ ├─003 flash_cntrl │ │ │ erase_sm.vhd │ │ │ flash_mem_cntrl.vhd │ │ │ read_sm.vhd │ │ │ write_sm.vhd │ │ │ │ │ └─005 pci_mt64 │ │ pci_top.vhd │ │ │ ├─001 sim │ │ │ modelsim.ini │ │ │ sim.do │ │ │ stratix_pci2ddr.mpf │ │ │ stratix_pci2ddr_tb.vhd │ │ │ trgt_tranx_mem_init.dat │ │ │ wave_stratix_pciddr.do │ │ │ │ │ ├─001 altera_lib │ │ │ altera_mf.vhd │ │ │ │ │ ├─002 ddr_dimm │ │ │ ddr_dimm_model.vhd │ │ │ mt46v32m8.vhd │ │ │ │ │ └─003 pci_bfm │ │ arbiter.vhd │ │ clk_gen.vhd │ │ log.vhd │ │ monitor.vhd │ │ mstr_pkg.vhd │ │ mstr_tranx.vhd │ │ pull_up.vhd │ │ trgt_tranx.vhd │ │ │ └─002 syn_1s25 │ stratix_top.csf │ stratix_top.esf │ stratix_top.psf │ stratix_top.quartus │ stratix_top.rbf │ stratix_top.sof │ ├─001 bin │ altera.inf │ megaicon.ico │ StratixPCI.exe │ STRATIX_KIT_APP_HELP.HLP │ wdreg.exe │ windrvr6.inf │ windrvr6.sys │ ├─002 constraints │ mt32_23_ep1s25f1020c5_66_03_04.tcl │ mt64_23_ep1s25f1020c5_66_03_04.tcl │ Stratix_PCI_Board_DDR_settings.tcl │ t32_23_ep1s25f1020c5_66_03_04.tcl │ ├─003 doc │ an223.pdf │ banner.jpg │ ds_StratixPciBd.pdf │ readmeStratixPciKit.htm │ StratixPciKitDocContents.pdf │ ug_StratixPciKit.pdf │ ├─004 max_config │ max_stratix_config.pof │ └─006 software ├─001 driver │ altera_lib.c │ altera_lib.h │ └─002 gui altera.aps altera.clw altera.cpp altera.dsp altera.dsw altera.h altera.ncb altera.odl altera.opt altera.plg altera.rc Altera.rgs alteraDlg.cpp alteraDlg.h alteralogo.bmp CBox.cpp CBox.h Ioctl.h megaicon.ico Meter.cpp Meter.h MonWnd.cpp MonWnd.h resource.h resource.hm StdAfx.cpp StdAfx.h
实现FPGA与DSP之间利用PCIe链路通信,您可以采用FPGA作为EP(End Point)端,DSP作为RC(Root Complex)端的方式。在这个过程中,了解PCIe协议的初始化配置、数据传输和中断等基本知识是很重要的。 对于PCIe实现,您可以参考两个规范文档:第一个规范文档主要关注PCIe配置空间的寄存器,特别是第七章“Software Initialization and Configuration”;第二个规范文档则介绍了PCI协议,因为PCIe与PCI是兼容的,所以这个文档在理解PCIe时也很重要,特别是第六章“Configuration Space”,其中包含了MSI相关的寄存器信息。这些规范文档可以在学校图书馆的中文书籍中找到。 另外,Altera提供了兼容PCIe 1.0和PCIe 2.0的解决方案,您可以使用FPGA内部的可配置硬核IP模块来实现,而不占用可编程资源。Altera的IP编译器可以支持不同通道接口,如×1,×2,×4,×8的通道接口。 最后,了解PCIe的硬件电气规范、协议规范以及相关的应用层系统方案、DMA仲裁、PCIe硬核配置与读写时序等内容对于实现FPGAPCIe接口非常有帮助。 综上所述,为了实现FPGAPCIe接口,您需要了解PCIe协议的初始化配置、数据传输和中断等基本知识,同时参考PCIe规范文档和Altera提供的解决方案。同时,对于硬件电气规范、协议规范以及相关的应用层系统方案、DMA仲裁、PCIe硬核配置与读写时序等内容也需要有所了解。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值