nemecon

Untitled

Jun 19th, 2015
271
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 4.07 KB | None | 0 0
  1. library ieee;
  2. use ieee.std_logic_1164.all;  -- Zasrany knihovny - hodnoty, kterych muzou nabyvat ty vektory...
  3.  
  4. entity detektor is   -- definice pro okolni svet (krabicka, ktera ma vstupy vst,clk,res a vystupy vyst detekce1,detekce2)...
  5.     port(vst,clk : in std_logic; -- deklarace vstupu a jejich typu
  6.             vyst : out std_logic;-- deklarace vystupu a jejich typu - tohle je jen std_logic protoze to neni vektor je to jen 0 nebo 1
  7.             detekce1,detekce2 : out std_logic_vector(4 downto 0)-- deklarace vystupu a jejich typu - vektor tzn neco jako (00001) nebo 10101...
  8.           );
  9. end detektor;
  10.  
  11. architecture det16 of detektor is  -- deklarace architektury (funkčnost té entity)..
  12. signal ps,vnitrnistav :std_logic_vector(4 downto 0); -- deklarace signalu jde to jen tady v begin už ne, jeste se tu muzou deklarovat variables a constant...
  13. signal pomocne :std_logic_vector(4 downto 0); -- 4 downto 0 znamena, ze to je petibitovy vektor s nejvyssim radem v levo opakem je 0 to 4, tam je nejvyssi rad v pravo...
  14.     begin
  15.    
  16.     process (vnitrnistav,vst) -- process se spusti automaticky a v zavorkach jsou vždycky sračky, který když se zmeni tak se ten process spusti...
  17.  
  18.         begin
  19.          case Vnitrnistav is
  20.             when "00000" => vyst <= '0'; if (vst = '1') then ps <= "00001";  else ps <= "00000";  end if; -- tohle je prepsana vyvojova tabulka posloupnosti, vlastně prechodovy funkce
  21.             when "00001" => vyst <= '0'; if vst = '1' then ps <= "00010";  else ps <= "00000";  end if;  -- vzdycky je to case kde je aktualni vnitrni stav tady 00001 coz je s1 jakoby.
  22.             when "00010" => vyst <= '0'; if vst = '1' then ps <= "00010";  else ps <= "00011";  end if; -- if funguje stejne jak v C# takze kdyz je x = 1 tak to nastavi ps na 00010 - pristi vnitrni stav...
  23.            when "00011" => vyst <= '0'; if vst = '1' then ps <= "00001";  else ps <= "00100";  end if;  -- pokud je x = 0 tak se provadi else a nastavi to ps na jinou hodnotu...
  24.             when "00100" => vyst <= '0'; if vst = '1' then ps <= "00001";  else ps <= "00101";  end if;
  25.             when "00101" => vyst <= '0'; if vst = '1' then ps <= "00110";  else ps <= "00000";  end if;
  26.             when "00110" => vyst <= '0'; if vst = '1' then ps <= "00010";  else ps <= "00111";  end if;
  27.             when "00111" => vyst <= '0'; if vst = '1' then ps <= "01000";  else ps <= "00000";  end if;
  28.             when "01000" => vyst <= '0'; if vst = '1' then ps <= "01001";  else ps <= "00000";  end if;
  29.             when "01001" => vyst <= '0'; if vst = '1' then ps <= "00010";  else ps <= "01010";  end if;
  30.             when "01010" => vyst <= '0'; if vst = '1' then ps <= "00001";  else ps <= "01011";  end if;
  31.             when "01011" => vyst <= '0'; if vst = '1' then ps <= "01100";  else ps <= "00000";  end if;
  32.             when "01100" => vyst <= '0'; if vst = '1' then ps <= "01101";  else ps <= "00000";  end if;
  33.             when "01101" => vyst <= '0'; if vst = '1' then ps <= "00010";  else ps <= "01110";  end if;
  34.             when "01110" => vyst <= '0'; if vst = '1' then ps <= "01111";  else ps <= "00000";  end if;
  35.             when "01111" => vyst <= '0'; if vst = '1' then ps <= "00010";  else ps <= "10000";  end if;
  36.             when "10000" => vyst <= '1'; if vst = '1' then ps <= "00001";  else ps <= "00000";  end if;
  37.             when others => ps <= "00000"; -- tenhle radek podchytava ostatni kombinace promennych ktery tady nejsou v tom seznamu case uvedeny treba 11111.
  38.             end case;
  39.            
  40.             detekce1 <= vnitrnistav; -- tenhle radek jsem pouzil pro detekci vnitrniho stavu (aktualniho)
  41.             detekce2 <= ps; -- tenhle zase pro detekci pristiho stavu.
  42.            
  43.            
  44.            
  45.            
  46.         end process;
  47.        
  48.     process(clk)  -- tohle aby to fungovalo tak jak ma tak je to vlastne ten klopny obvod D - process reaguje na zmenu clk
  49.         begin
  50.             if rising_edge(clk) then vnitrnistav <= ps; else vnitrnistav <= vnitrnistav; end if; -- pokud je nabezna hrana signalu clk tak se provede prirazeni ps do vnitrniho stavu... tim se pak zase ale spusti horni process
  51.     end process;
  52. end det16; -- konec architektury...
  53.  
  54. -- prirazuje se (kdekoliv) <= timhle znakem protoze nejakyho picuse napadlo ze = je pouzito pro porovnavani... :D
  55. -- := tenhle znak znamena prirazeni ale jen pocatecni hodnoty...
Advertisement
Add Comment
Please, Sign In to add comment