Advertisement
Guest User

Untitled

a guest
Dec 17th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 2.80 KB | None | 0 0
  1. library IEEE;
  2. use IEEE.STD_LOGIC_1164.ALL;
  3. USE ieee.std_logic_arith.all;
  4. entity koder is
  5. port(
  6.       clk : in STD_LOGIC;
  7.       din : in std_logic);
  8. end koder;
  9.  
  10. architecture Behavioral of koder is
  11.  
  12. TYPE STATE_TYPE IS (s0,s1,s2,s3);
  13. SIGNAL current_state : STATE_TYPE;
  14. SIGNAL next_state : STATE_TYPE;
  15.  
  16. component peremezh is
  17.     Port (clk : in std_logic;
  18.           din : in std_logic;
  19.           dintabl : in integer := 0;
  20.           dout : out std_logic_vector(999 downto 0));
  21. end component;          
  22.  
  23. signal check1 : integer := 0;
  24. signal peremezhdin : std_logic_vector(999 downto 0):=(others => '0');
  25. signal rst : std_logic := '0';
  26. signal findout: std_logic;
  27. type rom is array (0 to 2) of std_logic;
  28. signal soderzhimoe : rom := (others=> '0');
  29. ----------------------------------------------------------------------------
  30. begin  
  31.  
  32. clocked_proc : PROCESS (clk) BEGIN
  33.     IF rising_edge(clk) THEN
  34.         iF (rst = '0') THEN
  35.             current_state <= s0;
  36.         ELSE
  37.             current_state <= next_state;
  38.         END IF;
  39.     END IF;
  40.  END PROCESS clocked_proc;
  41.  --------------------------------------------------------------------------
  42.  nextstate_proc : PROCESS (clk,check1,current_state) BEGIN
  43.     CASE current_state IS
  44.         WHEN s0 =>
  45.                 if rising_edge(clk) then
  46.                         soderzhimoe(1) <= soderzhimoe(0);
  47.                         soderzhimoe(0) <= din xor (soderzhimoe(1) xor soderzhimoe(2));
  48.                         soderzhimoe(2) <= soderzhimoe(1);
  49.                 end if;
  50.                 IF (check1=1) THEN
  51.                 next_state <= s1;
  52.             END IF;
  53.         WHEN s1 =>
  54.             IF (check1=2) THEN
  55.                 next_state <= s2;
  56.             END IF;
  57.         WHEN s2 =>
  58.             IF (check1=3) THEN
  59.                 next_state <= s3;
  60.             end if;
  61.         WHEN OTHERS =>
  62.                 next_state <= s0;
  63.     END CASE;
  64.   END PROCESS nextstate_proc;
  65.  --------------------------------------------------------------
  66.  output_proc : PROCESS (clk, current_state) BEGIN
  67.  
  68.   CASE current_state IS
  69.   WHEN s0 =>
  70.   findout <= soderzhimoe(0) xor soderzhimoe(2);
  71.   WHEN s1 =>
  72.  
  73.   WHEN s2 =>
  74.  
  75.   WHEN s3 =>  
  76.  
  77.   WHEN OTHERS =>
  78.   NULL;
  79.   END CASE;
  80.   END PROCESS output_proc;
  81.  
  82. -----------------------------------------------------------------
  83.  
  84. process(clk) begin
  85.     if rising_edge(clk) then
  86.         FOR I in 0 to 999 loop
  87.             soderzhimoe(1) <= soderzhimoe(0);
  88.             soderzhimoe(0) <= peremezhdin(i) xor (soderzhimoe(1) xor soderzhimoe(2));
  89.             soderzhimoe(2) <= soderzhimoe(1);
  90.             findout <= soderzhimoe(0) xor soderzhimoe(2);
  91.         end loop;
  92.     end if;
  93. end process;
  94.      
  95. komp: peremezh
  96. port map(
  97.     clk => clk,
  98.     din => din,
  99.     dout => peremezhdin);      
  100.      
  101. end behavioral;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement