Page 564 - 3-2
P. 564

end*/




            always @(posedge clk, negedge reset)
            begin
                    if(!reset)
                    begin
                            cnt<=0;
                            time_flag<=0;
                            door<=0;
                            time_flag<=0;
                            motor_flag<=0;
                            motor_cnt<=0;
                            motor<=0;
                    end


                    else
                    begin
                    if(cnt_start) // 패턴 맞았을 때
                    begin
                            if(cnt<150000000)
                            begin
                                    //B_D_flag <= 0;
                                    cnt<=cnt+1; // 약 3 초 셈
                                    time_flag<=0;
                                    if(pass_flag)
                                            // 집안으로 들어갈수 있음 패턴 맞을 때임
                                            door<=2'b10; // 작은 문 열림


                                    else door<=2'b00;
                            end


                            else
                            begin
                                    cnt<=0;
                                    time_flag<=1;  // 약 3 초후 num,led 초기화 시키는 flag
                                    motor_flag<=1; // 약 3 초후 문 닫히게 하는거임
                            end
                    end


                    else if(B_D) begin  motor<=2'b11; end //B_D_flag<=0;


                    else if(motor_flag)
                    begin
                            door<=2'b11;   // 작은 문 닫힘


                                                         - 564 -
   559   560   561   562   563   564   565   566   567   568   569