pci 小结

最近完成了FPGA和桥片的PCI连接,用的是ALTERA CYCLONG III最高级的那个芯片,使用片内的PCIcore。

PCI的通信挺复杂的,连接到总线上的设备可以作为主也可以作为从,通过总线上的仲裁器做出裁断。spec看了好几天,才对PCI有了肤浅的理解。

这个项目中,桥片MV64460有两路PCI,一路接FPGA,另一路接TSI138芯片。FPGA的PCIcore只作为从设备,因此REQn和GNTn没有使用。FPGA已经将外部的借口做好了,只需要我们控制一些local信号就可以了,它的USER GUIDE里有很好的说明。主要看看core的框图,时序图。

其实,只要生成一个PCIcore,主设备就可以找到FPGA的PCI接口了。CPU寻找PCI的设备过程叫做配置读(configuration read),n拉低一个时钟,高位地址线其中的一根且只有一根为高(每个PCI设备的idsel引脚要连接一根高位地址线),同时C/BE送出配置读命令。下一个周期,irdyn拉低,过几个周期之后,如果有设备的idsel连接到了这根地址线,那么就要将devseln拉低。这样,CPU就找到了一个PCI设备,然后PCI还会读取这个PCI设备的头部寄存器,还要设置BAR。

说到BAR,这个还是值得说一说的。BAR=base address register,这个基地址寄存器的第四位是属性位,说明了这一段地址的空间是IO还是MEMORY,是不是可预取的,预取就是不受BE的限制,一下子将32或64位数据全部打出。在FPGA生成PCIcore的时候,这些都是可以设置的。一个BAR是32位的,如果你觉得32位的地址空间不够用,那么可以用2个BAR寻址一段空间。以一个BAR寻址为例,如果希望这一段的空间大小为1MB,也就是2^20,FPGA会自动将BAR0[19:4]拉到GND上,当CPU读BAR0时,收到的数据应该是0xfff00000,或者0xfff00008。高12位是可读写的,CPU会将基地址写到这12位上,这就完成了CPU分配基地址的过程,以后,每当高位地址落到这个区间时,会引起PCI操作。

一个值得注意的问题是,一定要将关键信号外接上拉电阻,比如STOPn,这个引脚可害苦了我了。

├─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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值