Advertisement
Guest User

IF

a guest
May 29th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.90 KB | None | 0 0
  1. ----------------------------------------------------------------------------------
  2. -- Company:
  3. -- Engineer:
  4. --
  5. -- Create Date: 09:36:06 04/09/2015
  6. -- Design Name:
  7. -- Module Name: MEM - 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. use IEEE.STD_LOGIC_ARITH.ALL;
  23. use IEEE.STD_LOGIC_UNSIGNED.ALL;
  24.  
  25. -- Uncomment the following library declaration if using
  26. -- arithmetic functions with Signed or Unsigned values
  27. --use IEEE.NUMERIC_STD.ALL;
  28.  
  29. -- Uncomment the following library declaration if instantiating
  30. -- any Xilinx primitives in this code.
  31. --library UNISIM;
  32. --use UNISIM.VComponents.all;
  33.  
  34. entity MEM is
  35. port(
  36. clk: in std_logic;--
  37. ALURes : in std_logic_vector(15 downto 0);
  38. WriteData: in std_logic_vector(15 downto 0);
  39. MemWrite: in std_logic;
  40. MemWriteCtrl: in std_logic;
  41. MemData:out std_logic_vector(15 downto 0);--
  42. ALURes2 :out std_logic_vector(15 downto 0)--
  43. );
  44. end MEM;
  45.  
  46. architecture Behavioral of MEM is
  47.  
  48. signal Address: std_logic_vector(3 downto 0);
  49.  
  50. type ram_type is array (0 to 15) of std_logic_vector(15 downto 0);
  51. signal RAM:ram_type:=(
  52. X"0010",
  53. X"0020",
  54. X"000C",
  55. X"0008",
  56. X"0004",
  57. X"0014",
  58.  
  59. others =>X"0000");
  60.  
  61. begin
  62.  
  63. Address<=ALURes(3 downto 0);
  64.  
  65. ---------------READ/WRITE MEMORY---------------
  66. process(clk)
  67. begin
  68. if(rising_edge(clk)) then
  69. if MemWriteCtrl='1' then
  70. if MemWrite='1' then
  71. RAM(conv_integer(Address))<=WriteData;
  72. end if;
  73. end if;
  74. end if;
  75. MemData<=RAM(conv_integer(Address));
  76. end process;
  77. -----------------------------------------------
  78.  
  79. ALURes2<=ALURes; -----ALU RESULT-----
  80.  
  81. end Behavioral;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement