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

Subversion Repositories vga_lcd

[/] [vga_lcd/] [tags/] [rel_1/] [rtl/] [vhdl/] [vga_and_clut.vhd] - Blame information for rev 62

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 16 rudi
--
2
-- file: vga_and_clut.vhd
3
-- project: VGA/LCD controller + Color Lookup Table
4
-- author: Richard Herveille
5
--
6
-- rev. 1.0 July  4th, 2001.
7
-- rev. 1.1 July 15th, 2001. Changed cycle_shared_memory to csm_pb. The core does not require a CLKx2 clock anymore.
8
--                           Added CLUT bank switching
9
 
10
library ieee;
11
use ieee.std_logic_1164.all;
12
use ieee.std_logic_arith.all;
13
 
14
entity vga_and_clut is
15
        port(
16
                CLK_I   : in std_logic;                         -- wishbone clock input
17
                RST_I   : in std_logic;                         -- synchronous active high reset
18
                NRESET  : in std_logic;                         -- asynchronous active low reset
19
                INTA_O  : out std_logic;                        -- interrupt request output
20
 
21
                -- slave signals
22
                ADR_I      : in unsigned(10 downto 2);          -- addressbus input (only 32bit databus accesses supported)
23
                SDAT_I     : in std_logic_vector(31 downto 0);  -- Slave databus output
24
                SDAT_O     : out std_logic_vector(31 downto 0); -- Slave databus input
25
                SEL_I      : in std_logic_vector(3 downto 0);   -- byte select inputs
26
                WE_I       : in std_logic;                      -- write enabel input
27
                VGA_STB_I  : in std_logic;                      -- vga strobe/select input
28
                CLUT_STB_I : in std_logic;                      -- color-lookup-table strobe/select input
29
                CYC_I      : in std_logic;                      -- valid bus cycle input
30
                ACK_O      : out std_logic;                     -- bus cycle acknowledge output
31
                ERR_O      : out std_logic;                     -- bus cycle error output
32
 
33
                -- master signals
34
                ADR_O : out unsigned(31 downto 2);              -- addressbus output
35
                MDAT_I : in std_logic_vector(31 downto 0);      -- Master databus input
36
                SEL_O : out std_logic_vector(3 downto 0);       -- byte select outputs
37
                WE_O : out std_logic;                           -- write enable output
38
                STB_O : out std_logic;                          -- strobe output
39
                CYC_O : out std_logic;                          -- valid bus cycle output
40
                CAB_O : out std_logic;                          -- continuos address burst output
41
                ACK_I : in std_logic;                           -- bus cycle acknowledge input
42
                ERR_I : in std_logic;                           -- bus cycle error input
43
 
44
                -- VGA signals
45
                PCLK : in std_logic;                            -- pixel clock
46
                HSYNC : out std_logic;                          -- horizontal sync
47
                VSYNC : out std_logic;                          -- vertical sync
48
                CSYNC : out std_logic;                          -- composite sync
49
                BLANK : out std_logic;                          -- blanking signal
50
                R,G,B : out std_logic_vector(7 downto 0)        -- RGB color signals
51
        );
52
end entity vga_and_clut;
53
 
54
architecture structural of vga_and_clut is
55
        --
56
        -- component declarations
57
        --
58
        component VGA is
59
        port (
60
                CLK_I : in std_logic;
61
                RST_I : in std_logic;
62
                NRESET : in std_logic;
63
                INTA_O : out std_logic;
64
 
65
                -- slave signals
66
                ADR_I : in unsigned(4 downto 2);                          -- only 32bit databus accesses supported
67
                SDAT_I : in std_logic_vector(31 downto 0);
68
                SDAT_O : out std_logic_vector(31 downto 0);
69
                SEL_I : in std_logic_vector(3 downto 0);
70
                WE_I : in std_logic;
71
                STB_I : in std_logic;
72
                CYC_I : in std_logic;
73
                ACK_O : out std_logic;
74
                ERR_O : out std_logic;
75
 
76
                -- master signals
77
                ADR_O : out unsigned(31 downto 2);
78
                MDAT_I : in std_logic_vector(31 downto 0);
79
                SEL_O : out std_logic_vector(3 downto 0);
80
                WE_O : out std_logic;
81
                STB_O : out std_logic;
82
                CYC_O : out std_logic;
83
                CAB_O : out std_logic;
84
                ACK_I : in std_logic;
85
                ERR_I : in std_logic;
86
 
87
                -- VGA signals
88
                PCLK : in std_logic;                     -- pixel clock
89
                HSYNC : out std_logic;                   -- horizontal sync
90
                VSYNC : out std_logic;                   -- vertical sync
91
                CSYNC : out std_logic;                   -- composite sync
92
                BLANK : out std_logic;                   -- blanking signal
93
                R,G,B : out std_logic_vector(7 downto 0) -- RGB color signals
94
        );
95
        end component vga;
96
 
97
        component csm_pb is
98
        generic(
99
                DWIDTH : natural := 32; -- databus width
100
                AWIDTH : natural := 8   -- addressbus width
101
        );
102
        port(
103
                -- SYSCON signals
104
                CLK_I   : in std_logic; -- wishbone clock input
105
                RST_I   : in std_logic; -- synchronous active high reset
106
                nRESET  : in std_logic; -- asynchronous active low reset
107
 
108
                -- wishbone slave0 connections
109
                ADR0_I : in unsigned(AWIDTH -1 downto 0);              -- address input
110
                DAT0_I : in std_logic_vector(DWIDTH -1 downto 0);      -- data input
111
                DAT0_O : out std_logic_vector(DWIDTH -1 downto 0);     -- data output
112
                SEL0_I : in std_logic_vector( (DWIDTH/8) -1 downto 0); -- byte select input
113
                WE0_I : in std_logic;                                  -- write enable input
114
                STB0_I : in std_logic;                                 -- strobe input
115
                CYC0_I : in std_logic;                                 -- valid bus cycle input
116
                ACK0_O : out std_logic;                                -- acknowledge output
117
                ERR0_O : out std_logic;                                -- error output
118
 
119
                -- wishbone slave1 connections
120
                ADR1_I : in unsigned(AWIDTH -1 downto 0);              -- address input
121
                DAT1_I : in std_logic_vector(DWIDTH -1 downto 0);      -- data input
122
                DAT1_O : out std_logic_vector(DWIDTH -1 downto 0);     -- data output
123
                SEL1_I : in std_logic_vector( (DWIDTH/8) -1 downto 0); -- byte select input
124
                WE1_I : in std_logic;                                  -- write enable input
125
                STB1_I : in std_logic;                                 -- strobe input
126
                CYC1_I : in std_logic;                                 -- valid bus cycle input
127
                ACK1_O : out std_logic;                                -- acknowledge output
128
                ERR1_O : out std_logic                                 -- error output
129
        );
130
        end component csm_pb;
131
 
132
        --
133
        -- Signal declarations
134
        --
135
        signal CBA : unsigned(31 downto 11); -- color lookup table base address
136
 
137
        signal vga_clut_acc : std_logic; -- vga access to color lookup table
138
 
139
        signal empty_data : std_logic_vector(23 downto 0); -- all zeros
140
 
141
        signal vga_ack_o, vga_ack_i, vga_err_o, vga_err_i : std_logic;
142
        signal vga_adr_o                                  : unsigned(31 downto 2);
143
        signal vga_dat_i, vga_dat_o                       : std_logic_vector(31 downto 0); -- vga master data input, vga slave data output
144
        signal vga_sel_o                                  : std_logic_vector(3 downto 0);
145
        signal vga_we_o, vga_stb_o, vga_cyc_o             : std_logic;
146
 
147
        signal vga_clut_stb : std_logic;
148
 
149
        signal mem0_dat_o, mem1_dat_o : std_logic_vector(23 downto 0);
150
        signal mem0_ack_o, mem0_err_o : std_logic;
151
        signal mem1_ack_o, mem1_err_o : std_logic;
152
begin
153
        --
154
        -- capture VGA CBAR access
155
        --
156
        process(CLK_I, nReset)
157
        begin
158
                if (nReset = '0') then
159
                        CBA <= (others => '0');
160
                elsif (CLK_I'event and CLK_I = '1') then
161
                        if (RST_I = '1') then
162
                                CBA <= (others  => '0');
163
                        elsif ( (SEL_I = "1111") and (CYC_I = '1') and (VGA_STB_I = '1') and (WE_I = '1') and (std_logic_vector(ADR_I(4 downto 2)) = "111") ) then
164
                                CBA <= unsigned(SDAT_I(31 downto 11));
165
                        end if;
166
                end if;
167
        end process;
168
 
169
        -- generate vga_clut_acc. Because CYC_O and STB_O are generated one clock cycle after ADR_O,
170
        -- vga_clut_acc may be synchronous.
171
        process(CLK_I)
172
        begin
173
                if (CLK_I'event and CLK_I = '1') then
174
                        if (vga_adr_o(31 downto 11) = CBA) then
175
                                vga_clut_acc <= '1';
176
                        else
177
                                vga_clut_acc <= '0';
178
                        end if;
179
                end if;
180
        end process;
181
 
182
        --
183
        -- hookup vga controller
184
        --
185
        u1: VGA port map (CLK_I => CLK_I, RST_I => RST_I, NRESET => nReset, INTA_O => INTA_O,
186
                                        ADR_I => ADR_I(4 downto 2), SDAT_I => SDAT_I, SDAT_O => vga_dat_o, SEL_I => SEL_I, WE_I => WE_I,
187
                                        STB_I => VGA_STB_I, CYC_I => CYC_I, ACK_O => vga_ack_o, ERR_O => vga_err_o,
188
                                        ADR_O => vga_adr_o, MDAT_I => vga_dat_i, SEL_O => vga_sel_o, WE_O => vga_we_o, STB_O => vga_stb_o,
189
                                        CYC_O => vga_cyc_o, CAB_O => CAB_O, ACK_I => vga_ack_i, ERR_I => vga_err_i,
190
                                        PCLK => PCLK, HSYNC => HSYNC, VSYNC => VSYNC, CSYNC => CSYNC, BLANK => BLANK, R => R, G => G, B => B);
191
 
192
        --
193
        -- hookup cycle shared memory
194
        --
195
        vga_clut_stb <= vga_stb_o when (vga_clut_acc = '1') else '0';
196
 
197
        empty_data <= (others => '0');
198
        u2: csm_pb
199
                        generic map (DWIDTH => 24, AWIDTH => 9)
200
                        port map (CLK_I => CLK_I, RST_I => RST_I, nRESET => nReset,
201
                                ADR0_I => vga_adr_o(10 downto 2), DAT0_I => empty_data, DAT0_O => mem0_dat_o, SEL0_I => vga_sel_o(2 downto 0),
202
                                WE0_I => vga_we_o, STB0_I => vga_clut_stb, CYC0_I => vga_cyc_o, ACK0_O => mem0_ack_o, ERR0_O => mem0_err_o,
203
                                ADR1_I => ADR_I(10 downto 2), DAT1_I => SDAT_I(23 downto 0), DAT1_O => mem1_dat_o, SEL1_I => SEL_I(2 downto 0),
204
                                WE1_I => WE_I, STB1_I => CLUT_STB_I, CYC1_I => CYC_I, ACK1_O => mem1_ack_o, ERR1_O => mem1_err_o);
205
 
206
        --
207
        -- assign outputs
208
        --
209
 
210
        -- wishbone master
211
        CYC_O <= '0' when (vga_clut_acc = '1') else vga_cyc_o;
212
        STB_O <= '0' when (vga_clut_acc = '1') else vga_stb_o;
213
        ADR_O <= vga_adr_o;
214
        SEL_O <= vga_sel_o;
215
        WE_O  <= vga_we_o;
216
        vga_dat_i(31 downto 24) <= MDAT_I(31 downto 24);
217
        vga_dat_I(23 downto  0) <= mem0_dat_o when (vga_clut_acc = '1') else MDAT_I(23 downto 0);
218
        vga_ack_i <= mem0_ack_o when (vga_clut_acc = '1') else ACK_I;
219
        vga_err_i <= mem0_err_o when (vga_clut_acc = '1') else ERR_I;
220
 
221
        -- wishbone slave
222
        SDAT_O <= (x"00" & mem1_dat_o) when (CLUT_STB_I = '1') else vga_dat_o;
223
        ACK_O  <= mem1_ack_o when (CLUT_STB_I = '1') else vga_ack_o;
224
        ERR_O  <= mem1_err_o when (CLUT_STB_I = '1') else vga_err_o;
225
end architecture structural;
226
 
227
 

powered by: WebSVN 2.1.0

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