




已阅读5页,还剩3页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
时钟4分频,freqd_dff.vhd文件clk_in:时钟输入clk_out:时钟输出-library ieee;use ieee.std_logic_1164.all;library altera;use altera.maxplus2.all;entity freqd_dff isgeneric(n: integer :=2);port(clk_in: in std_logic;clk_out: out std_logic);end freqd_dff;architecture freqd_dff_arch of freqd_dff issignal q: std_logic_vector(0 to n);beginq(0) = clk_in;G1: for i in 0 to (n-1) generateUx: dff port map(not q(i+1), q(i), 1, 1, q(i+1);end generate; clk_out = q(n); end freqd_dff_arch;-波特率产生,clock.vhd文件clk:50m时钟clk_out:4倍的波特率时钟sel:波特率选择端,可接拨动开关。00:1200的波特率01:960010:3840011:115200的波特率-library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;library altera;use altera.maxplus2.all;entity clock isport(clk: in std_logic;clk_out: out std_logic;sel: in std_logic_vector(1 downto 0);end clock;architecture clock_arch of clock issignal count: std_logic_vector(31 downto 0);constant step96: integer :=3298535;-3298535:9600;constant step11: integer :=39582419;-115200;constant step12: integer :=412317;-1200;constant step38: integer := 13194139;-38400;signal step: integer;beginstep = step12 when sel= 00 else step96 when sel= 01 else step38 when sel= 10 else step11;process( clk )beginif rising_edge(clk) thencount = count + step;end if;end process;clk_out = count(31);end clock_arch;串口接收,recvive.vhd文件clk:4倍的波特率时钟reset:复位端,低电平0复位rx:串口rxrx_done:接收完成,1时完成接收rx_buf:接收的数据-library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;use ieee.std_logic_arith.all;entity recvive isgeneric(framlent:integer:=8);Port(clk, reset: std_logic;rxbuf: out std_logic_vector(7 downto 0);rx: in std_logic;rx_done: out std_logic);end recvive;architecture behave of recvive issignal txen: std_logic;beginrx_done 0);elsif rising_edge(clk) thenif txen = 1 thentxreg(35 downto 1) := txreg(34 downto 0);txreg(0) := rx;end if;end if;rxbuf = txreg(2)&txreg(6)&txreg(10)&txreg(14)&txreg(18)&txreg(22)&txreg(26)&txreg(30);end process;process(clk, reset)variable tcnt: std_logic_vector(5 downto 0); beginif reset=0 thentxen = 0;elsif rising_edge(clk) thenif txen =0 thentxen = not rx;else if tcnt = 100011 thentxen = 0;end if;end if;end if;if reset=0 thentcnt := 000000;elsif rising_edge(clk) thenif txen =1 thentcnt := tcnt + 1;elsetcnt := 000000;end if;end if;end process;end behave;-串口发送,recvive.vhd文件clk:倍的波特率时钟reset:复位端,低电平0复位send:发送信号,高电平开始发送tx:串口txtx_done:发送完成,1时完成发送tx_buf:要发送的数据-library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;use ieee.std_logic_arith.all;entity transferz isgeneric(framlent:integer:=8);Port(clk, reset, send: in std_logic;txbuf: in std_logic_vector(7 downto 0);tx: out std_logic;tx_done: out std_logic);end transferz;architecture behave of transferz issignal txen: std_logic;begintx_done = not txen;process(clk, reset)variable txreg: std_logic_vector(9 downto 0):=1111111111;beginif reset=0 thentxreg := 1111111111;elsif rising_edge(clk) thenif txen = 0 thentxreg(9 downto 2) := txbuf(7 downto 0);txreg(0) := 1;txreg(1) := 0;elsetxreg(8 downto 0) := txreg(9 downto 1);txreg(9) := 1;end if;end if;tx = txreg(0);end process;process(clk, reset)variable tcnt: std_logic_vector(3 downto 0) :=0000; beginif reset=0 thentxen = 0;elsif rising_edge(clk) thenif txen =0 thentxen = send;else if tcnt = 1111 thentxen = 0;end if;end if;end if;if reset=0 thentcnt := 0000;elsif rising_edge(clk) thenif txen =1 thentcnt := tcnt + 1;elsetcnt := 0000;end if;end if;end process;end behave;-总设计图,chuankou.bdfclk:50m的时钟输入。reset:复位端,低电平0复位,接复位按键。send:发送信号,低电平发送接,接复位按
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025年预防接种理论考试试题(附答案)
- 医院网络与信息安全类突发事件应急预案
- 2025年养猪技能大赛笔试题及答案
- 酒厂员工培训题库及答案
- 2025年音乐资格试题及答案
- 2025年泳池水处理设备项目发展计划
- 柳湾煤矿安全培训课件
- 2025年战略采购试题及答案
- 钢筋试验试题及答案
- 203日语真题及答案
- 2025年电信项目管理工程师考试试题
- 《高速铁路动车组辅助设备维护与检修(第2版)》课件 任务三四 CRH380B型动车组车门系统
- 单梁吊培训课件
- 2025教师暑期政治培训心得体会
- 抑尘网抑尘效果的风洞试验方法研究
- 2025至2030中国纳米纤维材料行业产业运行态势及投资规划深度研究报告
- 2025-2030中国蒸压加气混凝土(AAC)行业运行态势与未来前景展望报告
- 医疗卫生关键岗位权力清单管理制度
- 企事业单位车辆无偿借用协议范本
- DZ/T 0263-2014地面核磁共振法找水技术规程
- T/QX 006-2023工业设备水射流清洗质量验收规范
评论
0/150
提交评论