Page 197 - MDP2020-2
P. 197

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



              input  clk,  rst;
              input  eoc;
              input  [7:0]  adc_in;
              output  adc_clk;
              output  reg  ale;
              output  reg  start;
              output  reg  oe;
              output  reg  [2:0]  channel;
              output  reg  [7:0]  adc_out;
              reg  adc_clk;
              reg  [7:0]  adc_time;
              reg  [7:0]  clk_cnt;
              reg  [2:0]  state;
              parameter     s_IDLE=3'b000,      s_START=3'b001,        s_WAIT=3'b010,       s_OE_SIG=3'b011,
            s_CAPTURE=3'b100;
              always@(posedge  clk,  negedge  rst)
                begin
                  if(!rst)
                    begin
                        clk_cnt  <=  0;
                        adc_clk  <=  0;
                      end
                  else
                    begin
                      if(clk_cnt  >=  25  -  1)
                          begin

                            clk_cnt  <=  0;
                            adc_clk  <=  ~adc_clk;
                          end
                      else
                        begin
                            clk_cnt  <=  clk_cnt  +  1;
                            adc_clk  <=  adc_clk;
                          end
                    end
                end
                always@(posedge  clk,  negedge  rst)
                begin
                  if(!rst)
                    begin
                        adc_time  <=  0;
                      end
                  else
                    begin
                        if(state  ==  s_START  ||  state  ==  s_OE_SIG)
   192   193   194   195   196   197   198   199   200   201   202