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

Subversion Repositories wb_vga

[/] [wb_vga/] [trunk/] [vga_chip.vhd] - Blame information for rev 9

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 tantos
--
2
--  File: vga_chip.vhd
3
--
4
--  (c) Copyright Andras Tantos <andras_tantos@yahoo.com> 2001/03/31
5
--  This code is distributed under the terms and conditions of the GNU General Public Lince.
6
--
7
 
8
library IEEE;
9
use IEEE.std_logic_1164.all;
10
 
11 4 tantos
package constants is
12
    constant v_dat_width: positive := 16;
13
    constant v_adr_width : positive := 20;
14 6 tantos
    constant cpu_dat_width: positive := 32;
15
    constant cpu_adr_width: positive := 19;
16
    constant reg_adr_width: positive := 5;
17 4 tantos
    constant fifo_size: positive := 256;
18
--      constant addr_diff: integer := log2(cpu_dat_width/v_dat_width);
19
end constants;
20
 
21
library IEEE;
22
use IEEE.std_logic_1164.all;
23
 
24
library wb_vga;
25
use wb_vga.all;
26
use wb_vga.constants.all;
27
 
28
library wb_tk;
29
use wb_tk.all;
30
use wb_tk.technology.all;
31
 
32
 
33 2 tantos
-- same as VGA_CORE but without generics. Suited for post-layout simulation.
34
entity vga_chip is
35
        port (
36
                clk_i: in std_logic;
37
                clk_en: in std_logic := '1';
38 6 tantos
                rstn: in std_logic := '1';
39 2 tantos
 
40
                -- CPU bus interface
41 6 tantos
                data: inout std_logic_vector (cpu_dat_width-1 downto 0) := (others => 'Z');
42
                addr: in std_logic_vector (cpu_adr_width-1 downto 0) := (others => 'U');
43
                rdn: in std_logic := '1';
44
                wrn: in std_logic := '1';
45
                vmem_cen: in std_logic := '1';
46
                reg_cen: in std_logic := '1';
47
                byen: in std_logic_vector ((cpu_dat_width/8)-1 downto 0);
48
                waitn: out std_logic;
49 2 tantos
 
50
                -- video memory SRAM interface
51 4 tantos
                s_data : inout std_logic_vector(v_dat_width-1 downto 0);
52
                s_addr : out std_logic_vector(v_adr_width-1 downto 0);
53 2 tantos
                s_oen : out std_logic;
54
                s_wrhn : out std_logic;
55
                s_wrln : out std_logic;
56
                s_cen : out std_logic;
57
 
58
                -- sync blank and video signal outputs
59
                h_sync: out std_logic;
60
                h_blank: out std_logic;
61
                v_sync: out std_logic;
62
                v_blank: out std_logic;
63
                h_tc: out std_logic;
64
                v_tc: out std_logic;
65
                blank: out std_logic;
66 4 tantos
                video_out: out std_logic_vector (7 downto 0)   -- video output binary signal (unused bits are forced to 0)
67 2 tantos
        );
68
end vga_chip;
69
 
70
architecture vga_chip of vga_chip is
71 4 tantos
        component wb_async_slave
72
        generic (
73
                width: positive := 16;
74
                addr_width: positive := 20
75
        );
76
        port (
77
                clk_i: in std_logic;
78
                rst_i: in std_logic := '0';
79
 
80
                -- interface for wait-state generator state-machine
81
                wait_state: in std_logic_vector (3 downto 0);
82
 
83
                -- interface to wishbone master device
84
                adr_i: in std_logic_vector (addr_width-1 downto 0);
85
                sel_i: in std_logic_vector ((addr_width/8)-1 downto 0);
86
                dat_i: in std_logic_vector (width-1 downto 0);
87
                dat_o: out std_logic_vector (width-1 downto 0);
88
                dat_oi: in std_logic_vector (width-1 downto 0) := (others => '-');
89
                we_i: in std_logic;
90
                stb_i: in std_logic;
91
                ack_o: out std_logic := '0';
92
                ack_oi: in std_logic := '-';
93
 
94
                -- interface to async slave
95
                a_data: inout std_logic_vector (width-1 downto 0) := (others => 'Z');
96
                a_addr: out std_logic_vector (addr_width-1 downto 0) := (others => 'U');
97
                a_rdn: out std_logic := '1';
98
                a_wrn: out std_logic := '1';
99
                a_cen: out std_logic := '1';
100
                -- byte-enable signals
101
                a_byen: out std_logic_vector ((width/8)-1 downto 0)
102
        );
103
        end component;
104
 
105 6 tantos
    component wb_async_master
106
        generic (
107
                width: positive := 16;
108
                addr_width: positive := 20
109
        );
110
        port (
111
                clk_i: in std_logic;
112
                rst_i: in std_logic := '0';
113
 
114
                -- interface to wb slave devices
115
                s_adr_o: out std_logic_vector (addr_width-1 downto 0);
116
                s_sel_o: out std_logic_vector ((width/8)-1 downto 0);
117
                s_dat_i: in std_logic_vector (width-1 downto 0);
118
                s_dat_o: out std_logic_vector (width-1 downto 0);
119
                s_cyc_o: out std_logic;
120
                s_ack_i: in std_logic;
121
                s_err_i: in std_logic := '-';
122
                s_rty_i: in std_logic := '-';
123
                s_we_o: out std_logic;
124
                s_stb_o: out std_logic;
125
 
126
                -- interface to asyncron master device
127
                a_data: inout std_logic_vector (width-1 downto 0) := (others => 'Z');
128
                a_addr: in std_logic_vector (addr_width-1 downto 0) := (others => 'U');
129
                a_rdn: in std_logic := '1';
130
                a_wrn: in std_logic := '1';
131
                a_cen: in std_logic := '1';
132
                a_byen: in std_logic_vector ((width/8)-1 downto 0);
133
                a_waitn: out std_logic
134
        );
135
    end component;
136
 
137 2 tantos
        component vga_core
138
        generic (
139 4 tantos
                v_dat_width: positive := 16;
140
                v_adr_width : positive := 20;
141 6 tantos
                cpu_dat_width: positive := 16;
142
                cpu_adr_width: positive := 20;
143
                reg_adr_width: positive := 20;
144 4 tantos
                fifo_size: positive := 256
145 2 tantos
        );
146
        port (
147
                clk_i: in std_logic;
148
                clk_en: in std_logic := '1';
149
                rst_i: in std_logic := '0';
150 6 tantos
 
151
                -- CPU memory bus interface
152
                vmem_cyc_i: in std_logic;
153
                vmem_we_i: in std_logic;
154 4 tantos
                vmem_stb_i: in std_logic;   -- selects video memory
155 6 tantos
                vmem_ack_o: out std_logic;
156
                vmem_ack_oi: in std_logic;
157
                vmem_adr_i: in std_logic_vector (cpu_adr_width-1 downto 0);
158
            vmem_sel_i: in std_logic_vector ((cpu_dat_width/8)-1 downto 0) := (others => '1');
159
                vmem_dat_i: in std_logic_vector (cpu_dat_width-1 downto 0);
160
                vmem_dat_oi: in std_logic_vector (cpu_dat_width-1 downto 0);
161
                vmem_dat_o: out std_logic_vector (cpu_dat_width-1 downto 0);
162
 
163
                -- CPU register bus interface
164
                reg_cyc_i: in std_logic;
165
                reg_we_i: in std_logic;
166
                reg_stb_i: in std_logic;    -- selects configuration registers
167
                reg_ack_o: out std_logic;
168
                reg_ack_oi: in std_logic;
169
                reg_adr_i: in std_logic_vector (reg_adr_width-1 downto 0);
170
            reg_sel_i: in std_logic_vector ((cpu_dat_width/8)-1 downto 0) := (others => '1');
171
                reg_dat_i: in std_logic_vector (cpu_dat_width-1 downto 0);
172
                reg_dat_oi: in std_logic_vector (cpu_dat_width-1 downto 0);
173
                reg_dat_o: out std_logic_vector (cpu_dat_width-1 downto 0);
174
 
175 4 tantos
                -- video memory interface
176
                v_adr_o: out std_logic_vector (v_adr_width-1 downto 0);
177
                v_sel_o: out std_logic_vector ((v_dat_width/8)-1 downto 0);
178
                v_dat_i: in std_logic_vector (v_dat_width-1 downto 0);
179
                v_dat_o: out std_logic_vector (v_dat_width-1 downto 0);
180
                v_cyc_o: out std_logic;
181
                v_ack_i: in std_logic;
182
                v_we_o: out std_logic;
183
                v_stb_o: out std_logic;
184 6 tantos
 
185 2 tantos
                -- sync blank and video signal outputs
186
                h_sync: out std_logic;
187
                h_blank: out std_logic;
188
                v_sync: out std_logic;
189
                v_blank: out std_logic;
190
                h_tc: out std_logic;
191
                v_tc: out std_logic;
192
                blank: out std_logic;
193 4 tantos
                video_out: out std_logic_vector (7 downto 0)  -- video output binary signal (unused bits are forced to 0)
194 2 tantos
        );
195
        end component;
196 4 tantos
 
197
        component wb_out_reg
198
        generic (
199
                width : positive := 8;
200
                bus_width: positive := 8;
201
                offset: integer := 0
202
        );
203
        port (
204
                clk_i: in std_logic;
205
                rst_i: in std_logic;
206
                rst_val: std_logic_vector(width-1 downto 0) := (others => '0');
207
 
208
        cyc_i: in std_logic := '1';
209
                stb_i: in std_logic;
210
        sel_i: in std_logic_vector ((bus_width/8)-1 downto 0) := (others => '1');
211
                we_i: in std_logic;
212
                ack_o: out std_logic;
213
                ack_oi: in std_logic := '-';
214
                adr_i: in std_logic_vector (size2bits((width+offset+bus_width-1)/bus_width)-1 downto 0) := (others => '0');
215
                dat_i: in std_logic_vector (bus_width-1 downto 0);
216
                dat_oi: in std_logic_vector (bus_width-1 downto 0) := (others => '-');
217
                dat_o: out std_logic_vector (bus_width-1 downto 0);
218
                q: out std_logic_vector (width-1 downto 0)
219
        );
220
        end component;
221
 
222 6 tantos
    signal reg_ack_o: std_logic;
223
    signal reg_dat_o: std_logic_vector(cpu_dat_width-1 downto 0);
224
 
225
    signal reg_stb: std_logic;
226 4 tantos
    signal ws_stb: std_logic;
227
    signal wait_state: std_logic_vector(3 downto 0);
228
 
229
        signal v_adr_o: std_logic_vector (v_adr_width-1 downto 0);
230
        signal v_sel_o: std_logic_vector ((v_dat_width/8)-1 downto 0);
231
        signal v_dat_i: std_logic_vector (v_dat_width-1 downto 0);
232
        signal v_dat_o: std_logic_vector (v_dat_width-1 downto 0);
233
        signal v_cyc_o: std_logic;
234
        signal v_ack_i: std_logic;
235
        signal v_we_o: std_logic;
236
        signal v_stb_o: std_logic;
237
 
238
        signal s_byen : std_logic_vector((v_dat_width/8)-1 downto 0);
239
 
240
        signal ws_dat_o: std_logic_vector(cpu_dat_width-1 downto 0);
241
        signal ws_ack_o: std_logic;
242
 
243
        signal s_wrn: std_logic;
244 6 tantos
 
245
 
246
        signal dat_i: std_logic_vector (cpu_dat_width-1 downto 0);
247
        signal dat_oi: std_logic_vector (cpu_dat_width-1 downto 0);
248
        signal dat_o: std_logic_vector (cpu_dat_width-1 downto 0);
249
        signal cyc_i: std_logic;
250
        signal ack_o: std_logic;
251
        signal ack_oi: std_logic;
252
        signal we_i: std_logic;
253
        signal vmem_stb_i: std_logic;
254
        signal reg_stb_i: std_logic;
255
        signal adr_i: std_logic_vector (cpu_adr_width-1 downto 0);
256
        signal sel_i: std_logic_vector ((cpu_dat_width/8)-1 downto 0) := (others => '1');
257
 
258
        signal cen: std_logic;
259
        signal stb: std_logic;
260
 
261
    signal rst_i: std_logic := '0';
262
 
263
        constant vga_reg_size: integer := size2bits((32*8+cpu_dat_width-1)/cpu_dat_width);
264 2 tantos
begin
265 6 tantos
    rst_i <= not rstn;
266
 
267 4 tantos
        ws_reg: wb_out_reg
268
                generic map( width => 4, bus_width => cpu_dat_width , offset => 0 )
269
                port map(
270
                stb_i => ws_stb,
271
                q => wait_state,
272
                rst_val => "1111",
273
                dat_oi => dat_oi,
274
                dat_o => ws_dat_o,
275
                ack_oi => ack_oi,
276
                ack_o => ws_ack_o,
277
                adr_i => adr_i(0 downto 0), -- range should be calculated !!!
278
                sel_i => sel_i, cyc_i => cyc_i, we_i => we_i, clk_i => clk_i, rst_i => rst_i, dat_i => dat_i );
279
 
280
        core : vga_core
281
        generic map (
282
                v_dat_width => v_dat_width,
283
                v_adr_width => v_adr_width,
284
                cpu_dat_width => cpu_dat_width,
285
                cpu_adr_width => cpu_adr_width,
286 6 tantos
                reg_adr_width => reg_adr_width,
287 4 tantos
                fifo_size => fifo_size
288
        )
289 2 tantos
                port map (
290
                clk_i => clk_i,
291
                    clk_en => clk_en,
292
                    rst_i => rst_i,
293 6 tantos
 
294 4 tantos
                -- CPU bus interface
295 6 tantos
                vmem_cyc_i => cyc_i,
296
                vmem_we_i => we_i,
297
                vmem_stb_i => vmem_stb_i,
298
                vmem_ack_o => ack_o,
299
                vmem_ack_oi => reg_ack_o,
300
                vmem_adr_i => adr_i,
301
            vmem_sel_i => sel_i,
302
                vmem_dat_i => dat_i,
303
                vmem_dat_oi => reg_dat_o,
304
                vmem_dat_o => dat_o,
305
 
306
                -- CPU register bus interface
307
                reg_cyc_i => cyc_i,
308
                reg_we_i => we_i,
309
                reg_stb_i => reg_stb_i,
310
                reg_ack_o => reg_ack_o,
311
                reg_ack_oi => ack_oi,
312
                reg_adr_i => adr_i(reg_adr_width-1 downto 0),
313
            reg_sel_i => sel_i,
314
                reg_dat_i => dat_i,
315
                reg_dat_oi => dat_oi,
316
                reg_dat_o => reg_dat_o,
317
 
318
 
319 4 tantos
                -- video memory interface
320
                v_adr_o => v_adr_o,
321
                v_sel_o => v_sel_o,
322
                v_dat_i => v_dat_i,
323
                v_dat_o => v_dat_o,
324
                v_cyc_o => v_cyc_o,
325
                v_ack_i => v_ack_i,
326
                v_we_o => v_we_o,
327
                v_stb_o => v_stb_o,
328
 
329 2 tantos
                h_sync => h_sync,
330
                    h_blank => h_blank,
331
                    v_sync => v_sync,
332
                    v_blank => v_blank,
333
                    h_tc => h_tc,
334
                    v_tc => v_tc,
335
                    blank => blank,
336 4 tantos
                video_out => video_out
337
                );
338 2 tantos
 
339 4 tantos
        mem_driver: wb_async_slave
340
            generic map (width => v_dat_width, addr_width => v_adr_width)
341
            port map (
342
                clk_i => clk_i,
343
                    rst_i => rst_i,
344
 
345
                wait_state => wait_state,
346
 
347
                adr_i => v_adr_o,
348
                        sel_i => v_sel_o,
349
                dat_o => v_dat_i,
350
                dat_i => v_dat_o,
351
--              dat_oi => (others => '0'),
352
                we_i => v_we_o,
353
                stb_i => v_stb_o,
354
                ack_o => v_ack_i,
355
                ack_oi => '0',
356
 
357
                a_data => s_data,
358
                a_addr => s_addr,
359
                a_rdn => s_oen,
360
                a_wrn => s_wrn,
361
                a_cen => s_cen,
362
                a_byen => s_byen
363
            );
364
 
365
        s_wrln <= s_wrn or s_byen(0);
366
        s_wrhn <= s_wrn or s_byen(1);
367
 
368 6 tantos
    master: wb_async_master
369
        generic map (
370
                width => cpu_dat_width,
371
                addr_width => cpu_adr_width
372
        )
373
        port map (
374
                clk_i => clk_i,
375
                rst_i => rst_i,
376
 
377
                -- interface to wb slave devices
378
                s_adr_o => adr_i,
379
                s_sel_o => sel_i,
380
                s_dat_i => dat_o,
381
                s_dat_o => dat_i,
382
                s_cyc_o => cyc_i,
383
                s_ack_i => ack_o,
384
                s_err_i => '0',
385
                s_rty_i => '0',
386
                s_we_o => we_i,
387
                s_stb_o => stb,
388
 
389
                -- interface to asyncron master device
390
                a_data => data,
391
                a_addr => addr,
392
                a_rdn => rdn,
393
                a_wrn => wrn,
394
                a_cen => cen,
395
                a_byen => byen,
396
                a_waitn => waitn
397
        );
398 4 tantos
 
399 6 tantos
    cen <= vmem_cen and reg_cen;
400
    vmem_stb_i <= stb and not vmem_cen;
401
    reg_stb_i <= stb and not reg_cen;
402
 
403 4 tantos
        addr_decoder: process is
404
        begin
405
                wait on reg_stb_i, adr_i;
406
 
407 6 tantos
        reg_stb <= '0';
408 4 tantos
        ws_stb <= '0';
409
 
410
                if (reg_stb_i = '1') then
411 6 tantos
                        case (adr_i(vga_reg_size)) is
412
                                when '0' => reg_stb <= '1';
413
                                when '1' => ws_stb <= '1';
414 4 tantos
                                when others =>
415
                        end case;
416
                end if;
417
        end process;
418
 
419 2 tantos
end vga_chip;

powered by: WebSVN 2.1.0

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