百进制计数器.docxVIP

  • 26
  • 0
  • 约2.4千字
  • 约 6页
  • 2022-07-22 发布于四川
  • 举报
百进制计数器 位设计要求:在数码管上实现0-99的递增与递减循环计数。 但 设计目的:通过实验更透彻的掌握编写程序的能力,并且拓展VHDL语言的应用o 但设计原理: 但 硬件要求:主芯片EMP240T100C5, 1个拨码开关,数码管 但设计步骤: .使用Quartus II新建一个工程ybjz,输入源程序后,进行编 译。 .进行仿真测试。 .进行引脚分配: Node Name Direction Location 1 ■ dk Input PIN_12 2 dis [6] Output PIN_99 3 dis [5] Output PIN_98 4 dis [可 Output PIN_97 5 dis [3] Output PIN_96 6 dis [2] Output PIN_95 7 dis[l] Output PIN_92 8 dis[0] Output PIN_91 9 r[5] Output PIN_6 10 r[4] Output PIN_5 11 r[3] Output PIN_4 12 r[2] Output PIN_3 13 r[l] Output PIN_2 14 r[0] Output PIN_1 15 ■ reset Input PIN_30 .下载结果到EMP240开发板,以及通过数码管验证结果是否 正确。 原理图: 源程序: 库library ieee; use ieee.std_logic_l 164.all;use ieee.std_logic_arith.all; use ieee.std_logic_unsigned.all;实体 entity ybjz2 isport(clk:in std」ogic; reset:in stdjogic;加法,减法计数的控制 dis:out std_logic_vector(6 downto 0)—数码管的段选-- r:out std_logic_vector(5 downto 0));--数码管的位选-- end ybjz2;结构体 architecture one of ybjz2 issignal m,n,z:integer range 0 to 9; signal clkl:std_logic;signal clk2:std_logic; signal led integer range 0 to 5;begin 1000分频与100分频程序process(clk) variable ent 1 integer range 0 to 25000;variable cnt2: integer range 0 to 1000; beginif rising_edge(clk) then if ent 1=25000 thencntl:=0; clkl=not clkl;if cnt2= 1000 then cnt2:=0;clk2=not clk2; elsecnt2:=cnt2+l; end if;else cntl:=cntl+l;end if; end if;end process; 计数process (clk2,reset) beginif clk2!event and clk2=T then if reset=,r thenif m=9 then m=0;if n-9 then n=0;else n=n+l;end if; elsem=m+l; end if;end if; if reset=,O, thenif m=0 then m=9;if n=0 then n=9;else n=n-l;end if; elsem=m-1; end if;end if; end if;end process; 数码管地址扫描process(clkl) beginif rising_edge(clkl) then if led=l thenled=0; elseled=led+1; end if;end if; end process;选择 process(clkl)begin case led iswhen 0=z=m;r=n01111 ln; when l=z=n;r=101111;when others=〉z=0;r= 111117; end case;end process; 七段译码process(clkl,z,led) begincase z is when 0=dis=01111ir,; when l=dis=0000110;when 2=dis=10110HH; when 3=dis=H 1001 111;when 4=dis=1100110; when 5=dis=1101101;when 6=dis=111 1101; when

文档评论(0)

1亿VIP精品文档

相关文档