- 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
-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