双向播放时出现问题。该项目将创建一个占空比为1:2的时钟。在综合和实施过程中没有问题。我尝试了几种解决方法。但是他们工作得不好。
module clock_div(clk, clk_out);
input clk;
output reg clk_out;
integer count1, count2;
reg clk_div;
always@(posedge clk)
begin
count1 <= count1 + 1;
if(count1 == 16666667)
begin
count1 <= 0;
clk_div <= ~clk_div;
end
end
always@(clk_div)
begin
count2 <= count2 + 1;
if(count2 == 1)
begin
clk_out <= ~clk_out;
end
else if(count2 == 3)
begin
count2 <= 0;
clk_out <= ~clk_out;
end
end
endmodule
vivado给出的信息如下
[DRC 23-20] Rule violation (LUTLP-1) Combinatorial Loop - 231 LUT
cells form a combinatorial loop.
This can create a race condition.
Timing analysis may not be accurate.
The preferred resolution is to modify the design to remove
combinatorial logic loops.
To allow bitstream creation for designs with combinatorial logic loops
(not recommended), use this command: set_property SEVERITY {Warning}
[get_drc_checks LUTLP-1].
NOTE: When using the Vivado Runs infrastructure (e.g. launch_runs Tcl
command), add this command to a .tcl file and add that file as a pre-
hook for write_bitstream step for the implementation run.
clk_out_reg_i_3, clk_out_reg_i_4, clk_out_reg_i_5, clk_out_reg_i_7,
clk_out_reg_i_8, clk_out_reg_i_10, clk_out_reg_i_11, clk_out_reg_i_12,
clk_out_reg_i_13, clk_out_reg_i_14, clk_out_reg_i_15,
clk_out_reg_i_16, clk_out_reg_i_17, clk_out_reg_i_20, clk_out_reg_i_21
(the first 15 of 231 listed).
如果有人可以帮助我,我将不胜感激。
答案 0 :(得分:0)
这是错误的:
/cases
您使用的灵敏度列表不完整。这在仿真和综合之间产生了不匹配。对于您要合成的所有代码,请使用完整的敏感度列表,甚至更容易使用:always@(clk_div) // <<== WRONG!!!!
begin
count2 <= count2 + 1;
if(count2 == 1)
begin
clk_out <= ~clk_out;
end
else if(count2 == 3)
begin
count2 <= 0;
clk_out <= ~clk_out;
end
end
如果在上面的部分中使用它,则会发现您的模拟不再起作用。它将陷入无限循环。这正是该工具抱怨的组合循环。
要解决此问题,您应该将所有代码放在顶部:
always@( * )
问题:
当您除以16666667时,您将不会得到2:1的时钟,而是得到了33333334:1的时钟。
除非您希望在clk_div和clk_out之间使用2:1时钟,否则clk_div不会出现。在这种情况下,请在上面标记的部分中同时设置clk_div和clk_out