OpenCores
URL https://opencores.org/ocsvn/diogenes/diogenes/trunk

Subversion Repositories diogenes

[/] [diogenes/] [tags/] [initial/] [vhdl/] [vga/] [vga.vhdl] - Blame information for rev 236

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 164 fellnhofer
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 vga is
7
  port(reset      : in std_logic;
8
                 clk50_in  : in std_logic;
9
       red_out   : out std_logic;
10
       green_out : out std_logic;
11
       blue_out  : out std_logic;
12
       hs_out    : out std_logic;
13
       vs_out    : out std_logic;
14
 
15
                 addrb: IN std_logic_VECTOR(12 downto 0);
16
                 dinb: IN std_logic_VECTOR(7 downto 0);
17
                 web: IN std_logic
18
                 );
19
end vga;
20
 
21
architecture Behavioral of vga is
22
 
23
component video_ram is
24
        port (
25
        addra: IN std_logic_VECTOR(12 downto 0);
26
        addrb: IN std_logic_VECTOR(12 downto 0);
27
        clka: IN std_logic;
28
        clkb: IN std_logic;
29
        dinb: IN std_logic_VECTOR(7 downto 0);
30
        douta: OUT std_logic_VECTOR(7 downto 0);
31
        web: IN std_logic
32
        );
33
end component;
34
 
35
signal clk25              : std_logic;
36
 
37
signal horizontal_counter : std_logic_vector (9 downto 0);
38
signal vertical_counter   : std_logic_vector (9 downto 0);
39
 
40
signal count : std_logic_vector (9 downto 0);
41
 
42
signal v_addr : std_logic_VECTOR(12 downto 0);
43
signal v_data : std_logic_VECTOR(7 downto 0);
44
 
45
signal pixel : std_logic_vector(3 downto 0);
46
signal pixel_buf : std_logic_vector(7 downto 0);
47
 
48
 
49
begin
50
 
51
video_ram_c: video_ram
52
  port map(
53
                addra => v_addr,
54
                addrb => addrb,
55
                clka => clk50_in,
56
                clkb => clk50_in,
57
                dinb => dinb,
58
                douta => v_data,
59
                web => web
60
        );
61
 
62
-- generate a 25Mhz clock
63
process (clk50_in, reset)
64
        variable temp: std_logic_vector(9 downto 0) := (others => '0');
65
begin
66
        if reset='0' then
67
 
68
                clk25 <= '1';
69
--              horizontal_counter <= (others => '0'); --"1101110000";
70
--              vertical_counter <= (others => '0'); --"1111011001";
71
                hs_out <= '1';
72
                vs_out <= '1';
73
                blue_out <= '0';
74
                red_out <= '0';
75
                green_out <= '0';
76
--              pixel_buf <= (others => '0');
77
--              pixel <= (others => '0');
78
                v_addr <= (others => '0');
79
 
80
        elsif rising_edge(clk50_in) then
81
 
82
    if (clk25 = '0') then ----------- 25mhz rising edge
83
 
84
                clk25 <= '1';
85
 
86
                if (horizontal_counter < "1010000000" ) -- 640
87
                and (vertical_counter < "0111100000" )  -- 480 
88
                and (horizontal_counter >= "0000000000" )
89
                and (vertical_counter >= "0000000000" ) then
90
                        red_out <= pixel(0);
91
                        green_out <= pixel(1);
92
                        blue_out <= pixel(2);
93
                else
94
                        red_out <= '0';
95
                        green_out <= '0';
96
                        blue_out <= '0';
97
                end if;
98
                if (horizontal_counter >    "1101110000" )
99
                and (horizontal_counter < "1111010001" ) then -- 96+1 
100
                        hs_out <= '0';
101
                else
102
                        hs_out <= '1';
103
                end if;
104
                if (vertical_counter >    "1111011001" )
105
                and (vertical_counter < "1111011100" ) then -- 2+1
106
                        vs_out <= '0';
107
                else
108
                        vs_out <= '1';
109
                end if;
110
                horizontal_counter <= horizontal_counter+"0000000001";
111
                if (horizontal_counter="1010010000") then              -- 800 - 144
112
                        vertical_counter <= vertical_counter+"0000000001";
113
                        horizontal_counter <= "1101110000";
114
                end if;
115
                if (vertical_counter="0111101110") then                    -- 521 - 39
116
                        vertical_counter <= "1111011001";
117
                end if;
118
 
119
    else                 ----------- 25mhz falling edge
120
 
121
                clk25 <= '0';
122
 
123
           -- tile index:   0yyy xxxx
124
           -- tile address: yyyVVV 1xxxxHH
125
 
126
                if horizontal_counter(0) = '0' then
127
                        temp := horizontal_counter(9 downto 0) + "0000000010";
128
                        v_addr <= vertical_counter(8 downto 3) & temp(9 downto 3);
129
                        pixel_buf <= v_data;
130
                        pixel <= v_data(7 downto 4);
131
                elsif horizontal_counter(0) = '1' then
132
                        temp := horizontal_counter(9 downto 0) + "0000000001";
133
                        v_addr <= v_data(6 downto 4) & vertical_counter(2 downto 0) & "1" & v_data(3 downto 0) & temp(2 downto 1);
134
                        pixel <= pixel_buf(3 downto 0);
135
                end if;
136
 
137
         end if;
138
 
139
  end if;
140
end process;
141
 
142
-- 144 horizontal blank interval + 16 before incrementing vsync
143
-- 39 vertical blank interval + 2 before reseting
144
 
145
 
146
end Behavioral;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.