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

📄 counter.txt

📁 Decimal counter which is counting from 256 to 0. After that there will appear logic "1" in out. You
💻 TXT
字号:
Program


library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;

entity deton is

port(
clock,reset: in std_logic;
p1: in std_logic_vector(3 downto 0);
digit1,digit2: out std_logic_vector(7 downto 1);
lunch: out std_logic);
end deton;

architecture a1 of deton is

component licznik
port(clock,stop,reset: in std_logic;
       wy: out std_logic_vector(7 downto 0));
end component;

component hex2led
port(I: in std_logic_vector(3 downto 0);
       S: out std_logic_vector(7 downto 1));
end component;



component detektor
port(clock: in std_logic;
       p1: in std_logic_vector(3 downto 0);
       carry: out std_logic);
end component

-- sygnaly pomocnicze

signal wyj: std_logic_vector(7 downto 0);
signal b: std_logic;

begin

U1: licznik port map(clock=>clock, wy=>wyj, stop=>b,reset=>reset);
U2: hex2led port map(I=>wyj(7 downto 4), s=>digit1);
U3: hex2led port map(I=>wyj(3 downto 0), s=>digit2);
U4: detektor port map(clock=>clock, carry=>b,p1=>p1);
end;

Komponenty: 

-- licznik.vhd

library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity licznik is

port(
clock,reset,stop: in std_logic;
wy: out std_logic_vector(7 downto 0);
lunch: out std_logic);

end;

architecture beh of licznik is
begin

process(clock,reset)
variable Q_int: unsigned(7 downto 0);
begin

if reset='1' or stop='1' then
Q_int:="11111111";

elsif rising_edge(clock) then
if Q_int="00000000" then lunch<='1' ;

else

Q_int:=Q_int-1;
end if;
end if;
wy <=std_logic_vector(Q_int);

end process;
end;






-- hex2led.vhd

library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;

entity hex2led is
port( i: in std_logic_vector ( 3 downto 0);
        s: out std_logic_vector(7 downto 1));
end hex2led;

architecture hex2led of hex2led is
begin
with i select
s<= "1000000" when "0000",    -- 0
       "1111001" when "0001",    -- 1
       "0100100" when "0010",    -- 2
       "0110000" when "0011",    -- 3
       "0011001" when "0100",    -- 4
       "0010010" when "0101",    -- 5
       "0000010" when "0110",    -- 6
       "1111000" when "0111",    -- 7
       "0000000" when "1000",    -- 8
       "0010000" when "1001",    -- 9
       "0001000" when "1010",    -- A
       "0000011" when "1011",    -- b
       "1000110" when "1100",    -- C
       "0100001" when "1101",    -- d
       "0000110" when "1110",    -- E
       "0001110" when "1111",    -- F
       "1100011" when others;     -- n 

⌨️ 快捷键说明

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