Page 201 - MDP2020-2
P. 201

················································································  명장양성프로젝트  【MDP】  과제발표회  자료집  Ⅱ    |  195





              //200Hz
              always  @(posedge  clk,  negedge  rst)
                begin
                    if(!rst)
                      begin
                        clk_cnt  <=  0;
                      end
                    else
                      begin
                        if(clk_cnt  >=  DIV  -  1)
                            begin
                              clk_cnt  <=  0;
                            end
                        else
                            begin
                              clk_cnt  <=  clk_cnt  +  1;
                            end
                      end
                end


              //100ms
              always  @(posedge  clk,  negedge  rst)
                begin
                  if(!rst)
                      begin

                        cnt_100ms  <=  0;
                      end
                    else
                      begin
                        if(state  ==  delay_100ms)  //     delay_100ms
                            begin
                              if(clk_cnt  >=  DIV  -  1) //5ms
                                begin
                                    if(cnt_100ms  ==  19)   //5ms  x  20  =  100ms
                                      begin
                                        cnt_100ms  <=  0;
                                      end
                                    else
                                      begin
                                        cnt_100ms  <=  cnt_100ms  +  1;
                                      end
                                end
                              else
                                begin
   196   197   198   199   200   201   202   203   204   205   206