Page 195 - MDP2020-2
P. 195

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



                          begin
                              led  <=  ~led;
                            end
                        else
                          begin
                              led  <=  led;
                            end
                      end
                end
            endmodule  */


            //A  ->  /A  ->  B    ->  /B
            module  step_motor(clk,  rst,  step_phase);
              input  clk,  rst;
              output  reg  [3:0]  step_phase;


              reg  [2:0]  step;
              reg  [31:0]  time_count;
              reg  stop_flag;
              reg  [31:0]  temp;

              parameter  SPEED  =  100000;
              //parameter  SPEED  =  10000000;
              parameter  A  =  4'b0001,  A_  =  4'b0010,  B  =  4'b0100,  B_  =  4'b1000;

              always  @(posedge  clk,  negedge  rst)

                begin
                  if(!rst)
                      begin
                        time_count  <=  0;
                      end
                    else
                      begin
                        if(time_count  >=  SPEED)
                          begin
                              time_count  <=  0;
                            end
                        else
                          begin
                              time_count  <=  time_count  +  1;
                            end
                      end
                end

              always  @(posedge  clk,  negedge  rst)
   190   191   192   193   194   195   196   197   198   199   200