0

程序中有一个错误,我确定它是由negedge iChangalways 块引起的。错误是:

节点中的零时振荡......检查组合环的设计或矢量源文件。

我的部分程序如下:

input  clk, rst,iChang;
always@(posedge clk or negedge rst or negedge iChang)
    begin 
        if(!iChang)//auto mode,serious problems!!!!!!!!!!!!!!!!!!
            begin
                if(!rst)
                    begin
                        s1<=state1;
                        A<=3'b0;
                        B<=3'b0;
                        count1<=3'd4;
                        count2<=3'd2;
                        count3<=3'd3;
                        count4<=3'd2;
                        temp<=1'b1;
                    end
                else
                    begin
                        if(temp==1)
                            begin
                                temp<=1'b0;
                                case(s1)
                                    state1:
                                        begin
                                            times<=count1;
                                            A<=3'b001;
                                            B<=3'b100;
                                            s1<=state2;
                                        end
                                    state2:
                                        begin
                                            times<=count2;
                                            A<=3'b010;
                                            B<=3'b100;
                                            s1<=state3;             
                                        end
                                    state3:
                                        begin
                                            times<=count3;
                                            A<=3'b100;
                                            B<=3'b001;
                                            s1<=state4;

                                        end
                                    state4:
                                        begin
                                            times<=count4;
                                            A<=3'b100;
                                            B<=3'b010;
                                            s1<=state1;
                                        end
                                    default:
                                        begin
                                            A<=3'b000;
                                            B<=3'b000;
                                        end
                                    endcase
                            end     

如果我negedge iChangalways块和if(!iChang)块中删除,将不会有错误。我不明白 thenegedge iChang和组合循环之间的关系。似乎没有反馈会导致组合循环。

4

1 回答 1

2

边沿触发的 always 块用于同步逻辑。它应该有一个时钟参考,它可能有一个异步复位,可能有一个异步设置。根据您的代码,它看起来iChang应该被采样posedge clk,所以它不应该在敏感度列表中。我相信您将同步始终块的敏感性列表要求与 IEEE1364-1995 组合始终块的样式混淆了。IEEE1364-1995 样式组合始终块要求所有输入信号都列在灵敏度列表中。(建议使用 IEEE1364-2001 的自动敏感列表 ( @*/ @(*)) 组合 always 块)

假设您想要异步重置,那么您的 always 块应如下所示:

always @(posedge clk or negedge rst) begin 
  if(!rst) begin
    // ... reset code ...
  end
  else if (!iChang) begin
    // ... synchronous code ...
  end
end

如果你真的想iChang防止重置,那么也让重置同步:

always @(posedge clk) begin 
  if (!iChang) begin
    if(!rst) begin
      // ... reset code ...
    end
    else begin
      // ... synchronous code ...
    end
  end
end
于 2014-12-02T17:37:44.897 回答