在 Vivado 中进行 FPGA 开发时,如果用到了 IP 核,Vivado 会自动生成 IP 对应的约束文件。例如,如果用到了 MMCM/PLL IP 核,Vivado 会在 IP 核文件夹下生成相应的约束文件,用户就不必对 MMCM/PLL 的输入输出时钟做约束,极大的方便了 FPGA 开发。不过,为了理清 IP 核会生成哪些约束文件以及 IP 核的约束文件与用户定义的约束文件的编译顺序,还是有必要对此做一下总结。
在 Xilinx 官方开发文档:Vivado Design Suite User Guide : Designing with IP (UG896),此文档对此有清楚的说明。
Vivado 中 IP 核会生成哪些约束文件
根据 UG896 中的描述,IP 核会生成如下几种约束文件:
- <ip_name>.xdc
- <ip_name>_clocks.xdc
- <ip_name>_OOC.xdc
- <others>.xdc
(1)<ip_name>.xdc 约束文件,是 IP 核不依赖于外部时钟的约束文件。
(2)<ip_name>_clocks.xdc 约束文件,相对应的,是依赖于外部时钟的约束文件。
Because the top-level clock can come from other constraints, or from other IP with a dependency, any constraints that need those clocks to be defined first should be placed in the
<ip_name>_clocks.xdc
. By default, the Vivado IDE processes the<ip_name>_clocks.xdc
file after user constraints and other IP core XDC files.
(3)大部分 IP 核还会生成<ip_name>_OOC.xdc 约束文件。
Most IP deliver an OOC XDC file as well, (<ip_name>_OOC.xdc). This file contains default top-level definitions for input clocks to the IP. This file is only used in the DCP creation when using the recommended default flow (IP synthesized OOC to the top-level design). When the Vivado Design Suite synthesizes the IP OOC of the top-level design, clocks that are created by the end-user or other IP are not available; consequently, this file is necessary to provide the clock definitions for synthesizing the IP.
The <ip_name>_ooc.xdc is not needed during implementation of the user logic with the IP, because all the netlists are linked together before constraints are applied. At that point a user-created clock or an IP-created clock is available to any IP that requires a clock.
(4)其他约束文件。
Some IP can deliver additional XDC files. This might be because they deliver constraints that are to be used only during synthesis or only during implementation.
(5)对于一个工程而言,还会产生板级的约束文件。
When you create a project that targets a platform board instead of a target part, that board is available during the IP customization letting you specify which connections on the board to use in connecting to the IP. This produces an
<ip_name>_board.xdc
file which containsPACKAGE_PIN
,IOSTANDARD
, and other physical constraints.
如何在 Vivado 中查看约束文件的编译顺序
如果 Vivado 工程中用到了多个约束文件,包括 IP 核约束文件和用户定义的约束文件,如何查看这些约束文件的编译顺序呢?可以通过下面的 tcl 语句来查看。
report_compile_order -constraints
下面是一个实际工程中的例子。
注意红色框中的综合阶段和实现阶段编译的约束文件的不同。
有些 IP 核的约束文件仅在实现阶段编译,例如上面的 design_1_clk_wiz_0_0.xdc,如果工程中用到了 MMCM/PLL 的输出时钟或者衍生时钟,那么在综合阶段就会报出类似
[Vivado 12-4739] set_clock_groups:No valid object(s) found for ‘-group [get_clocks_xxx]
的错误,但是实现阶段就不会。
另外,在 Vivado 的默认设置下,IP 核的约束文件(主要是<ip_name>.xdc)会在用户约束文件之前编译,主要基于下面两点:
- The IP might produce a clock that must be available to the end-user constraints.
- If the IP delivers physical constraints, the end-user can override them if necessary.
如何在 Vivado 中修改约束文件的编译顺序
可根据需要,按照下述方式修改 IP 核约束文件和用户约束文件的编译顺序。
- User XDC set to
EARLY
- IP XDC set to
EARLY
- User XDC set to
NORMAL
(default) - IP XDC set to
LATE
- User XDC set to
LATE
不过,如果没有特殊需求,建议不要更改。
扫码关注尚为网微信公众号
原创文章,作者:sunev,如若转载,请注明出处:https://www.sunev.cn/embedded/1281.html