<meter id="pryje"><nav id="pryje"><delect id="pryje"></delect></nav></meter>
          <label id="pryje"></label>

          新聞中心

          EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計應(yīng)用 > 好用的Verilog串口UART程序

          好用的Verilog串口UART程序

          作者: 時間:2010-06-20 來源:網(wǎng)絡(luò) 收藏

          if (!rx_busy !rx_d2) begin
          rx_busy = 1;
          rx_sample_cnt = 1;
          rx_cnt = 0;
          end
          // Start of frame detected, Proceed with rest of data
          if (rx_busy) begin
          rx_sample_cnt = rx_sample_cnt + 1;
          // Logic to sample at middle of data
          if (rx_sample_cnt == 7) begin
          if ((rx_d2 == 1) (rx_cnt == 0)) begin
          rx_busy = 0;
          end else begin
          rx_cnt = rx_cnt + 1;
          // Start storing the rx data
          if (rx_cnt > 0 rx_cnt 9) begin
          rx_reg[rx_cnt - 1] = rx_d2;
          end
          if (rx_cnt == 9) begin
          rx_busy = 0;
          // Check if End of frame received correctly
          if (rx_d2 == 0) begin
          rx_frame_err = 1;
          end else begin
          rx_empty = 0;
          rx_frame_err = 0;
          // Check if last rx data was not unloaded,
          rx_over_run = (rx_empty) ? 0 : 1;
          end
          end
          end
          end
          end
          end
          if (!rx_enable) begin
          rx_busy = 0;
          end
          end

          // TX Logic
          always @ (posedge txclk or posedge reset)
          if (reset) begin
          tx_reg = 0;
          tx_empty = 1;
          tx_over_run = 0;
          tx_out = 1;
          tx_cnt = 0;
          end else begin
          if (ld_tx_data) begin
          if (!tx_empty) begin
          tx_over_run = 0;
          end else begin
          tx_reg = tx_data;
          tx_empty = 0;
          end
          end
          if (tx_enable !tx_empty) begin
          tx_cnt = tx_cnt + 1;
          if (tx_cnt == 0) begin
          tx_out = 0;
          end
          if (tx_cnt > 0 tx_cnt 9) begin
          tx_out = tx_reg[tx_cnt -1];
          end
          if (tx_cnt == 9) begin
          tx_out = 1;
          tx_cnt = 0;
          tx_empty = 1;
          end
          end
          if (!tx_enable) begin
          tx_cnt = 0;
          end
          end

          endmodule

          本文引用地址:http://www.ex-cimer.com/article/151787.htm

          上一頁 1 2 下一頁

          關(guān)鍵詞: 程序 UART 串口 Verilog

          評論


          相關(guān)推薦

          技術(shù)專區(qū)

          關(guān)閉
          看屁屁www成人影院,亚洲人妻成人图片,亚洲精品成人午夜在线,日韩在线 欧美成人 (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })();