




已阅读5页,还剩3页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
串口通信Verilog源程序测试过,很好用。/-/ Design Name : uart / File Name : uart.v/ Function : Simple UART/ Coder : Deepak Kumar Tala/-module uart (reset ,txclk ,ld_tx_data ,tx_data ,tx_enable ,tx_out ,tx_empty ,rxclk ,uld_rx_data ,rx_data ,rx_enable ,rx_in ,rx_empty);/ Port declarationsinput reset ;input txclk ;input ld_tx_data ;input 7:0 tx_data ;input tx_enable ;output tx_out ;output tx_empty ;input rxclk ;input uld_rx_data ;output 7:0 rx_data ;input rx_enable ;input rx_in ;output rx_empty ;/ Internal Variables reg 7:0 tx_reg ;reg tx_empty ;reg tx_over_run ;reg 3:0 tx_cnt ;reg tx_out ;reg 7:0 rx_reg ;reg 7:0 rx_data ;reg 3:0 rx_sample_cnt ;reg 3:0 rx_cnt ; reg rx_frame_err ;reg rx_over_run ;reg rx_empty ;reg rx_d1 ;reg rx_d2 ;reg rx_busy ;/ UART RX Logicalways (posedge rxclk or posedge reset)if (reset) beginrx_reg = 0; rx_data = 0;rx_sample_cnt = 0;rx_cnt = 0;rx_frame_err = 0;rx_over_run = 0;rx_empty = 1;rx_d1 = 1;rx_d2 = 1;rx_busy = 0;end else begin/ Synchronize the asynch signalrx_d1 = rx_in;rx_d2 = rx_d1;/ Uload the rx dataif (uld_rx_data) begin rx_data = rx_reg; rx_empty = 1;end/ Receive data only when rx is enabledif (rx_enable) begin / Check if just received start of frame 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 0 & rx_cnt 9) begin rx_regrx_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 endif (!rx_enable) begin rx_busy = 0;endend/ UART TX Logicalways (posedge txclk or posedge reset)if (reset) begintx_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 & tx_cnt 9) begin tx_out = tx_regtx_cnt -1; end
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 【正版授权】 ISO 80000-7:2019/AMD1:2025 EN Amendment 1 - Quantities and units - Part 7: Light and radiation
- 【正版授权】 ISO 17666:2025 EN Space systems - Programme management - Risk management
- 【正版授权】 IEC 60068-3-14:2025 EN Environmental testing – Part 3-14: Supporting documentation and guidance – Developing a climatic sequential test
- 校园师生消防知识培训课件
- 绝食减肥测试题及答案
- 甲乳外科考试题及答案
- 自律作息测试题及答案
- 桂林社工面试题及答案
- 胰腺炎考试试题及答案
- 锁骨护理试题及答案
- 2025年云南省高校大学《辅导员》招聘考试题库及答案
- 消费品市场2025年消费者对绿色包装认知及需求调研可行性研究报告
- 台球厅消防知识培训课件
- 充电桩运维服务协议
- 2025至2030中国防砸安全鞋行业运营态势与投资前景调查研究报告
- 2025年医疗器械仓库管理培训试题及答案
- 2024年湖南省古丈县事业单位公开招聘工作人员考试题含答案
- 卵巢性索间质肿瘤课件
- 2025甘肃行政执法资格考试模拟卷及答案(题型)
- 2025-2026年秋季第一学期学校德育工作安排表:德润心田、智启未来、行塑栋梁
- 成人零基础英语教学课件
评论
0/150
提交评论