CPLD设计的数码管驱动显示电路

[09-12 18:34:30]   来源:http://www.88dzw.com  EDA/PLD   阅读:8650

文章摘要:use ieee.std_logic_unsigned.all;entity cn8 isport(clk:in std_logic;cout:out std_logic_vector(2 downto 0));end cn8;architecture rtl of cn8 issignal q: std_logic_vector(2 downto 0);beginprocess(clk)beginif (clk'event and clk='1' ) thenif (q=7) thenq<="000";elseq<=q+1;end if

CPLD设计的数码管驱动显示电路,标签:eda技术,eda技术实用教程,http://www.88dzw.com

  use ieee.std_logic_unsigned.all;

  entity cn8 is

  port(clk:in std_logic;

  cout:out std_logic_vector(2 downto 0));

  end cn8;

  architecture rtl of cn8 is

  signal q: std_logic_vector(2 downto 0);

  begin

  process(clk)

  begin

  if (clk'event and clk='1' ) then

  if (q=7) then

  q<="000";

  else

  q<=q+1;

  end if;

  end if;

  end procESS;

  cout<=q;

  end rtl;

  1.3.2 3-8 线译码器模块

  3-8 线译码器模块DECODER3_8 如图1.6 所示。DECODER3_8 模块的输入端是A[2..0]接收时钟脉冲计数器CN8 模块的输出信号,经过译码后输出信号Q[7..0]分别接八个数码管的阴极Vss7、Vss6、Vss5、Vss4、Vss3、Vss2、Vss1、Vss0,使对应的数码管的阴极为低电平,对应的数码管被点亮。要显示八位数字,需要八个输出端,所以做成3-8 线译码器。


图 1.6 3-8 线译码器模块DECODER3_8

  library ieee;

  use ieee.std_logic_1164.all;

  entity decoder3_8 is

  port(a:in std_logic_vector(2 downto 0);

  q:out std_logic_vector(7 downto 0));

  end decoder3_8;

  architecture rtl of decoder3_8 is

  begin

  process(a)

  begin

  case a is

  when "000"=>q<="11111110";

  when "001"=>q<="11111101";

  when "010"=>q<="11111011";

  when "011"=>q<="11110111";

  when "100"=>q<="11101111";

  when "101"=>q<="11011111";

  when "110"=>q<="10111111";

  when thers=>q<="01111111";

  end case;

  end process;

  end rtl;

  1.3.3 八选一数据选择模块

  八选一数据选择模块 SEL81 如图1.7 所示。SEL81 模块输入信号一个是数据选择器SEL81的地址码SEL[2..0],另一部分是数据信息A[3..0] ~H[3..0]。地址码SEL[2..0]来自时钟脉冲计数器CN8,由地址码SEL[2..0]决定输出哪个输入数据。输出信号是Q[3..0]。


图 1.7 八选一数据选择模块SEL81

  library ieee;

  use ieee.std_logic_1164.all;

  entity sel81 is

  port(sel:in std_logic_vector(2 downto 0);

  a,b,c,d,e,f,g,h:in std_logic_vector(3 downto 0);

  q:out std_logic_vector(3 downto 0));

  end sel81;

  architecture rtl of sel81 is

  begin

  process(a,b,c,d,e,f,g,h,sel)

  variable cout: std_logic_vector(3 downto 0);

  begin

  case (sel) is

  when "000"=>cout:=a;

  when "001"=>cout:=b;

  when "010"=>cout:=c;

  when "011"=>cout:=d;

  when "100"=>cout:=e;

  when "101"=>cout:=f;

  when "110"=>cout:=g;

  when thers=>cout:=h;

  end case;

  q<=cout;

  end process;

  end rtl;

  1.3.4 七段译码器模块

  七段译码器模块 DISP 如图1.8 所示。DISP 模块是七段译码器,将输入的4 位二进制数转换为数码显示管所对应的数字。例如输入为4 位二进制数0000 的时候,使数码显示管显示0,则要七段译码器输出为0111111,即g 段为0,g 段发光二极管不亮,其他发光二极管被点亮,显示效果为0。DISP 模块输入信号D[3..0]接到八选一数据选择模块的输出信号Q[3..0];七段译码器输出信号Q[6..0]接数码管的a~g 管脚。

上一页  [1] [2] [3]  下一页


Tag:EDA/PLDeda技术,eda技术实用教程EDA/PLD
分类导航
最新更新
热门排行