Advertisement
Guest User

vhdl

a guest
Jun 26th, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 7.16 KB | None | 0 0
  1. entity project1 is
  2.     port (x1, x2, x3, x4, clkin, xx1 : in bit;
  3.           k1, k2, k3 : in bit_vector (7 downto 0);
  4.           y1, y2, y3, y4, yy2, yy3, y10 : out bit);
  5. end project1;
  6.  
  7. architecture project1_arch of project1 is
  8.  
  9.     component SCH
  10.     port (a: in bit;
  11.           b: out bit_vector (2 downto 0));
  12.     end component;
  13.    
  14.     component comp
  15.     port (a: in bit_vector (2 downto 0);
  16.           i_clkin: in bit;
  17.           b, i_clkout: out bit);
  18.     end component;
  19.    
  20.     component pass
  21.         port (k1, k2, k3: in bit_vector (7 downto 0);
  22.               clkin: in bit;
  23.               y10: out bit);
  24.     end component;
  25.        
  26.         component EX2
  27.         port(A,B : in bit;
  28.              Y : out bit);
  29.         end component;
  30.        
  31.         component N
  32.         port (A : in bit;
  33.               Y : out bit);
  34.         end component;
  35.        
  36.         component NO3A2
  37.         port (A,B,C,D : in bit;
  38.               Y : out bit);
  39.         end component;
  40.        
  41.         component NA2
  42.         port (A,B : in bit;
  43.               Y : out bit);
  44.         end component;
  45.        
  46.         component NA3O2
  47.         port (A,B,C,D : in bit;
  48.               Y : out bit);
  49.         end component;
  50.        
  51.         component NOA3
  52.         port (A,B,C,D : in bit;
  53.               Y : out bit);
  54.         end component;
  55.        
  56.         component VCC
  57.         port (Y : out bit);
  58.         end component;
  59.        
  60.         component NO3
  61.         port (A,B,C : in bit;
  62.               Y : out bit);
  63.         end component;
  64.        
  65.         component NOAO2
  66.         port (A,B,C,D : in bit;
  67.               Y : out bit);
  68.         end component;
  69.        
  70.         component NAO2
  71.         port (A,B,C : in bit;
  72.               Y : out bit);
  73.         end component;
  74.        
  75.        
  76.     signal s0,s1,s2,s3,s4,s5,s6,s7,s8,s9,s10,s11,s12,s13,s14,s15 : bit;
  77.     signal ss1 : bit_vector (2 downto 0);
  78.    
  79.     begin
  80.    
  81.     SCH1 : SCH port map (xx1, ss1);
  82.     comp1 : comp port map (ss1, xx1, yy2, yy3);
  83.     pass1: pass port map (k1, k2, k3, clkin, y10);
  84.  
  85.  
  86.     EX2_1: EX2 port map(x3,x2,s0);
  87.     N_1: N port map(s0,s1);
  88.     N_2: N port map(s14,s2);
  89.     N_3: N port map(s2,s3);
  90.     N_4: N port map(s1,s4);
  91.     N_5: N port map(x1,s5);
  92.     NO3A2_1: NO3A2 port map(x4,s3,s4,s5,s6);
  93.     N_6: N port map(x4,s7);
  94.     N_7: N port map(x2,s8);
  95.     N_8: N port map(s1,s9);
  96.     NA2_1: NA2 port map(s5,x4,s10);
  97.     NA3O2_1: NA3O2 port map(x3,s2,x1,s7,s11);
  98.     NOA3_1: NOA3 port map(s6,x3,s8,x1,s12);
  99.     N_9: N port map(s15,s13);
  100.     VCC_1: VCC port map(y1);
  101.     NO3_1: NO3 port map(s9,x4,s5,s14);
  102.     NOAO2_1: NOAO2 port map(s8,s11,x3,s10,s15);
  103.     NAO2_1: NAO2 port map(s12,x1,s13,y4);
  104. y2<=s14;
  105. y3<=s15;
  106.  
  107. end project1_arch;
  108.  
  109.  
  110.  
  111. entity EX2 is
  112. port(A,B : in bit;
  113.      Y : out bit);
  114. end EX2;
  115.  
  116. architecture EX2_arch of EX2 is
  117. begin
  118.     y <= ((A and (not B)) or ((not A) and B)) after 5 ns;
  119. end EX2_arch;
  120.  
  121. entity N is
  122. port (A : in bit;
  123.       Y : out bit);
  124. end N;
  125.  
  126. architecture N_arch of N is
  127. begin
  128.     y <= (not A) after 1 ns;
  129. end N_arch;
  130.  
  131. entity NO3A2 is
  132. port (A,B,C,D : in bit;
  133.       Y : out bit);
  134. end NO3A2;
  135.  
  136. architecture NO3A2_arch of NO3A2 is
  137. begin
  138.     y <= not(A or B or (D and C)) after 5 ns;
  139. end NO3A2_arch;
  140.  
  141. entity NA2 is
  142. port (A,B : in bit;
  143.       Y : out bit);
  144. end NA2;
  145.  
  146. architecture NA2_arch of NA2 is
  147. begin
  148.     y <= not(A and B) after 2 ns;
  149. end NA2_arch;
  150.  
  151. entity NA3O2 is
  152. port (A,B,C,D : in bit;
  153.       Y : out bit);
  154. end NA3O2;
  155.  
  156. architecture NA3O2_arch of NA3O2 is
  157. begin
  158.     y <= not(A and B and (C or D)) after 4 ns;
  159. end NA3O2_arch;
  160.  
  161. entity NOA3 is
  162. port (A,B,C,D : in bit;
  163.       Y : out bit);
  164. end NOA3;
  165.  
  166. architecture NOA3_arch of NOA3 is
  167. begin
  168.     y <= not(A or (B and C and D)) after 5 ns;
  169. end NOA3_arch;
  170.  
  171. entity VCC is
  172. port (Y : out bit);
  173. end VCC;
  174.  
  175. architecture VCC_arch of VCC is
  176. begin
  177.     y <= '1' after 1 ns;
  178. end VCC_arch;
  179.  
  180. entity NO3 is
  181. port (A,B,C : in bit;
  182.       Y : out bit);
  183. end NO3;
  184.  
  185. architecture NO3_arch of NO3 is
  186. begin
  187.     y <= not(A or B or C) after 4 ns;
  188. end NO3_arch;
  189.  
  190. entity NOAO2 is
  191. port (A,B,C,D : in bit;
  192.       Y : out bit);
  193. end NOAO2;
  194.  
  195. architecture NOAO2_arch of NOAO2 is
  196. begin
  197.     y <= not(A or (B and (C or D))) after 4 ns;
  198. end NOAO2_arch;
  199.  
  200. entity NAO2 is
  201. port (A,B,C : in bit;
  202.       Y : out bit);
  203. end NAO2;
  204.  
  205. architecture NAO2_arch of NAO2 is
  206. begin
  207.     y <= not(A and (B or C)) after 3 ns;
  208. end NAO2_arch;
  209.  
  210. entity SCH is
  211.     port (a: in bit;
  212.           b: out bit_vector (2 downto 0));
  213. end SCH;
  214.    
  215.     architecture SCH_arch of SCH is
  216.         begin
  217.         process(a)
  218.         variable sum1: integer := 0;
  219.         begin
  220.             if ((a'event) and (a = '1')) then
  221.                 sum1 := sum1 + 1;
  222.                 if (sum1 = 8) then
  223.                     sum1 := 0;
  224.                 end if;
  225.                 case sum1 is
  226.                     when 0 => b <= "000";
  227.                     when 1 => b <= "001";
  228.                     when 2 => b <= "010";
  229.                     when 3 => b <= "011";
  230.                     when 4 => b <= "100";
  231.                     when 5 => b <= "101";
  232.                     when 6 => b <= "110";
  233.                     when 7 => b <= "111";
  234.                     when others =>
  235.                 end case;
  236.             end if;
  237.         end process;
  238.     end  SCH_arch;
  239.    
  240.     entity comp is
  241.     port (a: in bit_vector (2 downto 0);
  242.           i_clkin: in bit;
  243.           b, i_clkout: out bit);
  244.     end comp;
  245.    
  246.     architecture comp_arch of comp is
  247.     begin
  248.         process(a)
  249.         variable sum2 : integer := 0;
  250.         begin
  251.             i_clkout <= '1', '0' after 20 ns;
  252.             if (a = "100") then
  253.             sum2 := sum2 + 1;
  254.             if (sum2 = 1) then
  255.             i_clkout <= '0', '1' after 20 ns;
  256.             else i_clkout <= '1', '0' after 20 ns;
  257.             end if;
  258.             if (sum2 = 1) then
  259.             b <= '1', '0' after 20 ns;
  260.             end if;
  261.             end if;
  262.    
  263.         end process;
  264.    
  265.     end  comp_arch;
  266.    
  267.     entity pass is
  268.     port (k1, k2, k3: in bit_vector (7 downto 0);
  269.           clkin: in bit;
  270.           y10: out bit);
  271.     end pass;
  272.    
  273.     architecture pass_arch of pass is
  274.    
  275.         begin
  276.         process(clkin)
  277.         variable ntakta : integer := 0;
  278.         variable ok1 : integer := 0;
  279.         begin
  280.         ntakta := ntakta + 1;
  281.         ok1 := 0;
  282.         if ((ntakta = 1) and (k1 = "01010101") and (clkin'event) and (clkin = '1'))
  283.         then ok1 := 1;
  284.         end if;
  285.         if ((ntakta = 2) and (k2 = "11001100") and (clkin'event) and (clkin = '1'))
  286.         then ok1 := 1;
  287.         end if;
  288.         if ((ntakta = 3) and (k3 = "11001100") and (clkin'event) and (clkin = '1'))
  289.         then ok1 := 1;
  290.         end if;
  291.         if ((ntakta = 4) and (k3 = "11001100") and (clkin'event) and (clkin = '1'))
  292.         then ok1 := 1;
  293.         end if;
  294.         if ((ntakta = 5) and (k1 = "01010101") and (clkin'event) and (clkin = '1'))
  295.         then ok1 := 1;
  296.         end if;
  297.         if ((ntakta = 6) and (k3 = "01010101") and (clkin'event) and (clkin = '1'))
  298.         then ok1 := 1;
  299.         end if;
  300.         if ((ntakta = 7) and (k3 = "01010101") and (clkin'event) and (clkin = '1'))
  301.         then ok1 := 1;
  302.         end if;
  303.         if ((ntakta = 8) and (k2 = "01010101") and (clkin'event) and (clkin = '1'))
  304.         then ok1 := 1;
  305.         end if;
  306.        
  307.         if (ok1 = 0) then ntakta := 0;
  308.         end if;
  309.         if ((ntakta = 8) and (clkin'event) and (clkin = '1'))
  310.         then y10 <= '1', '0' after 20 ns;
  311.         ntakta := 0;
  312.         end if;
  313.         end process;
  314.        
  315.     end pass_arch;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement