|
楼主 |
发表于 2011-7-10 16:24:55
|
显示全部楼层
不好意思,后面有default,没拷贝全,后面掉了两句
parameter SYS_IDLE = 'd0;
parameter WR_VEC = 'd1;
parameter WR_VEC_S1 = 'd2;
parameter WR_VEC_S2 = 'd3;
reg[3:0] sys_cs,sys_ns;
reg last,current; //启动状态机标志
reg wr,cs;
reg[6:0] timeoutcount;
input wr_ack;
case(sys_cs)
SYS_IDLE:
begin
if(last!=current)
begin
sys_cs <= sys_ns;
last <= current;
end
else
sys_cs <= SYS_IDLE;
wr <= 1;
cs <= 0;
end
WR_VEC://
begin
data <= {databuf2,databuf1,databuf0};
sys_cs <= WR_VEC_S1;
cs <= 1;
wr <= 0;
end
WR_VEC_S1://
begin
sys_cs <= WR_VEC_S2;
timeoutcount <= 0;
end
WR_VEC_S2:
begin
cs <= 0;
//问题出在这个if判断;本意是要接受到wr_ack 高电平才推出的
if(wr_ack)
begin
sys_cs <= SYS_IDLE;
wr <= 1;
end
else
begin
if(timeoutcount > 100)
begin
sys_cs <= SYS_IDLE;
wr <= 1;
timeoutcount <= 0;
end
else
begin
wr <= 0;
sys_cs <= WR_VEC_S2;
timeoutcount <= timeoutcount +1'b1;
end
end
end
default:sys_cs <= SYS_IDLE;
endcase |
|