Johnson Counter 4 bit & 8bit
Thứ Năm, 19 tháng 3, 2015 - Blade1407
Xem với phiên bản web đầy đủ
Xem với phiên bản web đầy đủ
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.NUMERIC_STD.ALL;
entity johnson_counter is
port (
DAT_O : out unsigned(3 downto 0);
RST_I : in std_logic;
CLK_I : in std_logic
);
end johnson_counter;
architecture Behavioral of johnson_counter is
signal temp : unsigned(3 downto 0):=(others => '0');
begin
DAT_O <= temp;
process(CLK_I)
begin
if( rising_edge(CLK_I) ) then
if (RST_I = '1') then
temp <= (others => '0');
else
temp(1) <= temp(0);
temp(2) <= temp(1);
temp(3) <= temp(2);
temp(0) <= not temp(3);
end if;
end if;
end process;
end Behavioral;
//////////////
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.NUMERIC_STD.ALL;
entity johnson_counter is
port (
DAT_O : out unsigned(3 downto 0);
RST_I : in std_logic;
CLK_I : in std_logic
);
end johnson_counter;
architecture Behavioral of johnson_counter is
signal temp : unsigned(3 downto 0):=(others => '0');
begin
DAT_O <= temp;
process(CLK_I)
begin
if( rising_edge(CLK_I) ) then
if (RST_I = '1') then
temp <= (others => '0');
else
temp(1) <= temp(0);
temp(2) <= temp(1);
temp(3) <= temp(2);
temp(0) <= not temp(3);
end if;
end if;
end process;
end Behavioral;
//////////////
library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.numeric_std.all;
use IEEE.std_logic_unsigned.all;
entity eightRC is
port(
CLK : in std_logic;
EN: in std_logic;
RST : in std_logic;
Q: out std_logic_vector(7 downto 0)
);
end eightRC;
architecture behavior of eightRC is
signal qs: std_logic_vector(7 downto 0);
begin
process(CLK, RST, EN)
begin
if(RST = '1') then
QS <= "11111110"; --initial state for QS
elsif (CLK'EVENT AND CLK = '1' and EN = '1') then --enable starts the shifting
QS(0) <= QS(7); --shift '0' to the left each clock edge, Q(0) gets Q(0) bit value
QS(7 downto 1) <= QS(6 downto 0);
end if;
Q <= QS;
end process;
end behavior;
Bài liên quan
- Hướng dẫn từng bước thực hiện mạch đếm 3 bit với phần mềm Quartus II
- Thiết kế mạch giải đa hợp 1 ngõ vào, 4 ngõ ra, 2 ngõ lựa chọn - VHDL
- Thiết kế mạch đa hợp 4 ngõ vào, 1 ngõ ra, 2 ngõ lựa chọn - VHDL
- Thiết kế mạch giải mã led 7 đoạn loại anode chung
- Thiết kế mạch mã hoá 4 đường sang 2 đường với ngõ vào tích cực mức cao - VHDL
Nhận xét
Không có nhận xét nào:
Đăng nhận xét