Advertisement
mdabkow

Lab1Zadanie2UcyfB

Nov 21st, 2018
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.24 KB | None | 0 0
  1. ZADANIE B1
  2. library IEEE;
  3. use IEEE.std_logic_1164.all;
  4. use IEEE.numeric_std.all;
  5.  
  6. entity B1 is
  7. port
  8. (
  9. A1, B1, S1 : in std_logic_vector (7 downto 0);
  10. F1 : out std_logic_vector(1 downto 0);
  11. X1 : out std_logic_vector(7 downto 0)
  12. );
  13. end entity;
  14.  
  15. architecture structB1 of B1 is
  16. signal temp : std_logic_vector (8 downto 0);
  17. begin
  18. temp <= ('0' & std_logic_vector(unsigned(A1) + unsigned(B1) + 1)) when S1(0) = '0' else
  19. ('0' & std_logic_vector(unsigned(A1) - unsigned(B1)));
  20. X1 <= std_logic_vector(unsigned(A1) + unsigned(B1) + 1) when S1(0) = '0' else
  21. std_logic_vector(unsigned(A1) - unsigned(B1));
  22.  
  23. process(temp)
  24. begin
  25. if(temp(8) = '1') then F1 <= "10"; else
  26. F1 <= "01";
  27. end if;
  28. end process;
  29.  
  30.  
  31. end architecture;
  32. ZADANIE B2
  33. library IEEE;
  34. use IEEE.std_logic_1164.all;
  35.  
  36. entity B2 is
  37. port
  38. (
  39. C2, D2, S2, X2 : in std_logic_vector (7 downto 0);
  40. F2_i : in std_logic_vector(1 downto 0);
  41. M2 : out std_logic_vector(7 downto 0);
  42. F2_o : out std_logic_vector(0 downto 0)
  43. );
  44. end entity;
  45.  
  46. architecture structB2 of B2 is
  47. begin
  48.  
  49. process(F2_i)
  50. begin
  51. if(F2_i = "10") then M2 <= "11111111"; else
  52. case(S2(2 downto 1)) is
  53. when "01" => M2 <= C2;
  54. when "10" => M2 <= D2;
  55. when others => M2 <= X2;
  56. end case;
  57. end if;
  58. end process;
  59.  
  60. F2_o <= "1" when F2_i = "10";
  61.  
  62. end architecture;
  63. ZADANIE B3
  64. library IEEE;
  65. use IEEE.std_logic_1164.all;
  66.  
  67. entity B3 is
  68. port
  69. (
  70. M3, S3 : in std_logic_vector (7 downto 0);
  71. H0_3, H1_3, H2_3, H3_3 : out std_logic_vector(3 downto 0)
  72. );
  73. end entity;
  74.  
  75. architecture structB3 of B3 is
  76. begin
  77.  
  78. process(S3)
  79. begin
  80. if(S3(7 downto 6) = "01") then
  81. H0_3 <= M3(7 downto 4);
  82. H1_3 <= M3(3 downto 0);
  83. H2_3 <= "0000";
  84. H3_3 <= "0000";
  85. elsif(S3(7 downto 6) = "00") then
  86. H0_3 <= M3(7 downto 4);
  87. H1_3 <= "0000";
  88. H2_3 <= M3(3 downto 0);
  89. H3_3 <= "0000";
  90. else
  91. H0_3 <= M3(7 downto 4);
  92. H1_3 <= "0000";
  93. H2_3 <= "0000";
  94. H3_3 <= M3(3 downto 0);
  95.  
  96. end if;
  97. end process;
  98.  
  99. end architecture;
  100. ZADANIE ZB
  101. library IEEE;
  102. use IEEE.std_logic_1164.all;
  103.  
  104. entity zB is
  105. port
  106. (
  107. A,B,C,D,s : in std_logic_vector(7 downto 0);
  108. X : out std_logic_vector(7 downto 0);
  109. F : out std_logic_vector(3 downto 0);
  110. H0, H1, H2, H3 : out std_logic_vector(3 downto 0)
  111. );
  112. end entity;
  113.  
  114. architecture structure of zB is
  115. component B1
  116. port
  117. (
  118. A1, B1, S1 : in std_logic_vector (7 downto 0);
  119. F1 : out std_logic_vector(1 downto 0);
  120. X1 : out std_logic_vector(7 downto 0)
  121. );
  122. end component;
  123.  
  124. component B2
  125. port
  126. (
  127. C2, D2, S2, X2 : in std_logic_vector (7 downto 0);
  128. F2_i : in std_logic_vector(1 downto 0);
  129. M2 : out std_logic_vector(7 downto 0);
  130. F2_o : out std_logic_vector(0 downto 0)
  131. );
  132. end component;
  133.  
  134. component B3
  135. port
  136. (
  137. M3, S3 : in std_logic_vector (7 downto 0);
  138. H0_3, H1_3, H2_3, H3_3 : out std_logic_vector(3 downto 0)
  139. );
  140. end component;
  141.  
  142. signal XX, MM : std_logic_vector(7 downto 0);
  143. signal FF : std_logic_vector(1 downto 0);
  144.  
  145. begin
  146.  
  147. blokB1 : B1
  148. port map(A1 => A, B1 => B, S1 => S, X1 => X, F1 => F(3 downto 2));
  149.  
  150. blokB2 : B2
  151. port map(C2 => C, D2 => D, X2 => XX, S2 => S, F2_i => FF, M2 => MM, F2_o => F(0 downto 0));
  152.  
  153. blokB3 : B3
  154. port map(M3 => MM, S3 => S, H0_3 => H0, H1_3 => H1, H2_3 => H2, H3_3 => H3);
  155. end architecture;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement