I have written code for a synchronous FIFO that contains tasks. I am getting an error in task t_write that says
syntax error in assignment statement l-value
However, I do not understand the cause of the error.
Any help would be appreciated.
Source code:
module sync_fifo #(parameter Dwidth = 16, Ddepth = 2) (output reg [Dwidth-1:0] RD_DATA,
output reg FULL, EMPTY,
input [Dwidth-1:0] WR_DATA,
input WRITE, READ, CLK, RSTB);
reg COUNT = 0;
reg READ_PTR = 0;
reg WRITE_PTR = 0;
reg [Dwidth-1:0] FIFO[Ddepth-1:0];
task automatic t_read;
begin
RD_DATA = FIFO(READ_PTR);
COUNT = COUNT - 1;
READ_PTR = READ_PTR + 1;
end
endtask
task automatic t_write;
begin
FIFO(WRITE_PTR) = WR_DATA;
WRITE_PTR = WRITE_PTR + 1;
COUNT = COUNT + 1;
end
endtask
always @(COUNT) begin
FULL = (COUNT == Ddepth);
EMPTY = (COUNT == 0);
end
always @(posedge CLK) begin
if(RSTB) begin
COUNT = 0;
READ_PTR = 0;
WRITE_PTR = 0;
end
end
always @(posedge CLK) begin
if(!RSTB) begin
if(READ & !WRITE) begin
if(!EMPTY)
t_read;
else
$display("FIFO is empty");
end
end
end
always @(posedge CLK) begin
if(!RSTB) begin
if(!READ & WRITE) begin
if(!FULL)
t_write;
else
$display("FIFO is full");
end
end
end
always @(posedge CLK) begin
if(!RSTB) begin
if(READ & WRITE) begin
if(!EMPTY && !FULL) begin
t_read;
t_write;
end
else if(FULL) begin
t_read;
$display("FIFO is full");
end
else if(EMPTY) begin
t_write;
$display("FIFO is empty");
end
end
end
end
endmodule