首页 数字电路设计实验vhdl语言实验报告

数字电路设计实验vhdl语言实验报告

举报
开通vip

数字电路设计实验vhdl语言实验报告实验一 秒表计数器的设计 1、实验目的: 本实验通过设计四种频率可选的数字时钟系统,以达到熟悉VHDL语言编程语法、设计思路和熟练掌握Quartus II 开发软件的目的。 二、实验内容: 该数字时钟的显示格式如下所示:HH:MM:SS,其中HH表示时计数的两位,MM表示分计数的两位,SS表示秒计数的两位。本系统输入信号分别为复位信号rst(高有效)、sel(两位信号,分别可以选择2分频、4分频8分频和16分频)、clk_in(时钟信号)、8位时输出、8位分输出、8位秒输出(其中高4为表示对应的高半字节、低4位表...

数字电路设计实验vhdl语言实验报告
实验一 秒表计数器的 设计 领导形象设计圆作业设计ao工艺污水处理厂设计附属工程施工组织设计清扫机器人结构设计 1、实验目的: 本实验通过设计四种频率可选的数字时钟系统,以达到熟悉VHDL语言编程语法、设计思路和熟练掌握Quartus II 开发软件的目的。 二、实验内容: 该数字时钟的显示格式如下所示:HH:MM:SS,其中HH表示时计数的两位,MM表示分计数的两位,SS表示秒计数的两位。本系统输入信号分别为复位信号rst(高有效)、sel(两位信号,分别可以选择2分频、4分频8分频和16分频)、clk_in(时钟信号)、8位时输出、8位分输出、8位秒输出(其中高4为表示对应的高半字节、低4位表示的低半字节,譬如当时间为08:59:30时,时输出为”0000_1000”,分输出为”0101_1001”,秒输出为”0011_0000”)。该时钟系统可以通过Sel信号时钟运行的快慢。 三、实验 流程 快递问题件怎么处理流程河南自建厂房流程下载关于规范招聘需求审批流程制作流程表下载邮件下载流程设计 : 通过对实验内容的分析:可以考虑时钟系统的可由三部分组成: 1、分频器: 分频器为时序电路并且通过《数字电路》理论课程的学习可知由计数器来实现,同学可以回想一下实验1中是如何实现计数器电路的设计),该模块主要产生2、4、8、16分频的时钟信号; 2、多路选择器: 在VHDL中多路选择器为组合逻辑,可以有多种实现方法,在这里主要选用了case语句来实现。该模块的作用是从分频器中根据Sel信号选择适当的时钟信号; 3、时钟控制器: 该模块比较复杂,主要实现功能是实现一个24小时的计时。当时间为00:00:59的时候下一个时钟到来时状态的跳变为00:01:00,计时中多数计数为加1操作,有几个特殊状态需要重点考虑:当时间产生分进数时,譬如上例。当时间产生时进数时,譬如00:01:59时刻的下一个状态为00:02:00;当时间产生时进数时,譬如00:59:59是个的下一个状态为01:00:00。当时间产生天进数时,譬如23:59:59的下一个状态为00:00:00。 四、仿真要求: 本次试验的结果全部采用功能仿真分析: 1、在结果图中能够看到让复位信号rst为有效的情况下,所有的输出为00:00:00; 2、当频率选择输出分别为”00”、”01”、”10”、”11”时秒为的进数分别包含2、4、8、16倍clk_in的时钟周期; 3、可以看到完整的计时周期00:00:00->23:59:59->00:00:00。 五、实验代码: library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.STD_LOGIC_ARITH.ALL; use IEEE.STD_LOGIC_UNSIGNED.ALL; entity fpga is port( clk_in    : in std_logic; rst        : in std_logic; sel        : in std_logic_vector(1 downto 0); hour_high_out      : out std_logic_vector(3 downto 0); hour_low_out        : out std_logic_vector(3 downto 0); minute_high_out    : out std_logic_vector(3 downto 0); minute_low_out      : out std_logic_vector(3 downto 0); second_high_out    : out std_logic_vector(3 downto 0); second_low_out      : out std_logic_vector(3 downto 0) ); end fpga; architecture beha of fpga is signal clk        : std_logic; signal clk_cnt    : std_logic_vector(3 downto 0); signal hour_high  : std_logic_vector(3 downto 0); signal hour_low    : std_logic_vector(3 downto 0); signal minute_high : std_logic_vector(3 downto 0); signal minute_low  : std_logic_vector(3 downto 0); signal second_high : std_logic_vector(3 downto 0); signal second_low  : std_logic_vector(3 downto 0); begin process(rst,clk_in) begin if(rst='1')then clk_cnt<="0000"; elsif(rising_edge(clk_in))then clk_cnt<=clk_cnt+1; end if; end process; process(sel) begin case sel is when "00"=>clk<=clk_cnt(0); when "01"=>clk<=clk_cnt(1); when "10"=>clk<=clk_cnt(2); when "11"=>clk<=clk_cnt(3); when others=>clk<='0'; end case; end process; process(clk, rst) begin if (rst ='1')then hour_high<="0000"; hour_low<="0000"; minute_high<="0000"; minute_low<="0000"; second_high<="0000"; second_low<="0000"; elsif(rising_edge(clk))then if(second_low/="1001")then second_low<=second_low+1; else if(second_high/="0101")then second_high<=second_high+1; else second_high<="0000";     if(minute_low/="1001")then minute_low<=minute_low+1; else if(minute_high/="0101")then minute_high<=minute_high+1; else minute_high<="0000"; if((hour_low/="0011") and ((hour_high /="0010") or (hour_low/="1001")))then hour_low<=hour_low+1;    else hour_low<="0000";    if(hour_high ="0010" and hour_low ="0011" )then hour_high<="0000"; else hour_high<=hour_high+1; end if;    end if;    end if;    minute_low<="0000";                end if; end if; second_low<="0000"; end if; end if; end process; process(clk) begin hour_high_out<=hour_high; hour_low_out<=hour_low; minute_high_out<=minute_high; minute_low_out<=minute_low; second_high_out<=second_high; second_low_out<=second_low; end process; end beha; 1、 六、实验结果分析:在结果图中能够看到让复位信号rst为有效的情况下,所有的输出为00:00:00; 2、 当频率选择输出分别为”00”、”01”、”10”、”11”时秒为的进数分别包含2、4、8、16倍clk_in的时钟周期; 二分频图 四分频图 八分频图 十六分频图 3、可以看到完整的计时周期00:00:00->23:59:59->00:00:00。 七、实验心得 通过上一节课的学习,了解实验软件Quartus II基本的操作方法后,这次的实验就娴熟了很多,实验的设计想法不是很复杂,因为这次要求是实现偶数分频以及计数功能。这次实验老师给定了代码的模板,给我们的编写和设计提供了很大的帮助,认真思考原理过后,对以后的更难一些的实验一定会有很大帮助。 实验二  奇数分频的模十状态机的设计 一、实验目的: 通过设计频率可选的模十状态机以达到进一步掌握VHDL硬件描述语言的目的。 二、实验流程: 本设计有分频器、多路选择器、状态机。 1. 时钟输入作为分频器的输入,输出时钟分别为3分频和5分频; 2. 分频器输出由2选1的多路选择器选择其中之一作为状态机的时钟输入; 3. 使用选中的时钟频率作为输入时钟驱动状态机按照以下的次序输出:0->A->5->6->1->F->4->8->E->3->0的顺序输出。 三、实验代码: library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.STD_LOGIC_ARITH.ALL; use IEEE.STD_LOGIC_UNSIGNED.ALL; entity counter is port (clk: in std_logic; rst: in std_logic; clk_div: out std_logic; sel:in std_logic_vector(0 downto 0); out1:out std_logic_vector(3 downto 0)); end counter; architecture Behavioral of counter is signal shangsheng:std_logic_vector(2 downto 0); signal count1:std_logic_vector(2 downto 0); signal count2:std_logic_vector(2 downto 0); signal level_div3:std_logic; signal now_state : std_logic_vector(3 downto 0); signal next_state : std_logic_vector(3 downto 0); begin process(sel) begin case sel is when "0"  => shangsheng<= "010"; when "1"  => shangsheng<= "100"; end case; end process; p1:process(clk) begin if(clk'event and clk='1')then if(count2=shangsheng)then count2<="000"; else count2<=count2+1; end if; end if; end process p1; p2:process(clk) begin if(clk'event and clk='0')then if(count1=shangsheng)then count1<="000"; else count1<=count1+1; end if; end if; end process p2; level_div3<=count1(1) or count2(1); clk_div<=level_div3; Process(rst,clk) begin if( rst = '1') then now_state<="0000"; elsif( level_div3'event and level_div3 ='1')then now_state<=next_state; end if; end process; process(now_state) begin case now_state is when "0000"=>next_state<="1010"; when "1010"=>next_state<="0101"; when "0101"=>next_state<="0110"; when "0110"=>next_state<="0001"; when "0001"=>next_state<="1111"; when "1111"=>next_state<="0100"; when "0100"=>next_state<="1000"; when "1000"=>next_state<="1110"; when "1110"=>next_state<="0011"; when "0011"=>next_state<="0000"; when others=> next_state<="0000"; end case; end process; out1<=now_state; end Behavioral; 四、实验结果分析: 1、通过实验结果,rst有效时,所有的状态为零。 三分频 五、实验心得 这次实验做的是模十的状态机,利用奇数数分频,这个代码编写起来比较麻烦,不过有了上次编写偶数分频的经验,就容易多了,实现奇数分频需要将两个偶数分频相或,有了这样的思路,编写起来就简单了很多。通过这3次的实验,让我对数字电路这门课程的理解更加透彻了,也熟悉了Quartus II,相信对我以后的学习会有很大帮助。
本文档为【数字电路设计实验vhdl语言实验报告】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
该文档来自用户分享,如有侵权行为请发邮件ishare@vip.sina.com联系网站客服,我们会及时删除。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。
本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。
网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。
下载需要: 免费 已有0 人下载
最新资料
资料动态
专题动态
is_191127
暂无简介~
格式:doc
大小:40KB
软件:Word
页数:16
分类:互联网
上传时间:2019-02-11
浏览量:15