title: VHDL - reading from VGA's framebuffer
body: <p>I have an FPGA school project and I'm having some problems. We're using Digilent's Nexys2 board (Xilinx XC3S500E FPGA).</p>
  
  <p>We built a few controllers including VGA (640x480) with a framebuffer. At least we called it a framebuffer - it's actually a distributed 30x40 RAM that stores pixels to be displayed (1 bit - "one square", so we actually have a 30 by 40 resolution, no colors).</p>
  
  <p>Then we used the 8-bit Picoblaze microcontroller core and now we have to build a Snake game (you know, the one from the old Nokias). Now my problem is that Picoblaze only has a 64 Byte scratchpad RAM, so the snake can't get really long if I keep it in there.</p>
  
  <p>So I was thinking I could just read where the snake is from VGA's RAM, but I don't know how, as VGA is reading from it and there's also the problem of addressing or reading whole line of data (picoblaze has a 8-bit in_port).
  Here's the process:</p>
  
  <pre><code>process(clk_i, vert_data_on, hor_data_on, read_data)
  begin
      if vert_data_on = '1' and hor_data_on = '1' then
          if read_data(conv_integer(column_calc)) = '1' then
              red_o &lt;= "000";
              green_o &lt;= "000";
              blue_o &lt;= "00";
          else
              red_o &lt;= "111";
              green_o &lt;= "111";
              blue_o &lt;= "11";
          end if;
      else            
          red_o &lt;= "000";
          green_o &lt;= "000";
          blue_o &lt;= "00";
      end if;
  end process;
  </code></pre>
  
  <p>The RAM component and its instance:</p>
  
  <pre><code>component RAM30x40 is
      Port(
          clk_i           : in  STD_LOGIC;
          we_i            : in  STD_LOGIC;
          addrInX_i       : in  STD_LOGIC_VECTOR(5 downto 0);
          addrInY_i       : in  STD_LOGIC_VECTOR(4 downto 0);
          addrOutY_i      : in  STD_LOGIC_VECTOR(4 downto 0);
          data_i          : in  STD_LOGIC;
          data_o          : out STD_LOGIC_VECTOR(0 to 39)
      );
  end component;
  
  inst_RAM: RAM30x40
  Port map(
      clk_i           =&gt; clk_i,
      we_i            =&gt; write_enable,
      addrInX_i       =&gt; write_addr_x,
      addrInY_i       =&gt; write_addr_y,
      addrOutX_i      =&gt; read_addr_x,
      addrOutY_i      =&gt; row_calc,
      data_i          =&gt; write_data,
      data_o          =&gt; read_data
  );
  </code></pre>
  
  <p>How is this solved in PCs? Is it common to read from graphic card's memory?
  What are my options here? I could use block RAM with two clocks and have one for VGA's reading and the other for the picoblaze but I don't know and can't find how to generate another clock signal properly.</p>