专业课小实验

VHDL综合练习
一、实验目的

  1. 掌握VHDL基本编程方法;
  2. 掌握一些常用电路的VHDL设计;
  3. 复习Quartus II设计编译和仿真验证。
    二、实验要求
  4. 用VHDL语言完成10进制计数器的设计。
  5. 用VHDL语言完成占空比为50%的10分频器的设计。
  6. 用VHDL语言完成驱动共阴极数码管的显示译码器的设计。
  7. 在QuartusⅡ软件平台上完成编译、仿真。
    三、主要仪器设备
    电脑、Quartus Ⅱ软件平台
    四、实验内容
    1.10进制计数器程序
    (1)输入文本:
    library ieee;
    use ieee.std_logic_1164.all;
    use ieee.std_logic_unsigned.all;

entity cnt10 is
port(
clk:in std_logic;
en :out std_logic;
y:out integer range 0 to 10);
end cnt10;
architecture a of cnt10 is
signal q_temp: integer range 0 to 10;
begin
process(clk)
begin
if(clk’event and clk=‘1’)then
if
q_temp = 9 then
en <= ‘1’;
q_temp <= 0;

	else
		 q_temp <= q_temp+1;
		 en <= '0';
      
	end if;
end if;

y<=q_temp;
end process;
end a;;
(2)仿真

2.10分频器程序
(1)输入文本:
Library ieee;
Use ieee.std_logic_1164.all;
Use ieee.std_logic_unsigned.all;
Use ieee.std_logic_arith.all;

Entity fdiv is
generic(N: integer:=10); --rate=N,baiN是偶数
port(
clkin: IN std_logic;
clkout: OUT std_logic
);
End fdiv;
Architecture a of fdiv is
signal cnt: integer range 0 to n-1;
Begin
process(clkin) --计数
begin
if(clkin’event and clkin=‘1’) then
if(cnt<n-1) then
cnt <= cnt+1;
else
cnt <= 0;
end if;
end if;
end process;

process(cnt) --根据计数值du,控制输出时钟脉冲的高、低zhi电平
begin
if(cnt<n/2) then
clkout <= ‘1’;
else
clkout <= ‘0’;
end if;
end process;

End a;
(2)仿真

3.显示译码器程序
(1)输入文本:
Library ieee;
Use ieee.std_logic_1164.all;
Entity QELED7 is
PORT(DATA:IN STD_LOGIC_VECTOR(3 DOWNTO 0);
a,b,c,d,e,f,g:out std_logic);
end QELED7;
Architecture LED of QELED7 is
signal y: STD_LOGIC_VECTOR(6 DOWNTO 0);
begin
process(DATA)
begin
case DATA is
when “0000”=>y<=“1111110” ;
when “0001”=>y<=“0110000” ;
when “0010”=>y<=“1101101” ;
when “0011”=>y<=“1111001” ;
when “0100”=>y<=“0110011” ;
when “0101”=>y<=“1011011” ;
when “0110”=>y<=“1011111” ;
when “0111”=>y<=“1110000” ;
when “1000”=>y<=“1111111” ;
when “1001”=>y<=“1111011” ;
when others=>null;
end case;
a<=y(6);b<=y(5);c<=y(4);
d<=y(3);e<=y(2);f<=y(1);g<=y(0);
end process;
end;
(2)仿真

五、实验结果及分析
(1)10进制计数器
当时钟上升沿到来时产生计数加一,当计数为9(0111)时下一个时钟上升沿到来时计数器清零并产生一个时钟周期的进位信号。

(2)占空比为50%的10分频器
由图可知实验结果正确,设置一个5进制计数器,每当其记满是反转输出信号,也就是每10个周期信号进行一次输出周期信号,实现占空比为50%的10分频器。

3)驱动共阴极数码管的显示译码器

扫描二维码关注公众号,回复: 11783534 查看本文章

共阴极是高电平工作所以0时是除g外都是高电平,可以实现显示0
其他数字也可以依次类推。有图可知我的实验结果正确

猜你喜欢

转载自blog.csdn.net/weixin_45706856/article/details/106608454