⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 counter.vhd

📁 一个有效位为4位的十进制的数字频率计,VHDL语言编写
💻 VHD
字号:
--
--  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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -