fsm_sram: process(clk_ram, reset, mem_cycle, acc_copia, hcnt)
begin
if reset = '0' then
mem_cycle <= nop;
do_xsram <= "00000000";
-- inicilizamos dibujo
-- AKI INICIALIZO 'DIBUJO' que seria una imagen de 64x16 pixel
elsif clk_ram'event and clk_ram = '1' then
case mem_cycle is
when write1 => mem_cycle <= write2;
when write2 => mem_cycle <= write3;
when write3 => mem_cycle <= nop;
when read1 => mem_cycle <= read2;
when read2 => mem_cycle <= read3;
when read3 => mem_cycle <= nop;
when nop =>
if enable = '1' then
--addr <= "00000000000" & vcnt(8 downto 6) & hcnt(9 downto 6);
addr <= vcnt(7 downto 0) & hcnt;
mem_cycle <= read1;
elsif acc_copia ='1' then -- boton = '1' es apretado
mem_cycle <= write1;
addr <= dir_y(7 downto 0) & dir_x;
pixel_dibujo <= dibujo1(conv_integer(dir_y(3 downto 0)));
do_xsram <= "0000000" & pixel_dibujo(conv_integer(dir_x(5 downto 0)));
--do_xsram <= "00000" & dir_x(2 downto 0);
end if;
end case;
end if;
end process;
output_fsm_sram: process(mem_cycle)
begin
case mem_cycle is
when write1 => we_auxi <= '0'; oe_auxi <= '1'; ce1_auxi <= '0'; ce2_auxi <= '1';
when write2 => we_auxi <= '0'; oe_auxi <= '1'; ce1_auxi <= '0'; ce2_auxi <= '1';
when write3 => we_auxi <= '1'; oe_auxi <= '1'; ce1_auxi <= '0'; ce2_auxi <= '1';
when read1 => we_auxi <= '1'; oe_auxi <= '0'; ce1_auxi <= '0'; ce2_auxi <= '1';
when read2 => we_auxi <= '1'; oe_auxi <= '0'; ce1_auxi <= '0'; ce2_auxi <= '1';
when read3 => we_auxi <= '1'; oe_auxi <= '0'; ce1_auxi <= '0'; ce2_auxi <= '1';
when others => we_auxi <= '1'; oe_auxi <= '1'; ce1_auxi <= '1'; ce2_auxi <= '1';
end case;
end process;
we <= we_auxi;
oe <= oe_auxi;
ce1 <= ce1_auxi;
ce2 <= ce2_auxi;
data <= do_xsram when mem_cycle <= write2 and mem_cycle <= write3 else (others => 'Z');
di_xsram <= data when mem_cycle = read2 else di_xsram;
r_auxi <= di_xsram(2);
g_auxi <= di_xsram(1);
b_auxi <= di_xsram(0);