verilog code errorneous

Joined
Jan 31, 2009
Messages
2
Reaction score
0
I've got a problem with my Verilog code. The 'always' construct should re-run when either RecButtons, FloorNr or Direction has changed. Still, it runs only once when RecButtons has changed. Can you find a conceptual error here?

-Siim

It doesn't have to be synthetizable
Code:
always
begin
   $display("Starting elevator control function (time %d)", $time);
   if(AutoReset == 1)
   begin
      FloorNr = 0;
      Direction = right;
      RunMotors = 0;
      for(j = 0; j < NUM_FLOORS; j = j + 1)
      begin
         ReleaseButtons[j] = 0;
         DoorsOpen[j] = 0; 
      end
   end
   else
   begin
      if(RecButtons[FloorNr] == 1)
      begin
         DoorsOpen[FloorNr] = 1;
         ReleaseButtons[FloorNr] = 1;
         #50
         ReleaseButtons[FloorNr] = 0;
         DoorsOpen[FloorNr] = 0; 
      end
      if(ButtonsDir == 1)
      begin
         RunMotors = 1;
         #10
         RunMotors = 0;
         if(   Direction[0] == right[0] &&
               Direction[1] == right[1])
            FloorNr = FloorNr + 1;
         else
         if(   Direction[0] == left[0] &&
               Direction[1] == left[1])
            FloorNr = FloorNr - 1;
      end
      else
      begin
         if(ButtonsOtherDir == 1)
         begin
            Direction = OtherDir;
            RunMotors = 1;
            #10
            RunMotors = 0;
            if(   Direction[0] == right[0] &&
                  Direction[1] == right[1])
               FloorNr = FloorNr + 1;
            else
            if(   Direction[0] == left[0] &&
                  Direction[1] == left[1])
               FloorNr = FloorNr - 1;
         end
      end
   end
   @(RecButtons, FloorNr, Direction);
   //@(AutoReset, RecButtons, FloorNr, DoorsOpen, ReleaseButtons,
   //         ButtonsDir, RunMotors, Direction, ButtonsOtherDir, OtherDir);
end
 
Joined
Jan 31, 2009
Messages
2
Reaction score
0
Actually the problem is using "#"-delays in this behavioral model. Does anyone have an idea how to add the delays without using an external clock signal. Any help or comments appreciated!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top