我有一个"总是";Verilog中的块。首先让我介绍一下代码:
module syncRX(clk, signal, detect, output clk_1khz);
input clk, signal;
output reg [7:0] detect = 0;
//wire clk_1khz;
freq_div div(.clk(clk), .clk_1khz(clk_1khz));
always @(posedge signal, posedge clk_1khz)
begin
detect <= detect + 1;
end
endmodule // top
module freq_div(input clk, output reg clk_1khz);
reg [12:0] count = 0;
always @(posedge clk)
begin
if(count == 6000)
begin
clk_1khz <= ~clk_1khz;
count <= 0;
end
else
count <= count + 1;
end
endmodule
我收到了这个错误消息(使用Icestorm(:
2.3.7.执行PROC_DFF过程(将进程同步转换为FF(。正在为信号
freq_div.clk_1khz' using process
\freq_div创建寄存器$proc$syncRX.v:22$4'。创建$dff cell$procdff$15' with positive edge clock. Creating register for signal
\freq_div。\count"使用具有正边缘时钟的进程freq_div.$proc$syncRX.v:22$4'. created $dff cell
$procdff$16"。正在创建为信号syncRX.detect' using process
\syncRX注册$proc$syncRX.v:8$1'。错误:多个边缘敏感事件找到此信号!make:***[Makefile:44:syncRX.bin]错误1
我可以检测到;总是";涉及的区块是:
always @(posedge signal, posedge clk_1khz)
begin
detect <= detect + 1;
end
因为如果改变";总是@(posedge信号,posedge clk_1khz(";对于";总是@(posedge信号(";作品
同样以同样的方式失败:
always @(posedge signal)
begin
detect <= detect + 1;
end
always @(posedge clk_1khz)
begin
detect <= detect + 1;
end
并且当注释行";检测<=检测+1"在购买的箱子里。然后该错误与访问";"检测";计数器寄存器。我不知道为什么我不能从两个不同的信号触发这个计数器,但事实上,我必须在购买的后边缘信号中增加计数器(我可以在脑海中想出一个非常简单的数字电路来做这件事(,我在Verilog中发现了许多使用";总是";带有两个偏序触发器的块。。。但我的不管用。
请,如果有人能解释我为什么不工作,以及我怎么做。这对我来说非常有用。
我想您可以为每个clk_1khz和信号使用单独的计数器。然后添加它们:
always @(posedge signal)
begin
detect_sig <= detect_sig + 1;
end
always @(posedge clk_1khz)
begin
detect_clk <= detect_clk + 1;
end
assign detect = detect_sig + detect_clk;
不过,@(posedge signal)
在我看来很奇怪。这里除了时钟什么都不要用。所以,检查一下你的算法。
而且,在合成之前,您还应该模拟并验证您的模型。
由于你在另一个问题中问了这个问题,你的第二个变体有两个不同的总是块,也不可合成。它导致detect
信号由多个始终块驱动,并导致合成中的乘法驱动条件。在模拟中,它将导致不确定性的结果。合成应该中断。检查消息。