Advertisement
Guest User

OD KAROLA

a guest
Mar 21st, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 2.19 KB | None | 0 0
  1. library ieee;
  2. use ieee.std_logic_1164.all;
  3. use ieee.std_logic_unsigned.all;
  4.  
  5.  
  6.  
  7.  
  8. entity lab3_1 is
  9.     port(
  10.         c0, c1, c2, c3, s1, s2: in std_logic;
  11.         y : out std_logic_vector(0 to 6);
  12.         z : out std_logic_vector(0 to 3)
  13.     );
  14. end lab3_1;
  15.  
  16. architecture struct of lab3_1 is
  17.  
  18.     component Vhdl3 is
  19.     port(
  20.         c0, c1, c2, c3, s1, s2: in std_logic;
  21.         z : out std_logic_vector(0 to 3)
  22.     );
  23.     end component;
  24.  
  25.     component Vhdl4 is
  26.     port(
  27.         c0, c1, c2, c3: in std_logic;
  28.         y : out std_logic_vector(0 to 6)
  29.     );
  30.     end component;
  31.    
  32. begin
  33.     M: Vhdl3 port map (c0, c1, c2, c3, s1, s2, z);
  34.     H: Vhdl4 port map (c0, c1, c2, c3, y);
  35. end struct;
  36.  
  37.  
  38. library ieee;
  39. use ieee.std_logic_1164.all;
  40. use ieee.std_logic_unsigned.all;
  41.  
  42.  
  43. entity Vhdl3 is
  44.     port(
  45.         c0, c1, c2, c3, s1, s2: in std_logic;
  46.         z : out std_logic_vector(0 to 3)
  47.     );
  48. end Vhdl3;
  49.  
  50. architecture mux of Vhdl3 is
  51.  
  52. begin
  53. z <= c0 & "000"  when s1 = '0' and s2 = '0' else
  54.     "0" & c1 & "00"when s1 = '0' and s2 = '1' else
  55.     "00" & c2 & "0" when s1 = '1' and s2 = '0' else
  56.     "000" & c3 when s1 = '1' and s2 = '1';
  57. end mux;
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65. library ieee;
  66. use ieee.std_logic_1164.all;
  67. use ieee.std_logic_unsigned.all;
  68.  
  69.  
  70.  
  71.  
  72. entity Vhdl4 is
  73.     port(
  74.         c0, c1, c2, c3: in std_logic;
  75.         y : out std_logic_vector(0 to 6)
  76.     );
  77. end Vhdl4;
  78.  
  79. architecture display of Vhdl4 is
  80.  
  81. begin
  82. y <= "0000001" when c0 = '0' and c1 = '0' and c2 = '0' and c3 = '0' else
  83.     "1001111" when c0 =  '0' and c1 = '0' and c2 = '0' and c3 = '1' else
  84.     "0010010" when c0 =  '0' and c1 = '0' and c2 = '1' and c3 = '0' else
  85.     "0000110"when c0 =  '0' and c1 = '0' and c2 = '1' and c3 = '1' else
  86.     "1001100" when c0 = '0' and c1 = '1' and c2 = '0' and c3 = '0' else
  87.     "0100100" when c0 =  '0' and c1 = '1' and c2 = '0' and c3 = '1' else
  88.     "0100000" when c0 =  '0' and c1 = '1' and c2 = '1' and c3 = '0' else
  89.     "0001111" when c0 =  '0' and c1 = '1' and c2 = '1' and c3 = '1' else
  90.     "0000000" when c0 =  '1' and c1 = '0' and c2 = '0' and c3 = '0' else
  91.     "0000100" when c0 =  '1' and c1 = '0' and c2 = '0' and c3 = '1';
  92. end display;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement