Advertisement
Guest User

3_architecture_vhdl

a guest
Sep 19th, 2016
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 3.42 KB | None | 0 0
  1. -- configuration gate
  2. -- File: conf_gate.vhd
  3.  
  4. library IEEE;
  5. use IEEE.STD_LOGIC_1164.all;
  6.  
  7. entity xor_gate is
  8.     generic(
  9.         DATA_WIDTH : natural := 3
  10.         );
  11.     port(
  12.         a : in std_logic_vector(DATA_WIDTH-1 downto 0);
  13.         b : in std_logic_vector(DATA_WIDTH-1 downto 0);
  14.         c : out std_logic_vector(DATA_WIDTH-1 downto 0)
  15.  
  16.         );
  17. end xor_gate;
  18.  
  19. architecture arch of xor_gate is
  20.  
  21. begin
  22.     c <= a xor b;
  23. end arch;
  24.  
  25. architecture not_arch of xor_gate is
  26.  
  27. begin
  28.     c <= a xnor b;
  29. end not_arch;
  30.  
  31. library IEEE;
  32. use IEEE.STD_LOGIC_1164.all;
  33.  
  34. entity or_gate is
  35.     generic(
  36.         DATA_WIDTH : natural := 3
  37.         );
  38.     port(
  39.         a : in std_logic_vector(DATA_WIDTH-1 downto 0);
  40.         b : in std_logic_vector(DATA_WIDTH-1 downto 0);
  41.         c : out std_logic_vector(DATA_WIDTH-1 downto 0)
  42.  
  43.         );
  44. end or_gate;
  45.  
  46. architecture arch of or_gate is
  47.  
  48. begin
  49.     c <= a or b;
  50. end arch;
  51.  
  52. architecture not_arch of or_gate is
  53.  
  54. begin
  55.     c <= a nor b;
  56. end not_arch;
  57.  
  58. library IEEE;
  59. use IEEE.STD_LOGIC_1164.all;
  60.  
  61. entity and_gate is
  62.     generic(
  63.         DATA_WIDTH : natural := 3
  64.         );
  65.     port(
  66.         a : in std_logic_vector(DATA_WIDTH-1 downto 0);
  67.         b : in std_logic_vector(DATA_WIDTH-1 downto 0);
  68.         c : out std_logic_vector(DATA_WIDTH-1 downto 0)
  69.  
  70.         );
  71. end and_gate;
  72.  
  73. architecture arch of and_gate is
  74.  
  75. begin
  76.     c <= a and b;
  77. end arch;
  78.  
  79. architecture not_arch of and_gate is
  80.  
  81. begin
  82.     c <= a nand b;
  83. end not_arch;
  84.  
  85. library IEEE;
  86. use IEEE.STD_LOGIC_1164.all;
  87.  
  88. entity conf_gate is
  89.     generic(
  90.         DATA_WIDTH : natural := 3
  91.         );
  92.     port(
  93.         a : in std_logic_vector(DATA_WIDTH-1 downto 0);
  94.         b : in std_logic_vector(DATA_WIDTH-1 downto 0);
  95.         c : out std_logic_vector(DATA_WIDTH-1 downto 0)
  96.  
  97.         );
  98. end conf_gate;
  99.  
  100. architecture and_gate_arch of conf_gate is
  101.  
  102. constant negated : boolean := true ;
  103.  
  104. begin
  105.  
  106. negated_gate : if negated = true generate
  107.     mod_inst : and_gate(not_arch)
  108.         generic map (
  109.          DATA_WIDTH => DATA_WIDTH
  110.         )
  111.         port map (
  112.             a => a,
  113.             b => b,
  114.             c => c
  115.         );
  116.     end generate negated_gate;
  117.    
  118. gate : if negated = false generate
  119.     mod_inst : entity work.and_gate(arch)
  120.         generic map (
  121.          DATA_WIDTH => DATA_WIDTH
  122.         )
  123.         port map (
  124.             a => a,
  125.             b => b,
  126.             c => c
  127.         );
  128.     end generate gate;
  129.  
  130.        
  131. end and_gate_arch;
  132.  
  133. architecture or_gate_arch of conf_gate is
  134.  
  135. constant negated : boolean := true ;
  136.  
  137. begin
  138.  
  139. negated_gate : if negated = true generate
  140.     mod_inst : entity work.or_gate(not_arch)
  141.         generic map (
  142.          DATA_WIDTH => DATA_WIDTH
  143.         )
  144.         port map (
  145.             a => a,
  146.             b => b,
  147.             c => c
  148.         );
  149.     end generate negated_gate;
  150.    
  151. gate : if negated = false generate
  152.     mod_inst : entity work.or_gate(arch)
  153.         generic map (
  154.          DATA_WIDTH => DATA_WIDTH
  155.         )
  156.         port map (
  157.             a => a,
  158.             b => b,
  159.             c => c
  160.         );
  161.     end generate gate;
  162.  
  163.        
  164. end or_gate_arch;
  165.  
  166. architecture xor_gate_arch of conf_gate is
  167.  
  168. constant negated : boolean := true ;
  169.  
  170. begin
  171.  
  172. negated_gate : if negated = true generate
  173.     mod_inst : entity work.xor_gate(not_arch)
  174.         generic map (
  175.          DATA_WIDTH => DATA_WIDTH
  176.         )
  177.         port map (
  178.             a => a,
  179.             b => b,
  180.             c => c
  181.         );
  182.     end generate negated_gate;
  183.    
  184. gate : if negated = false generate
  185.     mod_inst : entity work.xor_gate(arch)
  186.         generic map (
  187.          DATA_WIDTH => DATA_WIDTH
  188.         )
  189.         port map (
  190.             a => a,
  191.             b => b,
  192.             c => c
  193.         );
  194.     end generate gate;
  195.  
  196.        
  197. end xor_gate_arch;
  198.  
  199. configuration CONF of conf_gate is
  200.     for and_gate_arch
  201.         for mod_inst : entity work.and_gate
  202.             use entity work.conf_gate;
  203.         end for;
  204.     end for;
  205. end CONF;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement