为什么我不能在Verilog的“ always”块中将寄存器的内容复制到另一个寄存器中?

时间:2020-08-22 12:51:46

标签: verilog fpga yosys iverilog

好吧,我有这段代码,可以很好地工作:

module syncRX(clk, signal, detect);
    input clk, signal;
    output reg [7:0] detect = 0;
    reg [7:0] delay = 0;
    
    //wire clk_1khz;
    freq_div div(.clk(clk), .clk_1khz(clk_1khz));
    
    always @(posedge signal)
     begin
        detect <= detect + 1;
        delay <= 0;
     end
    
    always @(posedge clk_1khz)
     begin
        delay <= delay + 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

当我更改“检测<=检测+ 1;”行时,出现问题。以“检测<=延迟;”。 目的是计算信号的周期,但是我得到了Icestorm的警告消息: 警告:设计中未找到时钟

FPGA停止工作... 拜托,任何人都知道发生了什么事? 谢谢大家!

通过问题的表决,我可以看到那不是一个好问题,可能是因为社区认为它已经被记录在案,但是我仍然找不到解决问题的方法,所以做了一些改进,我将再次尝试在这里找到帮助,我现在有了这段代码,可以完美地合成:

module syncRX(clk, signal, detect);
    input clk, signal;
    output [7:0] detect;
    
    reg [7:0] detect_aux = 8'b0;
    reg rst;
    assign detect = detect_aux & ~rst;
    
    freq_div div(.clk(clk), .clk_1khz(clk_1khz));
    
    always @(posedge signal)
        rst <= 1;
        
    always @(posedge clk_1khz)
        detect_aux <= detect_aux + 1;
     
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

问题是

    reg rst;
    assign detect = detect_aux & ~rst;

接缝什么也不做。有什么建议吗? 谢谢

1 个答案:

答案 0 :(得分:0)

问题在于my_map = std::make_shared<std::map<int, int, std::function<bool(int,int)>>>(std::greater<int>{}); 是乘驱动的(在综合中不允许从多个Always块驱动),这是未定义的行为(在这种情况下,我相信将使用常量'0')。这也至少应该是警告。

相关问题