当前位置:文档之家› VHDL课程设计

VHDL课程设计

本科实验报告实验名称:数字系统设计与实验(软件部分)实验一 QuartusII9.1软件的使用一、实验目的:1、通过实现书上的例子,掌握QUARTUSII9.1软件的使用.2、编程实现3-8译码电路以掌握VHDL组合逻辑的设计以及QUARTUSII9.1软件的使用。

二、实验内容1.十进制加法计数器的VHDL文本及仿真功能图:VHDL文本:library IEEE;use IEEE.std_logic_1164.all;use IEEE.STD_LOGIC_ARITH.ALL;use IEEE.STD_LOGIC_UNSIGNED.ALL;entity count10 isport(clk,load,en:in std_logic;data_in:in std_logic_vector(3 downto 0);seg:out std_logic_vector(6 downto 0));end count10;architecture beha of count10 issignal qout:std_logic_vector(3 downto 0);signal q_temp:std_logic_vector(3 downto 0);beginprocess(clk,load)beginif(load='1')thenq_temp<=data_in;elsif(clk'event and clk='1')thenif(en='0')thenqout<=qout;elsif(qout="1001")thenqout<="0000";elseqout<=qout+1;end if;q_temp<=qout;end if;end process;process(q_temp)begincase q_temp iswhen"0000"=>seg<="1000000";when"0001"=>seg<="1111001";when"0010"=>seg<="0100100";when"0011"=>seg<="0110000";when"0100"=>seg<="0011001";when"0101"=>seg<="0010010";when"0110"=>seg<="0000010";when"0111"=>seg<="1111000";when"1000"=>seg<="0000000";when"1001"=>seg<="0010000";when others=>seg<="0001000";end case;end process;end beha;功能仿真流程及结果:全编译通过后,进行仿真新建波形文件,在其中添加所需节点。

将clk设置为时钟信号,将en设置为高电平,将load 设置为低电平,将data_in设置为想要预置的数值。

运行Generate Functional Simulation Nest List命令产生能仿真的网标文件。

点击Start Simulation开始模拟仿真仿真结果:时序仿真流程及结果:全编译通过后,进行仿真设置其他步骤和功能仿真一致。

仿真结果:可以看出存在毛刺。

2.设计3-8译码器的VHDL程序编程思路:参考书上148页8-3编码器的例子,按照给定的3-8译码器真值表,改变其输入输出,即可编出3-8译码器的VHDL程序。

VHDL文本:library IEEE;use IEEE.std_logic_1164.all;use IEEE.STD_LOGIC_ARITH.ALL;use IEEE.STD_LOGIC_UNSIGNED.ALL;entity yima isport(en:in std_logic;data_in:in std_logic_vector(2 downto 0);seg:out std_logic_vector(7 downto 0));end yima;architecture beha of yima issignal q_temp:std_logic_vector(2 downto 0);signal qout:std_logic_vector(2 downto 0);beginprocess(en)beginif(en='1')thenq_temp<=data_in;elseqout<=qout;end if;end process;process(q_temp)begincase q_temp iswhen"000"=>seg<="00000001";when"001"=>seg<="00000010";when"010"=>seg<="00000100";when"011"=>seg<="00001000";when"100"=>seg<="00010000";when"101"=>seg<="00100000";when"110"=>seg<="01000000";when"111"=>seg<="10000000";when others=>seg<="00000000";end case;end process;end beha;仿真结果:三、心得体会第一次应用这个软件,刚刚上手,还不习惯;界面简单易懂,但是编程语言还不熟悉,相信在之后的两天有更好的提高。

实验二模十状态机与7段译码器显示一、实验目的、通过设计频率可选的模十状态机以及7段译码电路以进一步掌握VHDL硬件描述语言。

二、实验流程本设计有分频器、多路选择器、状态机和译码器。

时钟输入作为分频器的输入,输出时钟分别为2分频、4分频、8分频和16分频;四个频率的时钟信号由4选1的多路选择器选择其中之一作为状态机的时钟输入;使用选中的时钟频率作为输入驱动状态机按照以下的次序输出:0->2->5->6->1->9->4->8->7->3->0的顺序输出。

三、编程思路共四个模块:Mod16加法计数器、Mux 4选1、Mod10状态机、七段译码。

模块设计思路:1、Mod16加法计数器模十六加法计数器可以产生2、4、8、16分频的时钟信号。

2、Mux 4选1多路选择器为组合逻辑,可以使用case语句实现其功能。

流程图如下:3、Mod10状态机可以通过CASE语句结合状态转化图实现。

4、7段译码上一个实验已给出其VHDL文本。

通过case语句实现。

四、VHDL文本library IEEE;use IEEE.std_logic_1164.all;use IEEE.STD_LOGIC_ARITH.ALL;use IEEE.STD_LOGIC_UNSIGNED.ALL;entity mod10 isport(clk,rst:in std_logic;sel:in std_logic_vector(1 downto 0);seg:out std_logic_vector(6 downto 0));end mod10;architecture beha of mod10 issignal colk,clk_2,clk_4,clk_8,clk_16:std_logic;signal count,now_state,next_state:std_logic_vector(3 downto 0):="0000"; beginprocess(clk,rst,clk_2,clk_4,clk_8,clk_16)beginif(rst='0')thencount<="0000";elsif(clk'event and clk='0')thencount<=count+1;end if;clk_2<=count(0);clk_4<=count(1);clk_8<=count(2);clk_16<=count(3);end process;process(sel)begincase sel iswhen"00"=>colk<=clk_2;when"01"=>colk<=clk_4;when"10"=>colk<=clk_8;when"11"=>colk<=clk_16;when others=>null;end case;end process;process(colk,rst,now_state,next_state) beginif(rst='0')thennow_state<="0000";elsif(colk'EVENT AND colk='1')THEN now_state<=next_state;end if;end process;process(now_state)begincase now_state iswhen "0000"=>next_state<="0010";when "0010"=>next_state<="0101";when "0101"=>next_state<="0110";when "0110"=>next_state<="0001";when "0001"=>next_state<="1001";when "1001"=>next_state<="0100";when "0100"=>next_state<="1000";when "1000"=>next_state<="0111";when "0111"=>next_state<="0011";when "0011"=>next_state<="0000";when others=>next_state<="0000";end case;end process;process(now_state)begincase now_state iswhen"0000"=>seg<="1000000";when"0001"=>seg<="1111001";when"0010"=>seg<="0100100";when"0011"=>seg<="0110000";when"0100"=>seg<="0011001";when"0101"=>seg<="0010010";when"0110"=>seg<="0000010";when"0111"=>seg<="1111000";when"1000"=>seg<="0000000";when"1001"=>seg<="0010000";when others=>seg<="1000000"; end case;end process;end beha;五、仿真结果二分频:四分频:八分频:十六分频:不同时间混合分频:四、心得体会第二天,对编程语言更熟悉了,操作也不那么生疏。

相关主题