Page 204 - MDP2020-2
P. 204

|    인천전자마이스터고등학교  ·············································································································
            198


                              if(clk_cnt  >=  62500  &&  clk_cnt  <=  187500)  //125000  +  62500
                                begin
                                    lcd_en  <=  1'b1;
                                end
                              else
                                begin
                                    lcd_en  <=  1'b0;
                                end
                            end
                      end
                end


              //FSM(next_state_logic  +  state_logic)
              always  @(posedge  clk,  negedge  rst)
                begin
                  if(!rst)
                      begin
                        state  <=  delay_100ms;
                      end
                    else
                      begin
                        if(clk_cnt  ==  0)
                          begin
                              case(state)
                              delay_100ms      :  state  <=  (cnt_100ms  ==  19)?  function_set  :  state;
                              function_set    :  state  <=  display_on;

                              display_on        :  state  <=  display_clear;
                              display_clear  :  state  <=  entry_mode;
                              entry_mode        :  state  <=  display_data;
                              display_data    :  state  <=  (cnt_line  >=  34)?  delay_20ms  :  state;
                              delay_20ms        :  state  <=  (cnt_20ms  ==  3)?  display_data  :  state;
                              endcase
                            end
                      end
                end


              //FSM(output_logic)
              always    @(posedge  clk,  negedge  rst)
                begin
                  if(!rst)
                      begin
                        lcd_rs  <=  0;
                        lcd_data  <=  0;
                      end
                    else
   199   200   201   202   203   204   205   206   207   208   209