首页 | 新闻 | 新品 | 文库 | 方案 | 视频 | 下载 | 商城 | 开发板 | 数据中心 | 座谈新版 | 培训 | 工具 | 博客 | 论坛 | 百科 | GEC | 活动 | 主题月 | 电子展
返回列表 回复 发帖

串口通信Verilog源程序(下)

串口通信Verilog源程序(下)

// UART 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
返回列表