verilog code errorneous

Discussion in 'VHDL' started by funkyrobot, Jan 31, 2009.

  1. funkyrobot

    funkyrobot

    Joined:
    Jan 31, 2009
    Messages:
    2
    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
     
    funkyrobot, Jan 31, 2009
    #1
    1. Advertising

  2. funkyrobot

    funkyrobot

    Joined:
    Jan 31, 2009
    Messages:
    2
    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!
     
    funkyrobot, Feb 3, 2009
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. walala
    Replies:
    0
    Views:
    8,768
    walala
    Aug 1, 2003
  2. Poly Diffusion
    Replies:
    2
    Views:
    1,423
  3. lovely
    Replies:
    1
    Views:
    7,995
    Jim Lewis
    Apr 12, 2004
  4. dcell

    Verilog Code

    dcell, Nov 21, 2004, in forum: VHDL
    Replies:
    1
    Views:
    2,920
    Uwe Bonnes
    Nov 21, 2004
  5. pplnet

    Verilog Code to VHDL Code

    pplnet, Dec 9, 2009, in forum: VHDL
    Replies:
    0
    Views:
    1,190
    pplnet
    Dec 9, 2009
Loading...

Share This Page