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;
0 nhận xét:
Đăng nhận xét