
By HYB,7.7.2013 调用IP核,有两种,一种是从ISE中为工程添加,另一种是使用Core Generator直接生成。两种方法本质上是一样的。
一、ISE工程中添加IP核
建好一个test工程,并添加一个main.v文件。
图1ISE工程
利用IP CORE Generator & Architecture Wizard 添加一个FIFO的CORE:
图2添加IP Core
其保存路径在工程test\\ipcore_dir目录下。这个目下的文件如下图2所示:
图3ipcore_dir目录下的文件此时,生成的IP核还需要例化才能添加到工程中:
图4例化IP Core
二、Core Generator生成IP核
利用Core Generator生成一个IP核,生成的目录和文件如下:
图5Core Generator生成的文件
这里终于得到验证:core generator生成的东西和ISE工程\\ipcore_dir目录下是一样的。
三、总结
可见,两种方法实际上都是有Core Generator生成的,且生成的东西一样,本质上没有差别。不过也有几点说明:
1,在ISE工程中添加IP Core很简洁,实际上最主要的就是使用了core generator生成的.xco文件,见图四。
2,Core Generator还生成了一个IP Core sub-project类型的子工程,可以直接打开子工程以便详细了解语言级的实现,不过有的IP核生成的这个子工程直接打开会有错
误。关于这个子工程找到了比较好的解释:
When you add the .xco file, you are adding an IP core sub-project.
Project Navigator automatically accesses files from the core sub-project during the various flows according to project settings, the flow that is being run, and the designation of files in the IP core sub-project. That is, .xco can be replaced by .v 、.ngc file(其实就是说可用真正的源文件来替换,真正的源文件可以在sub-project中看到).
Typically, a re-declaration error is caused when a second declaration of a module is inadvertently sent to synthesis.
Recently, we've seen an issue with a few IP (including the Fifo) where a XXX_synth.v file was incorrectly generated and added for synthesis and simulation flows. If the file is deleted, the flows complete successfully.按照第一句的说法,.xco也是通过sub-project来真正添加IP的,这就可以解释使用PCIe 的IP核时的情况了。通过ISE添加IP核时,暂未例化的情况如下:
图6ISE添加PCIe核暂未例化
而这个核例化的模板如下,可见需要PCIe模块中的四大类接口(截图只是一部分):
图7PCIe核的例化模板
为了证明.xco例化时确实是IP Core sub-project,为此,打开ISE工程目录下的\\ipcore_dir 子目录中的ipcore_pcie这个sub-project:
图8.xco等价于sub-project中的默认模块
从这里可以看出,.xco例化模板中使用的就是ipcore_pcie这个模块,正是sub-project 默认的这个模块。.xco确实等价于sub-project。
总结就是最好就直接ISE中添加.xco形式的IP Core。当然如果为了看IP核对应的例子,可以自行打开core generator生成的IP Core sub-project。
最后,有的硬核会在sub-project生成.ucf文件,但是作为一个ISE工程,顶层的.ucf文件会屏蔽掉这个IP core专用的ucf。解决办法是拷贝:A UCF file may be generated along with some cores when the core is elaborated. The constraints in the file can be copied and pasted into the UCF file of an ISE® project.
更多内容,参考Xilinx ISE Help关于IP and Cores的描述。
