ena<='b0;
enb<='b0;
addra<=13'h1fff;
addrb<=13'h1fff;
dina_i<='h0;
wr_flag<='b0;
flag <= 'b0;
STATE<=READ_EVENT;
end
READ_EVENT:
begin
//enb<='b0;
wr_flag<='b1;
u_addr0<='b0;
u_addr1<='b0;
STATE<=POINT_TO_OUT_FIFO;
end
POINT_TO_OUT_FIFO:
begin
if(u_flagc)
begin
u_sloe<='b0;
u_slrd<='b1;
STATE<=DATA_READY;
end
else
begin
u_sloe<='b1;
u_slrd<='b1;
STATE<=POINT_TO_OUT_FIFO;
end
end
DATA_READY:
begin
if((u_flagc&&data=='h0100&&!flag)||(u_flagc&&flag))
begin
flag<=1'b1;
u_slrd<='b0;
addra<=addra+1;
dina_i<=data;////////////////////data_src
ena<='b1;
enb<='b0;
STATE<=READ;
end
else
begin
u_slrd<='b1;
u_sloe<='b1;
STATE<=POINT_TO_OUT_FIFO;
end
end
READ:
begin
u_slrd<='b1;
ena <='b0;
if(addra!=ADDR_FULL)
STATE<=DATA_READY;
else
STATE<=READ_END;
end
READ_END:
begin
u_slrd<='b1;
u_sloe<='b1;
u_addr0<='b0;
u_addr1<='b0;
addra<='h1fff;
STATE<=WRITE_EVENT;
end
WRITE_EVENT:
begin
wr_flag<='b0;
sd_flag<='b0;
; enb<='b0;
STATE<=POINT_TO_IN_FIFO;
end
POINT_TO_IN_FIFO:
begin
addrb<=addrb+1;
ena<='b0;
enb<='b1;
STATE<=WRITE;
end
WRITE:
begin
if(addrb!=ADDR_FULL)
begin
addrb<=addrb+1;
sd_data<=doutb;
ena<='b0;
enb<='b1;
sd_flag<=1;
STATE<=WRITE;
end
else
begin
addrb<='h1fff;
ena<='b0;
enb<='b0;
STATE<=WRITE_END;
end
end
WRITE_END:
begin
sd_flag<='b0;
wr_flag<='b0;
addrb<='h1fff;//add by lww
u_addr0<='b1;
u_addr1<='b1;
STATE<=IDLE;
end
default:
STATE<=IDLE;
endcase
end
end