Advertisement
Guest User

Untitled

a guest
May 17th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 2.39 KB | None | 0 0
  1. ----------------------------------------------------------------------------------
  2. -- Company:
  3. -- Engineer:
  4. --
  5. -- Create Date:    11:14:47 05/17/2019
  6. -- Design Name:
  7. -- Module Name:    entita_a - 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. use IEEE.numeric_std.ALL;
  25.  
  26. ---- Uncomment the following library declaration if instantiating
  27. ---- any Xilinx primitives in this code.
  28. --library UNISIM;
  29. --use UNISIM.VComponents.all;
  30.  
  31. entity entita_a is
  32.     Port ( CLK : in  STD_LOGIC;
  33.            SDATA : in  STD_LOGIC := '0';
  34.            R_W_neg : in  STD_LOGIC;
  35.            EN : in  STD_LOGIC;
  36.            DATA_OUT : out  STD_LOGIC);
  37. end entita_a;
  38.  
  39. architecture Behavioral of entita_a is
  40. type ram_display is array (15 downto 0) of std_logic_vector (15 downto 0);
  41. signal display: ram_display;
  42. signal address : std_logic_vector (3 downto 0);
  43. signal flag_lettura_indirizzo, cnt : integer := 0;
  44. signal buffer_scrittura, buffer_lettura : std_logic_vector (15 downto 0);
  45. signal tmp_out : std_logic;
  46. begin
  47.  
  48.     process (CLK)
  49.         begin
  50.             if rising_edge(CLK) then
  51.                 if flag_lettura_indirizzo = 0 then
  52.                     if cnt > 3 then
  53.                         flag_lettura_indirizzo <= 1;
  54.                         cnt <= 0;
  55.                     else
  56.                         address <= address(2 downto 0) & SDATA;
  57.                         cnt <= cnt +1;
  58.                     end if;
  59.                 else
  60.                     if (R_W_neg = '0') then
  61.                         if cnt < 16 then
  62.                             buffer_scrittura <= buffer_scrittura(14 downto 0) & SDATA;
  63.                             cnt <= cnt +1;
  64.                         else
  65.                             display(conv_integer(address)) <= buffer_scrittura;
  66.                             cnt <= 0;
  67.                             flag_lettura_indirizzo <= 0;
  68.                         end if;
  69.                     else
  70.                         if cnt = 0 then
  71.                             buffer_lettura <= display(conv_integer(address));
  72.                             cnt <= cnt +1;
  73.                         elsif cnt < 17 then
  74.                             tmp_out <= buffer_lettura(15);
  75.                             buffer_lettura <= buffer_lettura(14 downto 0) & buffer_lettura(15);
  76.                             cnt <= cnt + 1;
  77.                         else
  78.                             tmp_out <= 'Z';
  79.                             cnt <= 0;
  80.                             flag_lettura_indirizzo <= 0;
  81.                         end if;
  82.                     end if;
  83.                
  84.                 end if;
  85.             end if;
  86.         end process;
  87.        
  88. DATA_OUT <= tmp_out when EN = '1' else
  89.                 'Z';
  90. end Behavioral;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement