【发布时间】:2018-07-28 20:04:11
【问题描述】:
我正在用 Verilog 准备一个程序。我在实现一个短脉冲时遇到了问题,该短脉冲每次都会在慢时钟的上升沿出现并在快时钟的上升沿消失。
下面我粘贴我写的代码,它给了我这样一个脉冲,但不幸的是它只在第一个边缘出现一次,并且再也不会出现。
reg cnt_write_bit1, cnt_write_bit2;
initial cnt_write_bit1 = 0;
initial cnt_write_bit2 = 0;
reg cnt_write_fifo;
initial cnt_write_fifo = 0;
always @ (posedge clk_1kHz)
begin : WRITE_FIFO
if (cnt_write_fifo)
begin
cnt_write_bit1 <= 0;
end
else
begin
cnt_write_bit1 <= 1;
end
end
always @ (posedge clk_50MHz)
begin : STOP_WRITE_FIFO
if (cnt_write_fifo)
begin
cnt_write_bit2 <= 0;
end
else //if (!cnt_write_bit1)
begin
cnt_write_bit2 <= 1;
end
end
always @ (cnt_write_bit1, cnt_write_bit2)
begin
if (cnt_write_bit1 && cnt_write_bit2)
begin
cnt_write_fifo <= 1;
end
else if (!cnt_write_bit2)
begin
cnt_write_fifo <= 0;
end
end
“cnt_write_fifo”信号上的脉冲应该在慢时钟的每个上升沿上都可以重复,但不幸的是它不是。
如果有任何帮助,我将不胜感激。
【问题讨论】:
-
最重要的是:慢时钟和快时钟之间有关系吗?如果不是,您必须使用时钟域交叉逻辑。
-
这些时钟之间没有关系。我在输入端有时钟信号。
-
您的豁免表格没有显示慢时钟在第一个边沿之后仍然存在。是吗?
-
对不起,这只是一个剪辑。慢时钟正常工作:)
标签: signals verilog fpga clock pulse