I'm trying to generate different delays in multiple places using task WAIT in a synthesizable module, and the code is as follows:
module LCD
(
input clk,
output en
);
reg [ 15 : 0 ] delay = 0; // counter for state machine
reg [ 15 : 0 ] COUNT= 0; // counter for "WAIT"
always @ (posedge clk_lcd) begin
COUNT = COUNT + 1'b1; // COUNTER FOR TASK "WAIT"
.
delay = 2000;
WAIT(en, delay); // call task
.
delay = 500;
WAIT(en, delay); // call task
end // always end
.
task automatic WAIT // task to wait till delay time is up
(
output EN,
input [ 15 : 0 ] DELAY
);
begin
COUNT = 0;
if(COUNT == DELAY)begin // create delay using counter
EN = 0;
COUNT = 0;
end else begin
EN = 1;
COUNT = COUNT + 1'b1;
end
end
endtask // end task
endmodule
But, they don't work. I'm a learner; please help.