Advertisement
Guest User

Untitled

a guest
Jan 24th, 2017
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 2.98 KB | None | 0 0
  1. library IEEE;
  2. use IEEE.STD_LOGIC_1164.ALL;
  3. use IEEE.STD_LOGIC_UNSIGNED.ALL;
  4. use IEEE.STD_LOGIC_ARITH.ALL;
  5.  
  6. -- Uncomment the following library declaration if using
  7. -- arithmetic functions with Signed or Unsigned values
  8. --use IEEE.NUMERIC_STD.ALL;
  9.  
  10. -- Uncomment the following library declaration if instantiating
  11. -- any Xilinx primitives in this code.
  12. --library UNISIM;
  13. --use UNISIM.VComponents.all;
  14.  
  15. entity z_54 is
  16. port(
  17.         clk:in std_logic;
  18.         --button:in std_logic;
  19.         seg:out std_logic_vector(2 downto 0);
  20.           anode: out std_logic_vector(3 downto 0) := "1110";
  21.           segpom: out std_logic_vector(4 downto 0) := "11111";
  22.         led:out std_logic_vector(1 downto 0)
  23.         );
  24. end z_54;
  25.  
  26. architecture Behavioral of z_54 is
  27. signal clk_final:std_logic;
  28. begin
  29. s1:entity work.freq_div generic map(100_000_000)port map(clk, clk_final);
  30.  
  31. process(clk_final)
  32. variable counter:integer range 0 to 68 := 0;
  33. begin
  34.     if(clk_final'event and clk_final = '1') then
  35.         counter := counter + 1;
  36.     end if;
  37.    
  38.     --crveno--
  39.      if(counter < 32) then
  40.         seg <= "110";
  41.         led <= "10";
  42.      --crveno i žuto--
  43.     elsif(counter = 32) then
  44.         seg <= "100";
  45.         led <= "01";
  46.      --zeleno--
  47.     elsif(counter < 65 and counter > 32) then
  48.         seg <= "011";
  49.         led <= "01";
  50.      --žuto--
  51.     elsif(counter = 65) then
  52.         seg <= "101";
  53.         led <= "01";
  54.      elsif(counter > 65) then  
  55.         counter := 0;
  56.      else
  57.           anode <= "1110";
  58.     end if;
  59.    
  60.     --if(button = '1' and counter > 32) then
  61.     --    counter := 60;
  62.     --end if;
  63.  
  64. end process;
  65. end Behavioral;
  66.  
  67. --------------------------------------------------------
  68.  
  69. library IEEE;
  70. use IEEE.STD_LOGIC_1164.ALL;
  71. use IEEE.STD_LOGIC_UNSIGNED.ALL;
  72. use IEEE.STD_LOGIC_ARITH.ALL;
  73.  
  74. -- Uncomment the following library declaration if using
  75. -- arithmetic functions with Signed or Unsigned values
  76. --use IEEE.NUMERIC_STD.ALL;
  77.  
  78. -- Uncomment the following library declaration if instantiating
  79. -- any Xilinx primitives in this code.
  80. --library UNISIM;
  81. --use UNISIM.VComponents.all;
  82.  
  83. entity freq_div is
  84. generic(nfclk:natural:=100_000_000);
  85. port(
  86.         clk:in std_logic;
  87.         clk_final:buffer std_logic
  88.      );
  89. end freq_div;
  90.  
  91. architecture Behavioral of freq_div is
  92.  
  93. begin
  94. process(clk)
  95. variable temp:integer range 0 to nfclk/2:=0;
  96. begin
  97.     if(clk'event and clk='1')then
  98.         temp:=temp+1;
  99.         if(temp>=nfclk/2)then
  100.             clk_final<=not clk_final;
  101.             temp:=0;
  102.         end if;
  103.     end if;
  104. end process;
  105.  
  106. end Behavioral;
  107.  
  108. ---------------------------------------
  109.  
  110. NET "clk" LOC = V10;
  111. NET "seg[0]" LOC = T17;
  112. NET "seg[1]" LOC = L14;
  113. NET "seg[2]" LOC = U18;
  114. NET "led[0]" LOC = U16;
  115. NET "led[1]" LOC = V16;
  116. NET "anode[0]" LOC = N16;
  117. NET "anode[1]" LOC = N15;
  118. NET "anode[2]" LOC = P18;
  119. NET "anode[3]" LOC = P17;
  120. NET "segpom[0]" LOC = T18;
  121. NET "segpom[1]" LOC = U17;
  122. NET "segpom[2]" LOC = M14;
  123. NET "segpom[3]" LOC = N14;
  124. NET "segpom[4]" LOC = M13;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement