Page 688 - 3-2
P. 688
front:
begin
buff_cnt2<=0;
flag<=0;
if(time_cnt>=50000000*2) state<=back; //2 초 세기
else time_cnt<=time_cnt+1;
end
back:
begin
time_cnt<=0;
flag<=1;
if(time_cnt2>=50000000*2) state<=down;//2 초 세기
else time_cnt2<=time_cnt2+1;
end
down: // 내려오다가 멈춤
begin
time_cnt2<=0;
flag<=2;
if(buff_cnt>=50000000&&limb==1) state<=left;
else buff_cnt<=buff_cnt+1;
end
left: // 옆으로 이동하다가 멈춤
begin
buff_cnt<=0;
if(buff_cnt2>=50000000&&liml==1) state<=finish;
else buff_cnt2<=buff_cnt2+1;
end
finish:
begin
buff_cnt2<=0;
state<=idle;
sig_f<=1;
end
default: begin state<=idle; end
endcase
end
end
end
always @(state) // 모터제어
begin
if(sig==1)
begin
case(state)
idle: begin dcmotor1=2'b00; dcmotor2=2'b00; end
- 688 -