欢迎来到天天文库
浏览记录
ID:59599737
大小:135.50 KB
页数:9页
时间:2020-11-14
《计数器的VHDL设计.doc》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、实验名称:计数器的VHDL设计一、带高电平使能信号,低电平清零信号,低电平置数信号的十进制计数器的VHDL设计1.实体框图2.程序设计①编译前的程序Libraryieee;Useieee.std_logic_1164.all;Useieee.std_logic_unsigned.all;Entitycnt10isPort(clk,RST,SET,EN:instd_logic;CQ:outstd_logic_vector(3downto0);Cout:outstd_logic);Endcnt10;Arc
2、hitectureoneofcnt10isBeginProcess(clk,RST,SET,EN)VariableCQ1:std_logic_vector(3downto0);BeginifRST='0'ThenCQ1:=(others=>'0');elsifclk'eventandclk='1'thenifSET='0'ThenCQ1:=(others=>'1');elsifEN='1'ThenifCQ1<9ThenCQ1:=CQ1+1;elseCQ1:=(others=>'0');endif;en
3、dif;endif;ifCQ1=9Thencout<='1';elsecout<='0';endif;CQ<=CQ1;Endprocess;Endone;②程序编译错误情况错误:Error(10500):VHDLsyntaxerrorat/cnt10.vhd(12)neartext"?;expecting":",or","标点符号格式输入不对引起的,切换到英文输入模式重新输入即可③正确的程序Libraryieee;Useieee.std_logic_1164.all;Useieee.std_logic
4、_unsigned.all;Entitycnt10isPort(clk,RST,SET,EN:instd_logic;CQ:outstd_logic_vector(3downto0);Cout:outstd_logic);Endcnt10;Architectureoneofcnt10isBeginProcess(clk,RST,SET,EN)VariableCQ1:std_logic_vector(3downto0);BeginifRST='0'ThenCQ1:=(others=>'0');elsif
5、clk'eventandclk='1'thenifSET='0'ThenCQ1:=(others=>'1');elsifEN='1'ThenifCQ1<9ThenCQ1:=CQ1+1;elseCQ1:=(others=>'0');endif;endif;endif;ifCQ1=9Thencout<='1';elsecout<='0';endif;CQ<=CQ1;Endprocess;Endone;3.仿真波形图4.仿真波形分析当低电平清零信号有效时,计数器清零;当低电平置数信号有效时,计数器置数使能信
6、号为高电平且脉冲上升沿有效时,计数器开始计数(从0到9)为十进制计数一、64进制的二进制计数器的VHDL设计1.实体框图2.程序设计①编译前的程序Libraryieee;Useieee.std_logic_1164.all;Useieee.std_logic_unsigned.all;Entitycnt64isPort(clk:instd_logic;D:instd_logic_vector(5downto0);Q:outstd_logic_vector(5downto0));Endcnt64;Arc
7、hitecturetwoofcnt64isSignalQ1:std_logic_vector(5downto0);BeginProcess(clk)Beginifclk'eventandclk='1'Thenif(Q1="")ThenQ1<="";elseQ1<=Q1+1;endif;Endprocess;Q<=Q1;Endtwo;②程序编译错误情况Error(10500):VHDLsyntaxerroratcnt64.vhd(18)neartext"process";expecting"if";Er
8、ror(10500):VHDLsyntaxerroratcnt64.vhd(20)neartext"two";expecting"if"经过检查,发现原程序少了ENDIF,加上即可;③正确的程序Libraryieee;Useieee.std_logic_1164.all;Useieee.std_logic_unsigned.all;Entitycnt64isPort(clk:instd_logic;D:instd_logic_vector(5downto
此文档下载收益归作者所有