counter.vhd

来自「一个有效位为4位的十进制的数字频率计,VHDL语言编写」· VHDL 代码 · 共 45 行

VHD
45
字号
--
--  File: counter.vhd
--  十进制计数器;
--  on_off:闸门信号,clr=0:清零
--  value:十进制计数值,cary:进位信号

library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.std_logic_unsigned.all;

entity counter is
	port (
		clk: in STD_LOGIC;
		clkclr: in STD_LOGIC;
		on_off: in STD_LOGIC;
		clr: in STD_LOGIC;			
		cary: out STD_LOGIC;
		value: out INTEGER range 0 to 9
	);
end counter;   


architecture rtl of counter is
signal temp:INTEGER range 0 to 9; 
begin 
	process(clk,clr,clkclr)
	begin	
		if(clr='1' or on_off='0') then  cary<='0';temp<=0;	
     	elsif rising_edge(clk) then
   		    if(on_off='1') then	
				if(temp=9) then temp<=0;cary<='1';
				else temp<=temp+1;cary<='0';
				end if;
          end if;
    end if;
		
				
	end process;
				  	
   value<=temp;	 
   
end rtl;


⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?