Page 493 - 3-2
P. 493

8.  소프트웨어 작성하기
              가. FPGA   소스 인체 감지 인식(       )
            module serial(rst,clk,tx_out,sensor,led);

            input clk,rst,sensor;
            output tx_out;

            output reg led;



            reg clk_uart;              //9600bps flag
            reg [19:0]clk_count;        // 속도를 맞추기위한 카운트변수 (5625)

            reg [7:0]tx_reg,tx_data;// 송신 데이터보관 변수
            reg tx_empty;               // 송신완료유무

            reg [4:0]tx_cnt;            // 비트의 길이
            reg tx_out;                 // 출력

            reg [7:0]sw_buff;
            reg [4:0]font=0;

            reg tx_flag=0;
            wire [7:0]out;

            reg flag;
            reg [35:0] led_time;



            parameter BAUD_CLK=16'd5208;//9600



            always@(posedge clk,negedge rst)//9600bps    에 맞게 분주를 해주는 모듈

            begin
                if(!rst) begin  clk_count<=0; clk_uart<=0; end

                else
                    begin

                        if(clk_count==BAUD_CLK)
                            begin

                                clk_count<=0;
                                clk_uart<=1;

                            end
                        else

                            begin
                                clk_count<=clk_count+1;

                                clk_uart<=0;



                                                         - 493 -
   488   489   490   491   492   493   494   495   496   497   498