title: Combinational loop in a program
body: <p>There is a error in the program and I'm sure it's caused by <code>negedge iChang</code> in the always block. The error is:</p>
  
  <blockquote>
    <p>Zero-time oscillation in node....... Check the design or vector source file for combinational loop. </p>
  </blockquote>
  
  <p>My partial program is as follow:</p>
  
  <pre><code>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&lt;=state1;
                          A&lt;=3'b0;
                          B&lt;=3'b0;
                          count1&lt;=3'd4;
                          count2&lt;=3'd2;
                          count3&lt;=3'd3;
                          count4&lt;=3'd2;
                          temp&lt;=1'b1;
                      end
                  else
                      begin
                          if(temp==1)
                              begin
                                  temp&lt;=1'b0;
                                  case(s1)
                                      state1:
                                          begin
                                              times&lt;=count1;
                                              A&lt;=3'b001;
                                              B&lt;=3'b100;
                                              s1&lt;=state2;
                                          end
                                      state2:
                                          begin
                                              times&lt;=count2;
                                              A&lt;=3'b010;
                                              B&lt;=3'b100;
                                              s1&lt;=state3;             
                                          end
                                      state3:
                                          begin
                                              times&lt;=count3;
                                              A&lt;=3'b100;
                                              B&lt;=3'b001;
                                              s1&lt;=state4;
  
                                          end
                                      state4:
                                          begin
                                              times&lt;=count4;
                                              A&lt;=3'b100;
                                              B&lt;=3'b010;
                                              s1&lt;=state1;
                                          end
                                      default:
                                          begin
                                              A&lt;=3'b000;
                                              B&lt;=3'b000;
                                          end
                                      endcase
                              end     
  </code></pre>
  
  <p>If I remove <code>negedge iChang</code> in the <code>always</code> block and the <code>if(!iChang)</code> block ,there will be no error. I don't understand the relation between the <code>negedge iChang</code> and the combination loop. It seemed that there is no feedback can cause combination loop.</p>