Advertisement
Antonil

Untitled

Dec 3rd, 2016
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 2.40 KB | None | 0 0
  1. library IEEE;
  2. use IEEE.STD_LOGIC_1164.all;
  3. entity N_AND is
  4.     generic(N: integer);
  5.      port(
  6.      in1 : in STD_LOGIC_vector(0 to N-1);  
  7.      out1 : inout STD_LOGIC
  8.          );
  9. end N_AND;         
  10.  
  11. architecture N_AND of N_AND is  
  12. begin
  13.     process(in1)
  14.     variable val: std_logic;
  15.     begin
  16.         val:= in1(0);
  17.         for i in 1 to N-1 loop
  18.             val:= val and in1(i);
  19.         end loop;
  20.         val:= not val;
  21.         if  (out1='0' and val='1') then out1<= val after 2 ns;
  22.             elsif (out1='1' and val='0') then out1<=val after 4 ns;
  23.                 else out1<=val;
  24.         end if;
  25.     end process;
  26. end N_AND;   
  27.  
  28. library ieee;
  29. use ieee. std_logic_1164.all;
  30. entity JK_FF is              
  31.     port( J,K,C: in std_logic;
  32.           Q, nQ: inout std_logic);
  33. end JK_FF;
  34.  
  35. architecture structural of JK_FF is
  36.     component N_AND  
  37.         generic(N: integer);
  38.         port(IN1 :in std_logic_vector(0 to N-1);
  39.              OUT1: inout std_logic);
  40.     end component;   
  41.    
  42. function DoVector2(IN1,IN2: in std_logic)
  43.     return std_logic_vector is
  44.     variable vec: std_logic_vector(0 to 1);
  45.     begin
  46.     vec(0):=IN1;
  47.     vec(1):=IN2;
  48.     return vec;
  49.     end function;                
  50.    
  51. function DoVector3(IN1,IN2,IN3: in std_logic)
  52.     return std_logic_vector is
  53.     variable vec: std_logic_vector(0 to 2);
  54.     begin
  55.     vec(0):=IN1;
  56.     vec(1):=IN2;
  57.     vec(2):=IN3;
  58.     return vec;
  59. end function;
  60.  
  61. signal DD1_out, DD2_out, DD3_out, DD4_out, DD5_out, DD6_out: std_logic;  
  62. signal DD1_in, DD2_in : std_logic_vector (0 to 2);
  63. signal DD3_in, DD4_in,DD5_in,DD6_in,DD7_in,DD8_in : std_logic_vector (0 to 1);
  64. signal notC,q1,q2: std_logic;        
  65.  
  66. begin          
  67.     notC <= not(C);
  68.    
  69.     DD1_in <= DoVector3(nQ,J,C);
  70.     DD1: N_AND generic map (N=>3)
  71.     port map (in1=>DD1_in,out1=>DD1_out);  
  72.    
  73.     DD2_in <= DoVector3(C,K,Q);
  74.     DD2: N_AND generic map (N=>3)
  75.     port map (in1=>DD2_in,out1=>DD2_out);
  76.    
  77.     DD3_in <= DoVector2(DD1_out,DD4_out);
  78.     DD3: N_AND generic map (N=>2)
  79.     port map (in1=>DD3_in,out1=>DD3_out);
  80.    
  81.     DD4_in <= DoVector2(DD3_out,DD2_out);
  82.     DD4: N_AND generic map (N=>2)
  83.     port map (in1=>DD4_in,out1=>DD4_out);  
  84.    
  85.     DD5_in <= DoVector2(DD3_out,notC);
  86.     DD5: N_AND generic map (N=>2)
  87.     port map (in1=>DD5_in,out1=>DD5_out);
  88.    
  89.     DD6_in <= DoVector2(notC,DD4_out);
  90.     DD6: N_AND generic map (N=>2)
  91.     port map (in1=>DD6_in,out1=>DD6_out);
  92.    
  93.     DD7_in <= DoVector2(DD5_out,nQ);
  94.     DD7: N_AND generic map (N=>2)
  95.     port map (in1=>DD7_in,out1=>Q);
  96.    
  97.     DD8_in <= DoVector2(Q,DD6_out);
  98.     DD8: N_AND generic map (N=>2)
  99.     port map (in1=>DD8_in,out1=>nQ);
  100.    
  101. end structural;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement