VIVADO时序约束与优化
一 时序约束的目的
1. 给工具提供电路信息,让工具尽量按照要求的信息布局布线.
1. 出现时序违例,通过约束优化解决.
二 约束分类
时钟约束
set_false_path
异步信号路径
时钟域交叉(CDC)
1
2
3
4
5
6
7
81. CDC 同步器作用
第一级触发器 (sync_ff1):捕获异步输入,可能处于亚稳态
第二级触发器 (sync_ff2):大幅降低亚稳态传播概率
输出 synced_data 已稳定在目标时钟域
明确设计意图:告诉工具这些路径已通过同步器处理,无需优化
# 禁止从源时钟域 clk_src 到目标时钟域 clk_dst 的路径进行时序分析
set_false_path -from [get_clocks clk_src] -to [get_clocks clk_dst]1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51// 源时钟域逻辑
module src_domain (
input wire clk_src,
input wire rstn_src,
input wire [7:0] data_in,
output reg [7:0] src_data
);
// 源时钟域数据生成逻辑
always @(posedge clk_src or negedge rstn_src) begin
if (!rstn_src) src_data <= 8'h0;
else src_data <= data_in;
end
endmodule
// 目标时钟域逻辑
module dst_domain (
input wire clk_dst,
input wire rstn_dst,
input wire [7:0] async_data, // 来自源时钟域的异步信号
output reg [7:0] synced_data
);
// 双触发器同步器
reg [7:0] sync_ff1, sync_ff2;
always @(posedge clk_dst or negedge rstn_dst) begin
if (!rstn_dst) begin
sync_ff1 <= 8'h0;
sync_ff2 <= 8'h0;
synced_data <= 8'h0;
end else begin
sync_ff1 <= async_data; // 第一级同步
sync_ff2 <= sync_ff1; // 第二级同步
synced_data <= sync_ff2; // 同步后的稳定数据
end
end
endmodule
// 顶层连接
module top (
input wire clk_src,
input wire clk_dst,
input wire rstn_src,
input wire rstn_dst,
input wire [7:0] data_in
);
wire [7:0] src_data;
src_domain u_src (.*); // 连接源时钟域
dst_domain u_dst (
.async_data(src_data), // 跨时钟域信号
.* // 其他信号自动连接
);
endmodule非时序关键路径
VIVADO时序约束与优化
http://witbit.cn/FPGA/VIVADO时序约束与优化.html