Page 570 - 3-2
P. 570

tx_cnt<=0; // 전송 데이터 비트수 세는 변수를 0            으로 만든다
                                                    tx_empty<=1; // 송신 완료 을 넣어줌으로써 송신을 멈춘다(1
                                            end
                                    end
                            end
                    end
            end*/




            // 수신 모듈
            always @(posedge clk, negedge reset)
            begin
                    if(reset == 0)
                    begin
                            rx_clk_cnt <= 0;
                            rx_bit_cnt <= 0;
                            rx_start_cnt <= 0;
                            state_rx <= 0; //  수신회선 휴지 상태
               end


                    else
                    begin
                            if(state_rx == 0 && rxd == 0)   // if not receive mode and start bit is detected
                                    begin
                        if(rx_start_cnt >= CLOCKS_WAIT_FOR_RECEIVE -1)
                        begin
                                                    rx_start_cnt <= 0;
                                               state_rx <= 1'b1;      //enter receive mode


                                       end


                                            else
                                  begin
                                            rx_start_cnt <= rx_start_cnt +1'b1 ;
                                                    state_rx <= 1'b0;
                                            end
                                    end


                            else    rx_start_cnt <=0;


                            if(state_rx == 1)   // if receive mode
                            begin
                                            if(rx_clk_cnt >= baud_rate)  // 컴퓨터의 통신속도로 시스템클럭 분주


                                       begin


                                                         - 570 -
   565   566   567   568   569   570   571   572   573   574   575