Advertisement
Guest User

vhdlfile

a guest
May 14th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 2.32 KB | None | 0 0
  1. ----------------------------------------------------------------------------------
  2. -- Company:
  3. -- Engineer:
  4. --
  5. -- Create Date: 15.05.2018 09:06:49
  6. -- Design Name:
  7. -- Module Name: Project1 - Project1_Arch
  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.  
  22. library IEEE;
  23. use IEEE.STD_LOGIC_1164.ALL;
  24.  
  25. -- Uncomment the following library declaration if using
  26. -- arithmetic functions with Signed or Unsigned values
  27. --use IEEE.NUMERIC_STD.ALL;
  28.  
  29. -- Uncomment the following library declaration if instantiating
  30. -- any Xilinx leaf cells in this code.
  31. --library UNISIM;
  32. --use UNISIM.VComponents.all;
  33.  
  34. entity Project1 is
  35.     port (clkin, x1, x2, x3, x4: in bit;
  36.           clk, y1, y2, y3, y4: out bit);
  37. end Project1;
  38.  
  39. architecture Project1_Arch of Project1 is
  40.  
  41. component SCH
  42.     Port (a: in bit;
  43.           b: out bit_vector (2 downto 0));
  44. end component;
  45.  
  46. component comp
  47.     Port (a: in bit_vector (2 downto 0);
  48.           b: out bit);
  49. end component;
  50.  
  51. signal s1: bit_vector (2 downto 0);
  52.  
  53. begin
  54.     SCH1: SCH port map (clkin, s1);
  55.     comp1 : comp port map (s1, clk);
  56.     y1 <= x1;
  57.     y2 <= x2;
  58.     y3 <= x3;
  59.     y4 <= x4;
  60. end Project1_Arch;
  61.  
  62. entity SCH is
  63.     Port (a: in bit;
  64.           b: out bit_vector (2 downto 0));
  65. end SCH;
  66.  
  67. architecture SCH_Arch of SCH is
  68.     begin
  69.     process(a)
  70.     variable sum1: integer;
  71.     begin
  72.         if ((a'event) and (a = '1')) then
  73.             sum1 := sum1 + 1;
  74.             if (sum1 = 8) then
  75.                 sum1 := 0;
  76.             end if;
  77.             case sum1 is
  78.                 when 0 => b <= "000";
  79.                 when 1 => b <= "001";
  80.                 when 2 => b <= "010";
  81.                 when 3 => b <= "011";
  82.                 when 4 => b <= "100";
  83.                 when 5 => b <= "101";
  84.                 when 6 => b <= "110";
  85.                 when 7 => b <= "111";
  86.                 when others =>
  87.             end case;
  88.         end if;
  89.     end process;
  90. end  SCH_Arch;
  91.  
  92. entity comp is
  93.     Port (a: in bit_vector (2 downto 0);
  94.           b: out bit);
  95. end comp;
  96.  
  97. architecture comp_Arch of comp is
  98.     begin
  99.         b <= a(0);
  100. end  comp_Arch;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement