always @(posedge clk)
if(~rst_n) begin
//rdreq <= #1 1'b0;
wrreq <= #1 1'b0;
data <= #1 64'hffffffffffffffff;
state <= #1 IDLE;
counter <= 8'h00;
end else begin
case (state)
IDLE:
begin
data <= #1 64'd10;
state <= #1 FIFO_WRITE;
wrreq <= #1 1'b1;
end
FIFO_WRITE:
begin
data <= #1 data + 1'b1;
counter <= counter + 1'b1;
if( counter == 4 ) begin
state <= #1 FIFO_READ;
wrreq <= #1 1'b0;
data <= #1 data - 1'b1;
//rdreq <= #1 1'b1;
end else
state <= #1 FIFO_WRITE;
end
FIFO_READ:
begin
//reg_data <= q;
if(rdempty)begin
state <= #1 STOP;
end
end
STOP:
begin
state <= #1 STOP;
//rdreq <= #1 1'b0;
wrreq <= #1 1'b0;
end
endcase
end
always @(posedge clk)
if(~rst_n)
begin
check_empty <= 1'b0;
end else if(~rdempty)
check_empty <= 1'b1;
else
check_empty <= 1'b0;
assign rdreq = (~rdempty) & check_empty;
always @(posedge clk)
rdreq_r <= rdreq;
always @(posedge clk)
if(~rst_n)
begin
reg_data <= 0;
end else if(rdreq_r)
reg_data <= q;
else
reg_data <= 64'hffffffffffffffff;