Guest User

Untitled

a guest
Apr 26th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 2.29 KB | None | 0 0
  1. ----------------------------------------------------------------------------------
  2. -- Company:
  3. -- Engineer:
  4. --
  5. -- Create Date:    16:54:29 12/11/2011
  6. -- Design Name:
  7. -- Module Name:    data_ram - 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_UNSIGNED.ALL;
  23. --use ieee.std_logic_arith.all;
  24. -- Uncomment the following library declaration if using
  25. -- arithmetic functions with Signed or Unsigned values
  26. use IEEE.NUMERIC_STD.ALL;
  27.  
  28. -- Uncomment the following library declaration if instantiating
  29. -- any Xilinx primitives in this code.
  30. --library UNISIM;
  31. --use UNISIM.VComponents.all;
  32.  
  33. entity data_ram is
  34. --  GENERIC (pDATA_WIDTH : integer :=8;
  35. --              pADRESS_WIDTH : integer:=4;
  36. --              pNO_OF_WORDS: integer:=16);
  37. --             
  38.     Port ( iCLK : in  STD_LOGIC;
  39.            inRST : in  STD_LOGIC;
  40.            iA : in  STD_LOGIC_VECTOR (4 downto 0);--padress
  41.            iD : in  STD_LOGIC_VECTOR (15 downto 0);--pdata
  42.            iWE : in  STD_LOGIC;
  43.            oQ : out  STD_LOGIC_VECTOR (15 downto 0));
  44. end data_ram;
  45.  
  46. architecture Behavioral of data_ram is
  47. type tRAM IS ARRAY (15 downto 0) of std_LOGIC_VECTOR (7 downto 0);
  48. SIGNAL sRAM:tRAM;
  49.  
  50.  
  51. begin
  52.     process (iCLK) begin
  53.         if (RISING_EDGE(iCLK)) then
  54.             if (inRST='0') then
  55.                 sRAM(0)<="00000000";
  56.                 sRAM( 1)<="00000000";
  57.                 sRAM( 2)<="00000000";
  58.                 sRAM( 3)<="00000000";
  59.                 sRAM( 4)<="00000000";
  60.                 sRAM( 5)<="00000000";
  61.                 sRAM( 6)<="00000000";
  62.                 sRAM( 7)<="00000000";
  63.                 sRAM( 8)<="00000000";
  64.                 sRAM( 9)<="00000000";
  65.                 sRAM( 10)<="00000000";
  66.                 sRAM( 11)<="00000000";
  67.                 sRAM( 12)<="00000000";
  68.                 sRAM( 13)<="00000000";
  69.                 sRAM( 14)<="00000000";
  70.                 sRAM( 15)<="00000000";
  71.             elsif (iWE= '1') then
  72.                 sRAM( Conv_INTEGER(iA))<=iD;
  73.             end if;
  74.         end if;
  75.     end process;
  76.    
  77.     process (iCLK) begin
  78.         if (RISING_EDGE(iCLK)) then
  79.             if (inRST='0') then
  80.                 oQ<=(others => 'Z');
  81.             elsif (iWE= '0') then
  82.                 oQ<=sRAM( Conv_INTEGER(iA));
  83.             else
  84.                 oQ<=(others => 'Z');
  85.             end if;
  86.         end if;
  87.     end process;
  88.  
  89. end Behavioral;
Add Comment
Please, Sign In to add comment