Advertisement
Guest User

Untitled

a guest
Dec 18th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.82 KB | None | 0 0
  1. ----------------------------------------------------------------------------------
  2. -- Company:
  3. -- Engineer:
  4. --
  5. -- Create Date: 01:53:54 12/04/2016
  6. -- Design Name:
  7. -- Module Name: rom16x8 - Behavioral
  8. -- Project Name:
  9. -- Target Devices:
  10. -- Tool versions:
  11. -- Description:
  12. --
  13. -- Dependencies:
  14. --
  15. -- Revision:
  16. -- Revision 0.01 - File Created
  17. -- Additional Comments:
  18. --
  19. ----------------------------------------------------------------------------------
  20. library IEEE;
  21. use IEEE.STD_LOGIC_1164.ALL;
  22.  
  23. -- Uncomment the following library declaration if using
  24. -- arithmetic functions with Signed or Unsigned values
  25. --use IEEE.NUMERIC_STD.ALL;
  26.  
  27. -- Uncomment the following library declaration if instantiating
  28. -- any Xilinx primitives in this code.
  29. --library UNISIM;
  30. --use UNISIM.VComponents.all;
  31.  
  32. entity rom16x8 is
  33. port(
  34. adr : in std_logic_vector(3 downto 0);
  35. cs : in std_logic;
  36. data : out std_logic_vector(7 downto 0)
  37. );
  38. end rom16x8;
  39.  
  40. architecture Behavioral of rom16x8 is
  41. begin
  42. data <= "0000"&adr when cs = '1' else
  43. "ZZZZZZZZ";
  44. end Behavioral;
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53. ----------------------------------------------------------------------------------
  54. -- Company:
  55. -- Engineer:
  56. --
  57. -- Create Date: 01:41:23 12/04/2016
  58. -- Design Name:
  59. -- Module Name: sram8x8 - Behavioral
  60. -- Project Name:
  61. -- Target Devices:
  62. -- Tool versions:
  63. -- Description:
  64. --
  65. -- Dependencies:
  66. --
  67. -- Revision:
  68. -- Revision 0.01 - File Created
  69. -- Additional Comments:
  70. --
  71. ----------------------------------------------------------------------------------
  72. library IEEE;
  73. use IEEE.STD_LOGIC_1164.ALL;
  74. use ieee.std_logic_arith.all;
  75. use ieee.std_logic_unsigned.all;
  76.  
  77. -- Uncomment the following library declaration if using
  78. -- arithmetic functions with Signed or Unsigned values
  79. --use IEEE.NUMERIC_STD.ALL;
  80.  
  81. -- Uncomment the following library declaration if instantiating
  82. -- any Xilinx primitives in this code.
  83. --library UNISIM;
  84. --use UNISIM.VComponents.all;
  85.  
  86. entity sram8x8 is
  87. port(
  88. adr : in std_logic_vector(2 downto 0);
  89. we, oe, cs : in std_logic;
  90. data : inout std_logic_vector(7 downto 0)
  91. );
  92. end sram8x8;
  93.  
  94. architecture Behavioral of sram8x8 is
  95. type sram_array is array (0 to 7) of std_logic_vector(7 downto 0);
  96. signal sram : sram_array;
  97. begin
  98. process(we, oe, cs, adr, data, sram)
  99. begin
  100. if(cs = '1') then
  101. if(we = '1' and oe = '0') then
  102. sram(conv_integer(adr)) <= data;
  103. elsif(we = '0' and oe = '1') then
  104. data <= sram(conv_integer(adr));
  105. else
  106. data <= (others => 'Z');
  107. end if;
  108. else
  109. data <= (others => 'Z');
  110. end if;
  111. end process;
  112. end Behavioral;
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123. ----------------------------------------------------------------------------------
  124. -- Company:
  125. -- Engineer:
  126. --
  127. -- Create Date: 02:00:02 12/04/2016
  128. -- Design Name:
  129. -- Module Name: ured - Behavioral
  130. -- Project Name:
  131. -- Target Devices:
  132. -- Tool versions:
  133. -- Description:
  134. --
  135. -- Dependencies:
  136. --
  137. -- Revision:
  138. -- Revision 0.01 - File Created
  139. -- Additional Comments:
  140. --
  141. ----------------------------------------------------------------------------------
  142. library IEEE;
  143. use IEEE.STD_LOGIC_1164.ALL;
  144. use ieee.std_logic_arith.all;
  145. use ieee.std_logic_unsigned.all;
  146.  
  147. -- Uncomment the following library declaration if using
  148. -- arithmetic functions with Signed or Unsigned values
  149. --use IEEE.NUMERIC_STD.ALL;
  150.  
  151. -- Uncomment the following library declaration if instantiating
  152. -- any Xilinx primitives in this code.
  153. --library UNISIM;
  154. --use UNISIM.VComponents.all;
  155.  
  156. entity ured is
  157. port(
  158. start , clk: in std_logic
  159. );
  160. end ured;
  161.  
  162. architecture Behavioral of ured is
  163. signal adr1 : std_logic_vector(3 downto 0) := "0000";
  164. signal adr2 : std_logic_vector(2 downto 0) := "000";
  165. signal data1, data2, sum: std_logic_vector(7 downto 0) := (others => '0');
  166. signal we, cs1, cs2 : std_logic := '1';
  167. signal oe : std_logic := '0';
  168. type sram_array is array (0 to 7) of std_logic_vector(7 downto 0);
  169. signal sram : sram_array;
  170. begin
  171. process(data1, sum, adr1, adr2, start, clk)
  172. variable cnt : integer range 0 to 2;
  173. begin
  174. if(start = '1' and rising_edge(clk)) then
  175. if(cnt = 2) then
  176. data2 <= sum;
  177. adr2 <= adr2 + 1;
  178. sum <= "00000000";
  179. cnt := 0;
  180. end if;
  181. sum <= sum + data1;
  182. adr1 <= adr1 + 1;
  183. cnt := cnt + 1;
  184. end if;
  185. end process;
  186. rom:process(adr1, cs1)
  187. begin
  188. if cs1 = '1' then
  189. data1 <= "0000"&adr1;
  190. end if;
  191. end process rom;
  192. ram:process(we, oe, cs2, adr2, data2, sram)
  193. begin
  194. if(cs2 = '1') then
  195. if(we = '1' and oe = '0') then
  196. sram(conv_integer(adr2)) <= data2;
  197. elsif(we = '0' and oe = '1') then
  198. data2 <= sram(conv_integer(adr2));
  199. else
  200. data2 <= (others => 'Z');
  201. end if;
  202. else
  203. data2 <= (others => 'Z');
  204. end if;
  205. end process ram;
  206. end Behavioral;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement