Advertisement
nex036ara

automat

Nov 22nd, 2011
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 2.92 KB | None | 0 0
  1. ----------------------------------------------------------------------------------
  2. -- Company:
  3. -- Engineer:
  4. --
  5. -- Create Date:    14:10:03 11/22/2011
  6. -- Design Name:
  7. -- Module Name:    automat - Behavioral
  8. -- Project Name:
  9. -- Target Devices:
  10. -- Tool versions:
  11. -- Description:
  12. --
  13. -- Dependencies:
  14. --
  15. -- Revision:
  16. -- Revision 0.01 - File Created
  17. -- Additional Comments:
  18. --
  19. ----------------------------------------------------------------------------------
  20.  
  21. PACKAGE TIPOVI IS
  22.     TYPE tSTANJA IS (S0, S1, S2, S3);
  23. END TIPOVI;
  24.  
  25. library IEEE;
  26. use IEEE.STD_LOGIC_1164.ALL;
  27. use IEEE.STD_LOGIC_ARITH.ALL;
  28. use work.TIPOVI.ALL;
  29.  
  30.  
  31.  
  32. -- Uncomment the following library declaration if using
  33. -- arithmetic functions with Signed or Unsigned values
  34. --use IEEE.NUMERIC_STD.ALL;
  35.  
  36. -- Uncomment the following library declaration if instantiating
  37. -- any Xilinx primitives in this code.
  38. --library UNISIM;
  39. --use UNISIM.VComponents.all;
  40.  
  41. entity automat is
  42.     Port ( iCLK : in  STD_LOGIC;
  43.            inRST : in  STD_LOGIC;
  44.            iW : in  STD_LOGIC_VECTOR (1 downto 0);
  45.            oZ : out  STD_LOGIC);
  46. end automat;
  47.  
  48. architecture Behavioral of automat is
  49.     signal Z0: STD_LOGIC := '0';
  50.     signal Z1: STD_LOGIC := '1';
  51.     signal sSTANJE, sSLEDECE_STANJE: tSTANJA;
  52.    
  53.     --signal W0: STD_LOGIC_VECTOR(1 downto 0):= "00";
  54.     --signal W1: STD_LOGIC_VECTOR(1 downto 0):= "01";
  55.     --signal W2: STD_LOGIC_VECTOR(1 downto 0):= "10";
  56.    
  57. begin
  58.     process(iW, sSTANJE) begin
  59.         case sSTANJE is
  60.        
  61.         ---stanje S0 = "00"
  62.         when S0 =>
  63.             case iW is
  64.             when "00" => sSLEDECE_STANJE <= S1; oZ <= Z0;
  65.             when "01" => sSLEDECE_STANJE <= S1; oZ <= Z1;
  66.             when "10" => sSLEDECE_STANJE <= S2; oZ <= Z1;
  67.             when others => sSLEDECE_STANJE <= sSLEDECE_STANJE; oZ <= Z1;
  68.         end case;
  69.         ---stanje S1 = "01"
  70.         when S1 =>
  71.             case iW is
  72.             when "00" => sSLEDECE_STANJE <= S0;  oZ<= Z1;
  73.             when "01" => sSLEDECE_STANJE <= S1; oZ<= Z0;
  74.             when "10" => sSLEDECE_STANJE <= S1; oZ <= Z0;
  75.             when others => sSLEDECE_STANJE <= sSLEDECE_STANJE; oZ <= Z0;
  76.         end case;
  77.         ----stanje S2 = "10"
  78.         when S2 =>
  79.         case iW is
  80.             when "00" => sSLEDECE_STANJE <= S3; oZ<=Z0;
  81.             when "01" => sSLEDECE_STANJE <= S1; oZ<= Z1;
  82.             when "10" => sSLEDECE_STANJE <=S0; oZ <=Z1;
  83.             when others => sSLEDECE_STANJE <= sSLEDECE_STANJE; oZ <= Z1;
  84.         end case;
  85.         ---stanje S3 = "11"
  86.         when S3 =>
  87.         case iW is
  88.             when "00" => sSLEDECE_STANJE <= S0; oZ<= Z1;
  89.             when "01" => sSLEDECE_STANJE <=S1; oZ <= Z0;
  90.             when "10" => sSLEDECE_STANJE <= S0; oZ <= Z0;
  91.             when others => sSLEDECE_STANJE <= sSLEDECE_STANJE; oZ <= Z0;
  92.         end case;
  93.     end case;
  94. end process;
  95.  
  96.  
  97. --- flip flopovi za pamcenje koda trenutnog stanja
  98.         ---reset je sinhron, u listi osetljivosi nema inRST
  99.         process(iCLK) begin
  100.             if(iCLK'event and iCLK= '1') then
  101.                 if(inRST = '1') then
  102.                     sSTANJE <= S0;
  103.                 else
  104.             sSTANJE<= sSLEDECE_STANJE;
  105.             end if;
  106.         end if;
  107.     end process;
  108.        
  109.  
  110.  
  111.  
  112. end Behavioral;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement