VHDL计数器程序.docx
《VHDL计数器程序.docx》由会员分享,可在线阅读,更多相关《VHDL计数器程序.docx(14页珍藏版)》请在冰豆网上搜索。
VHDL计数器程序
十五计数器
libraryieee;
useieee.std_logic_1164.all;
useieee.std_logic_unsigned.all;
ENTITYfiveteencoutIS
PORT(clk,reset,enable:
INstd_logic;count:
OUTstd_logic_vector(3downto0));
ENDfiveteencout;
ARCHITECTUREcounterOFfiveteencoutIS
SIGNALcount_int:
std_logic_vector(0to3);
BEGIN
PROCESS(clk,reset)
BEGIN
WAITUNTILrising_edge(clk);
IFreset='1'THEN
count_int<=(OTHERS=>'0');
ELSIFenable='1'THEN
IF(count_int="1110")THEN
count_int<="0000";
ELSE
count_int<=count_int1;
--ELSE
--NULL;
--IF(count_int="1001")THEN
--count_int<="0000";
ENDIF;
ENDIF;
ENDPROCESS;
count<=count_int;
--IF(reset='0')then
--q<="0000";
---ELSIF(clk'eventandclk='1')THEN
--q<=q1;
--IF(q<="1001")then
--q<="0000";
---ENDIF;
--IF(reset<='1')THEN
--q<="00";
--ELSIF
--waituntil(clk'eventandclk='1');
--WAITUNTIL(clk'EVENTANDclk='1');
--WAITUNTIL(clock'EVENTANDclock='1');
--q<=q'1';
--endif;
--count<=q;
--WAITUNTILclock='1';
--if(clock'eventandclock='1')then
--WAITUNTILrising_edge(clock);
--clock'eventandclock='1';
--count<=0;
--WAITUNTIL(clock'EVENTANDclock='1');
--WAITriseedgeclock='1';
--if(clock'eventandclock='1')then
--WAITUNTILrising_edge(clock);
--count<=1;
--WAITUNTIL(clock'EVENTANDclock='1');
--WAITUNTILclock='1';
--if(clock'eventandclock='1')then
--WAITUNTILrising_edge(clock);
--count<=2;
--endif;
--endif;
--endif;
--ENDPROCESS;
ENDcounter;
十四计数器
libraryieee;
useieee.std_logic_1164.all;
useieee.std_logic_unsigned.all;
ENTITYfourteencoutIS
PORT(clk,reset,enable:
INstd_logic;count:
OUTstd_logic_vector(3downto0));
ENDfourteencout;
ARCHITECTUREcounterOFfourteencoutIS
SIGNALcount_int:
std_logic_vector(0to3);
BEGIN
PROCESS(clk,reset)
BEGIN
WAITUNTILrising_edge(clk);
IFreset='1'THEN
count_int<=(OTHERS=>'0');
ELSIFenable='1'THEN
IF(count_int="1101")THEN
count_int<="0000";
ELSE
count_int<=count_int1;
--ELSE
--NULL;
--IF(count_int="1001")THEN
--count_int<="0000";
ENDIF;
ENDIF;
ENDPROCESS;
count<=count_int;
--IF(reset='0')then
--q<="0000";
---ELSIF(clk'eventandclk='1')THEN
--q<=q1;
--IF(q<="1001")then
--q<="0000";
---ENDIF;
--IF(reset<='1')THEN
--q<="00";
--ELSIF
--waituntil(clk'eventandclk='1');
--WAITUNTIL(clk'EVENTANDclk='1');
--WAITUNTIL(clock'EVENTANDclock='1');
--q<=q'1';
--endif;
--count<=q;
--WAITUNTILclock='1';
--if(clock'eventandclock='1')then
--WAITUNTILrising_edge(clock);
--clock'eventandclock='1';
--count<=0;
--WAITUNTIL(clock'EVENTANDclock='1');
--WAITriseedgeclock='1';
--if(clock'eventandclock='1')then
--WAITUNTILrising_edge(clock);
--count<=1;
--WAITUNTIL(clock'EVENTANDclock='1');
--WAITUNTILclock='1';
--if(clock'eventandclock='1')then
--WAITUNTILrising_edge(clock);
--count<=2;
--endif;
--endif;
--endif;
--ENDPROCESS;
ENDcounter;
十三计数器
libraryieee;
useieee.std_logic_1164.all;
useieee.std_logic_unsigned.all;
ENTITYthireteencoutIS
PORT(clk,reset,enable:
INstd_logic;count:
OUTstd_logic_vector(3downto0));
ENDthireteencout;
ARCHITECTUREcounterOFthireteencoutIS
SIGNALcount_int:
std_logic_vector(0to3);
BEGIN
PROCESS(clk,reset)
BEGIN
WAITUNTILrising_edge(clk);
IFreset='1'THEN
count_int<=(OTHERS=>'0');
ELSIFenable='1'THEN
IF(count_int="1100")THEN
count_int<="0000";
ELSE
count_int<=count_int1;
--ELSE
--NULL;
--IF(count_int="1001")THEN
--count_int<="0000";
ENDIF;
ENDIF;
ENDPROCESS;
count<=count_int;
--IF(reset='0')then
--q<="0000";
---ELSIF(clk'eventandclk='1')THEN
--q<=q1;
--IF(q<="1001")then
--q<="0000";
---ENDIF;
--IF(reset<='1')THEN
--q<="00";
--ELSIF
--waituntil(clk'eventandclk='1');
--WAITUNTIL(clk'EVENTANDclk='1');
--WAITUNTIL(clock'EVENTANDclock='1');
--q<=q'1';
--endif;
--count<=q;
--WAITUNTILclock='1';
--if(clock'eventandclock='1')then
--WAITUNTILrising_edge(clock);
--clock'eventandclock='1';
--count<=0;
--WAITUNTIL(clock'EVENTANDclock='1');
--WAITriseedgeclock='1';
--if(clock'eventandclock='1')then
--WAITUNTILrising_edge(clock);
--count<=1;
--WAITUNTIL(clock'EVENTANDclock='1');
--WAITUNTILclock='1';
--if(clock'eventandclock='1')then
--WAITUNTILrising_edge(clock);
--count<=2;
--endif;
--endif;
--endif;
--ENDPROCESS;
ENDcounter;
十二计数器
libraryieee;
useieee.std_logic_1164.all;
useieee.std_logic_unsigned.all;
ENTITYtwelvecoutIS
PORT(clk,reset,enable:
INstd_logic;count:
OUTstd_logic_vector(3downto0));
ENDtwelvecout;
ARCHITECTUREcounterOFtwelvecoutIS
SIGNALcount_int:
std_logic_vector(0to3);
BEGIN
PROCESS(clk,reset)
BEGIN
WAITUNTILrising_edge(clk);
IFreset='1'THEN
count_int<=(OTHERS=>'0');
ELSIFenable='1'THEN
IF(count_i