Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: tristanseifert on Jul 15th, 2012  |  syntax: VHDL  |  size: 1.98 KB  |  hits: 18  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. library IEEE;
  2. use IEEE.STD_LOGIC_1164.ALL;
  3. use IEEE.STD_LOGIC_ARITH.ALL;
  4. use IEEE.STD_LOGIC_UNSIGNED.ALL;
  5.  
  6. entity VDP is
  7.                         -- RAM schits and output to DAC
  8.     Port (      RGBOut  : out   STD_LOGIC_VECTOR (23 downto 0);
  9.                         RAM_Data: inout STD_LOGIC_VECTOR (31 downto 0);
  10.                         RAM_Addr: out   STD_LOGIC_VECTOR (10 downto 0);
  11.                         RAM_bank: out   STD_LOGIC_VECTOR (1 downto 0);
  12.                         RAM_CLK : out   STD_LOGIC;
  13.                         RAM_CS  : out   STD_LOGIC;
  14.                         RAM_RAS : out   STD_LOGIC;
  15.                         RAM_CAS : out   STD_LOGIC;
  16.                         RAM_WE  : out   STD_LOGIC;
  17.                        
  18.                         -- Interface lines from 68k
  19.                         CS              : in    STD_LOGIC;
  20.                         RW              : in    STD_LOGIC;
  21.                         AS              : in    STD_LOGIC;
  22.                         RESET   : in    STD_LOGIC;
  23.                         DMAREQ  : out   STD_LOGIC;
  24.                         DTACK   : out   STD_LOGIC;
  25.                         CPU_DATA: inout STD_LOGIC_VECTOR (15 downto 0);
  26.                         CPU_ADDR: inout STD_LOGIC_VECTOR (23 downto 0);
  27.                        
  28.                         -- Various other I/O moopers
  29.                         DIPCfg  : in    STD_LOGIC_VECTOR (3 downto 0);
  30.                        
  31.                         -- Clocks and various video pulses
  32.                         PCLK    : in    STD_LOGIC;
  33.                         VSync   : out   STD_LOGIC;
  34.                         HSync   : out   STD_LOGIC;
  35.                         VInt    : out   STD_LOGIC);
  36. end VDP;
  37.        
  38. -- The VDP is designed 66.5 MHz pixel clock
  39. architecture Behavioral of VDP is
  40.         shared variable pixelCount: integer range 0 to 1355;
  41.         shared variable lineCount: integer range 0 to 807;
  42.         begin
  43.                 process(PCLK)
  44.                 begin
  45.        
  46.                         if falling_edge(PCLK) then
  47.                                 pixelCount := pixelCount + 1;
  48.                                
  49.                                 -- Have we reached the right end of the screen?
  50.                                 if (pixelCount = 1024) then
  51.                                         HSync <= '1';
  52.                                         lineCount := lineCount + 1;
  53.                                 end if;
  54.                        
  55.                                 -- Have we completed horizontal blanking?
  56.                                 if (pixelCount = 1354) then
  57.                                         HSync <= '0';
  58.                                         pixelCount := 0;
  59.                                 end if;
  60.                        
  61.                                 -- Have we reached the bottom of the screen?
  62.                                 if (lineCount = 768) then
  63.                                         VSync <= '1';
  64.                                         VInt <= '1';
  65.                                 end if;
  66.                        
  67.                                 -- Have we completed vertical blanking?
  68.                                 if (lineCount = 806) then
  69.                                         VInt <= '0';
  70.                                         VSync <= '0';
  71.                                         lineCount := 0;
  72.                                         pixelCount := 0;
  73.                                 end if;
  74.                         end if;
  75.         end process;
  76. end Behavioral;