Page 207 - MDP2020-2
P. 207

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



                              clk_cnt  <=  0;
                            end
                        else
                          begin
                              clk_cnt  <=  clk_cnt  +  1;
                            end
                      end
                end

              always  @(posedge  clk,  negedge  rst)
                begin
                  if(!rst)
                      begin
                        state  <=  column1;
                      end
                  else
                      begin
                        if(clk_cnt  >=  scan_delay  -  1)
                            begin
                          case(state)
                                column1  :  state  =  column2;
                                column2  :  state  =  column3;
                                column3  :  state  =  column4;
                              column4  :  state  =  column1;
                              endcase
                          end

                    end
                end

              always  @(posedge  clk,  negedge  rst)
                begin
                  if(!rst)
                    begin
                        key_data  <=  4'b0000;
                      end
                  else
                    begin
                      case  (state)
                        column1  :  begin
                                                        case  (key_row)
                                                          4'b0001  :  key_data  <=  {4'b0001,  i};    //key_1
                                                          4'b0010  :  key_data  <=  {4'b0100,  i};  //key_4
                                                          4'b0100  :  key_data  <=  {4'b0111,  i};  //key_7
                                                          4'b1000  :  key_data  <=  {4'b1110,  i};  //key_*
                                                      endcase
                                                      end
   202   203   204   205   206   207   208   209   210   211   212