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

Subversion Repositories System09

[/] [System09/] [trunk/] [rtl/] [VHDL/] [vdu8_spram.vhd] - Blame information for rev 206

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 205 davidgb
--===========================================================================--
2
--                                                                           --
3
--  vdu8.vhd - Synthesizable Colour Video Display Unit for System09          --
4
--                                                                           --
5
--===========================================================================--
6
--
7
--  File name      : vdu8.vhd
8
--
9
--  Purpose        : Implements a text based Colour Video Display Unit for System09
10
--                   Supports 2KByte Text buffer and 2KByte Attribute memory
11
--                   Displays 80 characters across by 25 character rows
12
--                   Characters are 8 pixels across x 16 lines down.
13
--                   Character attribute bita for foreground and backgrond colour
14
--                   1 bit for each Blue Green and Red signal
15
--                   Supports 2 x 8 chunky graphics character mode.
16
--                   Uses Generic arguments for setting the video synchronization timing.
17
--                  
18
--  Dependencies   : ieee.std_logic_1164
19
--                   ieee.numeric_std
20
--
21
--  Uses           : ram_2k (ram2k_b16.vhd)             2KByte Character & Attribute buffer
22
--                   char_rom (char_rom2k_b16.vhd)      2KByte Character Generator ROM 
23
--
24
--  Author         : John E. Kent
25
--
26
--  Email          : dilbert57@opencores.org      
27
--
28
--  Web            : http://opencores.org/project,system09
29
--
30
--  Description    : Display Timing:
31
--                       800 pixels / line
32
--                       446 lines / frame
33
--                       None interlaced
34
--                       25MHz pixel clock implies 
35
--                       31.25 KHz line rate
36
--                       70.067 Hz frame rate   
37
--                       Timing settable by generics.
38
--
39
--                   Display Size:
40
--                       80 characters across
41
--                       25 characters down.
42
--
43
--                   Character Size:
44
--                        8 horizontal pixels across
45
--                       16 vertical scan lines down (2 scan lines/row)
46
--
47
--                   Registers:
48
--                   Base + 0 ASCII character register
49
--                            Writing to this register writes an 8 bit byte 
50
--                            into the text buffer at the specified cursor position
51
--                            Text Mode: ASCII Character (0 to 127)
52
--                            Chunky Graphics Mode: B0 B1 (0 to 255)
53
--                                                  B2 B3
54
--                                                  B4 B5
55
--                                                  B6 B7
56
--                   Base + 1 Attibute bit (0 to 255)
57
--                            Writing to the register writes an 8 bit byte 
58
--                            into the attribute buffer at the specified cursor position
59
--                            B7 - 0 => Text Mode / 1 => Chunky Graphics Mode
60
--                            B6 - 1 => Character Background Blue
61
--                            B5 - 1 => Character Background Green
62
--                            B4 - 1 => Character Background Red
63
--                            B3 - 1 => Character Background & Foreground Alternates
64
--                            B2 - 1 => Character Foreground Blue
65
--                            B1 - 1 => Character Foreground Green
66
--                            B0 - 1 => Character Foreground Red
67
--                   Base + 2 Cursor Horizontal Position (0 to 79)
68
--                   Base + 3 Cusror Vertical Position (0 to 24)
69
--                   Base + 4 Vertical Scroll Offset (0 to 24)
70
--                            Scrolls the display up by the specified number of character rows
71
--
72
--  Video Timing :
73
--
74
--  Horizontal 800 Pixels/ 25MHz Pixel Clock = 32usec Line period = 31.25 KHz Line Frequency
75
--  /--------------------------\_____________/---------------\______________/
76
--      640 Pixels Display       16 Pixel FP    96 Pixel HS     48 Pixel BP
77
--    
78
--      VGA_CLK_FREQ           : integer := 25000000; -- HZ
79
--           VGA_HOR_FRONT_PORCH    : integer := 16; -- PIXELS 0.64us (0.94us)
80
--           VGA_HOR_SYNC           : integer := 96; -- PIXELS 3.84us (3.77us)
81
--           VGA_HOR_BACK_PORCH     : integer := 48; -- PIXELS 1.92us (1.89us)
82
--           VGA_PIX_PER_CHAR       : integer := 8;  -- PIXELS 0.32us
83
--           VGA_HOR_CHARS          : integer := 80; -- CHARACTERS 25.6us
84
--
85
--  Vertical 446 Lines * 32 usec Line rate = 14.272ms Frame Period = 70.07Hz Frame frequency  
86
--  /---------------------------\____________/---------------\______________/
87
--      400 Line Display          10 Line FP     2 Line VS      34 Line BP
88
--
89
--           VGA_VER_FRONT_PORCH    : integer := 10; -- LINES 0.320ms
90
--           VGA_VER_SYNC           : integer := 2;  -- LINES 0.064ms
91
--           VGA_VER_BACK_PORCH     : integer := 34; -- LINES 1.088ms
92
--           VGA_LIN_PER_CHAR       : integer := 16; -- LINES 0.512ms
93
--           VGA_VER_CHARS          : integer := 25; -- CHARACTERS 12.8ms
94
--
95
--  Copyright (C) 2003 - 2010 John Kent
96
--
97
--  This program is free software: you can redistribute it and/or modify
98
--  it under the terms of the GNU General Public License as published by
99
--  the Free Software Foundation, either version 3 of the License, or
100
--  (at your option) any later version.
101
--
102
--  This program is distributed in the hope that it will be useful,
103
--  but WITHOUT ANY WARRANTY; without even the implied warranty of
104
--  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
105
--  GNU General Public License for more details.
106
--
107
--  You should have received a copy of the GNU General Public License
108
--  along with this program.  If not, see <http://www.gnu.org/licenses/>.
109
--
110
--===========================================================================--
111
--                                                                           --
112
--                              Revision  History                            --
113
--                                                                           --
114
--===========================================================================--
115
--
116
-- Version Author      Date        Changes
117
--
118
-- 0.1     John Kent   2004-09-03  Initial release
119
--
120
-- 0.2     Bert Cuzeau 2007-01-16  Modified by for compliance and code cleanliness
121
--                                 The effort is not over.
122
--                                 There are still signal initialized, which is BAD.
123
--
124
-- 0.3     John Kent   2007-02-07  Added generics for VGA Timing
125
--
126
-- 0.4     John Kent   2010-07-03  Added GPL notice. 
127
--                                 Updated description.
128
--                                 Rearranged Video Timing
129 206 davidgb
-- 0.5     David Burnette 2021-02-19 Changed video memory to use parameterized block
130
--                                   memory instead of instantiating hard ram macros.
131 205 davidgb
 
132
Library IEEE;
133
  use IEEE.std_logic_1164.all;
134
  use IEEE.numeric_std.all;
135
--Library unisim;
136
--  use unisim.vcomponents.all;
137
 
138
Entity vdu8 is
139
  generic(
140
        VGA_CLK_FREQ           : integer := 25000000; -- HZ
141
             VGA_HOR_CHARS          : integer := 80; -- CHARACTERS 25.6us
142
             VGA_HOR_CHAR_PIXELS    : integer := 8;  -- PIXELS 0.32us
143
             VGA_HOR_FRONT_PORCH    : integer := 16; -- PIXELS 0.64us
144
             VGA_HOR_SYNC           : integer := 96; -- PIXELS 3.84us
145
             VGA_HOR_BACK_PORCH     : integer := 48; -- PIXELS 1.92us
146
             VGA_VER_CHARS          : integer := 25; -- CHARACTERS 12.8ms
147
             VGA_VER_CHAR_LINES     : integer := 16; -- LINES 0.512ms
148
             VGA_VER_FRONT_PORCH    : integer := 10; -- LINES 0.320ms
149
             VGA_VER_SYNC           : integer := 2;  -- LINES 0.064ms
150
             VGA_VER_BACK_PORCH     : integer := 34  -- LINES 1.088ms
151
  );
152
  port(
153
    -- control register interface
154
    vdu_clk      : in  std_logic;       -- 12.5/25 MHz CPU Clock
155
    vdu_rst      : in  std_logic;
156
    vdu_cs       : in  std_logic;
157
    vdu_rw       : in  std_logic;
158
    vdu_addr     : in  std_logic_vector(2 downto 0);
159
    vdu_data_in  : in  std_logic_vector(7 downto 0);
160
    vdu_data_out : out std_logic_vector(7 downto 0);
161
 
162
    -- vga port connections
163
    vga_clk      : in  std_logic;       -- 25MHz clock
164
    vga_red_o    : out std_logic;
165
    vga_green_o  : out std_logic;
166
    vga_blue_o   : out std_logic;
167
    vga_hsync_o  : out std_logic;
168
    vga_vsync_o  : out std_logic
169
    );
170
end vdu8;
171
 
172
Architecture RTL of vdu8 is
173
  --
174
  -- Synchronisation constants
175
  --
176
  -- Displayed Characters per row
177
  constant HOR_DISP_CHR : integer := VGA_HOR_CHARS;
178
  -- Last horizontal pixel displayed
179
  constant HOR_DISP_END : integer := (HOR_DISP_CHR * VGA_HOR_CHAR_PIXELS) - 1;
180
  -- Start of horizontal synch pulse
181
  constant HOR_SYNC_BEG : integer := HOR_DISP_END + VGA_HOR_FRONT_PORCH;
182
  -- End of Horizontal Synch pulse
183
  constant HOR_SYNC_END : integer := HOR_SYNC_BEG + VGA_HOR_SYNC;
184
  -- Last pixel in scan line
185
  constant HOR_SCAN_END : integer := HOR_SYNC_END + VGA_HOR_BACK_PORCH;
186
 
187
  -- Displayed Characters per Column
188
  constant VER_DISP_CHR : integer := VGA_VER_CHARS;
189
  -- last row displayed
190
  constant VER_DISP_END : integer := (VER_DISP_CHR * VGA_VER_CHAR_LINES) - 1;
191
  -- start of vertical synch pulse
192
  constant VER_SYNC_BEG : integer := VER_DISP_END + VGA_VER_FRONT_PORCH;
193
  -- end of vertical synch pulse
194
  constant VER_SYNC_END : integer := VER_SYNC_BEG + VGA_VER_SYNC;
195
  -- Last scan row in the frame
196
  constant VER_SCAN_END : integer := VER_SYNC_END + VGA_VER_BACK_PORCH;
197
 
198
  signal horiz_sync    : std_logic := '1';
199
  signal vert_sync     : std_logic := '1';
200
  signal cursor_on_v   : std_logic;
201
  signal cursor_on_h   : std_logic;
202
  signal video_on_v    : std_logic := '0';
203
  signal video_on_h    : std_logic := '0';
204
  signal h_count       : std_logic_vector(9 downto 0) := (others=>'0');
205
  signal v_count       : std_logic_vector(8 downto 0) := (others=>'0');  -- 0 to VER_SCAN_END
206
  signal blink_count   : std_logic_vector(22 downto 0):= (others=>'1');
207
  --
208
  -- Character generator ROM
209
  --
210
  signal char_addr     : std_logic_vector(10 downto 0);
211
  signal char_data_out : std_logic_vector(7 downto 0);
212
 
213
  --
214
  -- Control Registers
215
  --
216
  signal reg_character : std_logic_vector(7 downto 0);
217
  signal reg_colour    : std_logic_vector(7 downto 0);
218
  signal reg_hcursor   : std_logic_vector(6 downto 0);   -- 80 columns
219
  signal reg_vcursor   : std_logic_vector(4 downto 0);   -- 25 rows
220
  signal reg_voffset   : std_logic_vector(4 downto 0);   -- 25 rows
221
  --
222
  -- Video Shift register
223
  --
224
  signal vga_shift     : std_logic_vector(7 downto 0);
225
  signal vga_fg_colour : std_logic_vector(2 downto 0);
226
  signal vga_bg_colour : std_logic_vector(2 downto 0);
227
  signal cursor_on     : std_logic;
228
  signal cursor_on1    : std_logic;
229
  signal video_on      : std_logic := '0';
230
  signal video_on1     : std_logic := '0';
231
  signal video_on2     : std_logic := '0';
232
  --
233
  -- vga character ram access bus
234
  --
235
  signal col_addr      : std_logic_vector(6 downto 0) := (others=>'0'); -- 0 to 79
236
  signal row_addr      : unsigned(5 downto 0)         := (others=>'0'); -- 0 to 49 (25 * 2 -1)
237
  signal col1_addr     : std_logic_vector(6 downto 0) := (others=>'0'); -- 0 to 79
238
  signal row1_addr     : unsigned(5 downto 0)         := (others=>'0'); -- 0 to 49 (25 * 2 - 1)
239
  signal hor_addr      : std_logic_vector(6 downto 0) := (others=>'0'); -- 0 to 79
240
  signal ver_addr      : std_logic_vector(6 downto 0) := (others=>'0'); -- 0 to 124
241
  signal vga0_cs       : std_logic;
242
  signal vga0_rw       : std_logic;
243
  signal vga1_cs       : std_logic;
244
  signal vga1_rw       : std_logic;
245
  signal vga2_cs       : std_logic;
246
  signal vga2_rw       : std_logic;
247
  signal vga_cs        : std_logic;
248
  signal vga_rw        : std_logic;
249
  signal vga_addr      : std_logic_vector(10 downto 0) := (others=>'0');  -- 2K byte character buffer
250
  signal vga_data_out  : std_logic_vector(7 downto 0);
251
  signal attr_data_out : std_logic_vector(7 downto 0);
252
  --
253
  -- Character write handshake signals
254
  --
255
  signal req_write     : std_logic;     -- request character write
256
  signal ack_write     : std_logic;
257
 
258
  --
259
  -- Block Ram Character gen
260
  --
261
  component char_rom
262
    port (
263
      clk      : in  std_logic;
264
      rst      : in  std_logic;
265
      cs       : in  std_logic;
266
      rw       : in  std_logic;
267
      addr     : in  std_logic_vector (10 downto 0);
268
      data_in  : in std_logic_vector (7 downto 0);
269
      data_out : out std_logic_vector (7 downto 0)
270
      );
271
  end component;
272
 
273
 
274
  component block_spram
275
    generic (
276
      dwidth : integer := 8;     -- parameterized data width
277
           awidth : integer := 16     -- parameterized address width
278
         );
279
         port (
280
      clk         : in std_logic;
281
           cs          : in std_logic; -- chip-select/enable
282
           addr        : in std_logic_vector(awidth-1 downto 0);
283
           rw          : in std_logic;
284
           data_in     : in std_logic_vector(dwidth-1 downto 0);
285
           data_out    : out std_logic_vector(dwidth-1 downto 0)
286
         );
287
  end component;
288
 
289
begin
290
 
291
--
292
-- instantiate Character generator ROM
293
--
294
vdu_char_rom : char_rom port map(
295
        clk      => vga_clk,
296
        rst      => vdu_rst,
297
        cs       => '1',
298
        rw       => '1',
299
        addr     => char_addr,
300
        data_in  => "00000000",
301
        data_out => char_data_out
302
    );
303
 
304
--
305
-- Character buffer RAM
306
--
307
char_buff_ram : block_spram
308
  generic map( dwidth => 8, awidth => 11) -- 2k bytes
309
  port map(
310
    clk      => vga_clk,
311
    cs       => vga_cs,
312
    rw       => vga_rw,
313
    addr     => vga_addr,
314
    data_in  => reg_character,
315
    data_out => vga_data_out
316
    );
317
 
318
 
319
--
320
-- Attribute buffer RAM
321
--
322
attr_buff_ram : block_spram
323
  generic map( dwidth => 8, awidth => 11) -- 2k bytes
324
  port map(
325
    clk      => vga_clk,
326
    cs       => vga_cs,
327
    rw       => vga_rw,
328
    addr     => vga_addr,
329
    data_in  => reg_colour,
330
    data_out => attr_data_out
331
    );
332
 
333
--
334
-- CPU Write interface
335
--
336
  vga_cpu_write : process(vdu_clk, vdu_rst)
337
  begin
338
    if vdu_rst = '1' then
339
      reg_character <= "00000000";
340
      reg_colour    <= "00000111";
341
      reg_hcursor   <= "0000000";
342
      reg_vcursor   <= "00000";
343
      reg_voffset   <= "00000";
344
      req_write     <= '0';
345
 
346
    elsif vdu_clk'event and vdu_clk = '0' then
347
      if (vdu_cs = '1') and (vdu_rw = '0') then
348
        case vdu_addr is
349
          when "000" =>
350
            reg_character <= vdu_data_in;
351
            req_write     <= '1';
352
          when "001" =>
353
            reg_colour    <= vdu_data_in;
354
          when "010" =>
355
            reg_hcursor   <= vdu_data_in(6 downto 0);
356
          when "011" =>
357
            reg_vcursor   <= vdu_data_in(4 downto 0);
358
          when others =>
359
            reg_voffset   <= vdu_data_in(4 downto 0);
360
        end case;
361
      else
362
 
363
        if (req_write = '1') and (ack_write = '1') then
364
          req_write <= '0';
365
        else
366
          req_write <= req_write;
367
        end if;
368
 
369
      end if;
370
    end if;
371
  end process;
372
--
373
-- CPU Read interface
374
--
375
  vga_cpu_read : process(vdu_addr, vdu_cs,
376
                          reg_character, reg_colour,
377
                          reg_hcursor, reg_vcursor, reg_voffset)
378
  begin
379
    case vdu_addr is
380
      when "000" =>
381
        vdu_data_out <= reg_character;
382
      when "001" =>
383
        vdu_data_out <= reg_colour;
384
      when "010" =>
385
        vdu_data_out <= "0" & reg_hcursor;
386
      when "011" =>
387
        vdu_data_out <= "000" & reg_vcursor;
388
      when others =>
389
        vdu_data_out <= "000" & reg_voffset;
390
    end case;
391
  end process;
392
 
393
--
394
-- Video memory access
395
--
396
  vga_addr_proc : process(vga_clk, vdu_rst)
397
  begin
398
 
399
    if vdu_rst = '1' then
400
      vga0_cs   <= '0';
401
      vga0_rw   <= '1';
402
      row_addr  <= "000000";
403
      col_addr  <= "0000000";
404
      --
405
      vga1_cs   <= '0';
406
      vga1_rw   <= '1';
407
      row1_addr <= "000000";
408
      col1_addr <= "0000000";
409
      --
410
      vga2_cs   <= '0';
411
      vga2_rw   <= '1';
412
      ver_addr  <= "0000000";
413
      hor_addr  <= "0000000";
414
      --
415
      vga_cs    <= '0';
416
      vga_rw    <= '1';
417
      vga_addr  <= "00000000000";
418
 
419
    elsif vga_clk'event and vga_clk = '0' then
420
      --
421
      -- on h_count = 0 initiate character write.
422
      -- all other cycles are reads.
423
      --
424
      case h_count(2 downto 0) is
425
        when "000" =>                   -- pipeline character write
426
          vga0_cs  <= req_write;
427
          vga0_rw  <= '0';
428
          col_addr <= reg_hcursor(6 downto 0);
429
          row_addr <= unsigned("0" & reg_vcursor(4 downto 0)) + unsigned("0" & reg_voffset(4 downto 0));
430
        when others =>                  -- other 6 cycles free
431
          vga0_cs  <= '1';
432
          vga0_rw  <= '1';
433
          col_addr <= h_count(9 downto 3);
434
          row_addr <= unsigned("0" & v_count(8 downto 4)) + unsigned("0" & reg_voffset(4 downto 0));
435
      end case;
436
      --
437
      -- on vga_clk + 1 round off row address
438
      --
439
      vga1_cs <= vga0_cs;
440
      vga1_rw <= vga0_rw;
441
      if row_addr < VER_DISP_CHR then
442
        row1_addr <= row_addr;
443
      else
444
        row1_addr <= row_addr - VER_DISP_CHR;
445
      end if;
446
      col1_addr <= col_addr;
447
      --
448
      -- on vga_clk + 2 calculate vertical address
449
      --
450
      vga2_cs   <= vga1_cs;
451
      vga2_rw   <= vga1_rw;
452
      ver_addr  <= std_logic_vector(unsigned("00" & row1_addr(4 downto 0)) + unsigned(row1_addr(4 downto 0) & "00"));
453
      hor_addr  <= col1_addr;
454
      --
455
      -- on vga_clk + 3 calculate memory address
456
      --
457
      vga_cs    <= vga2_cs;
458
      vga_rw    <= vga2_rw;
459
      vga_addr  <= std_logic_vector(unsigned("0000" & hor_addr) + unsigned(ver_addr & "0000"));
460
    end if;
461
  end process;
462
--
463
-- Video shift register
464
--
465
  vga_shift_proc : process( vga_clk, vdu_rst)
466
  begin
467
    if vdu_rst = '1' then
468
      ack_write     <= '0';
469
      video_on2     <= '0';
470
      video_on      <= '0';
471
      cursor_on     <= '0';
472
      vga_bg_colour <= "000";
473
      vga_fg_colour <= "111";
474
      vga_shift     <= "00000000";
475
      vga_red_o     <= '0';
476
      vga_green_o   <= '0';
477
      vga_blue_o    <= '0';
478
      -- Put all video signals through DFFs to elminate any delays that cause a blurry image
479
 
480
    elsif vga_clk'event and vga_clk = '0' then
481
      -- Character Data valid on 1 count
482
      if h_count(2 downto 0) = "000" then
483
        if (req_write = '1') and (ack_write = '0') then
484
          ack_write <= '1';
485
        elsif (req_write = '0') and (ack_write = '1') then
486
          ack_write <= '0';
487
        else
488
          ack_write <= ack_write;
489
        end if;
490
        video_on2     <= video_on1;
491
        video_on      <= video_on2;
492
        cursor_on     <= (cursor_on1 or attr_data_out(3)) and blink_count(22);
493
        vga_fg_colour <= attr_data_out(2 downto 0);
494
        vga_bg_colour <= attr_data_out(6 downto 4);
495
        if attr_data_out(7) = '0' then
496
          vga_shift <= char_data_out;
497
        else
498
          case v_count(3 downto 2) is
499
            when "00" =>
500
              vga_shift(7 downto 4) <= vga_data_out(0) & vga_data_out(0) & vga_data_out(0) & vga_data_out(0);
501
              vga_shift(3 downto 0) <= vga_data_out(1) & vga_data_out(1) & vga_data_out(1) & vga_data_out(1);
502
            when "01" =>
503
              vga_shift(7 downto 4) <= vga_data_out(2) & vga_data_out(2) & vga_data_out(2) & vga_data_out(2);
504
              vga_shift(3 downto 0) <= vga_data_out(3) & vga_data_out(3) & vga_data_out(3) & vga_data_out(3);
505
            when "10" =>
506
              vga_shift(7 downto 4) <= vga_data_out(4) & vga_data_out(4) & vga_data_out(4) & vga_data_out(4);
507
              vga_shift(3 downto 0) <= vga_data_out(5) & vga_data_out(5) & vga_data_out(5) & vga_data_out(5);
508
            when others =>
509
              vga_shift(7 downto 4) <= vga_data_out(6) & vga_data_out(6) & vga_data_out(6) & vga_data_out(6);
510
              vga_shift(3 downto 0) <= vga_data_out(7) & vga_data_out(7) & vga_data_out(7) & vga_data_out(7);
511
          end case;
512
        end if;
513
      else
514
        vga_shift <= vga_shift(6 downto 0) & '0';
515
      end if;
516
 
517
      --
518
      -- Colour mask is
519
      --  7  6  5  4  3  2  1  0
520
      --  X BG BB BR  X FG FB FR
521
      --
522
      if vga_shift(7) = (not cursor_on) then
523
        vga_red_o   <= video_on and vga_fg_colour(0);
524
        vga_green_o <= video_on and vga_fg_colour(1);
525
        vga_blue_o  <= video_on and vga_fg_colour(2);
526
      else
527
        vga_red_o   <= video_on and vga_bg_colour(0);
528
        vga_green_o <= video_on and vga_bg_colour(1);
529
        vga_blue_o  <= video_on and vga_bg_colour(2);
530
      end if;
531
    end if;
532
  end process;
533
 
534
 
535
--
536
-- Sync generator & timing process
537
-- Generate Horizontal and Vertical Timing Signals for Video Signal
538
--
539
  vga_sync : process(vga_clk)
540
  begin
541
    if vga_clk'event and vga_clk = '0' then
542
      --
543
      -- H_count counts pixels (640 + extra time for sync signals)
544
      --
545
      --  Horiz_sync  -----------------------------__________--------
546
      --  H_count       0                640      659       755    799
547
      --
548
      if unsigned(h_count) = HOR_SCAN_END then
549
        h_count <= (others=>'0');
550
      else
551
        h_count <= std_logic_vector(unsigned(h_count) + 1);
552
      end if;
553
--
554
-- Generate Horizontal Sync Signal using H_count
555
--
556
      if unsigned(h_count) = HOR_SYNC_BEG then
557
        horiz_sync <= '0';
558
      elsif unsigned(h_count) = HOR_SYNC_END then
559
        horiz_sync <= '1';
560
      else
561
        horiz_sync <= horiz_sync;
562
      end if;
563
--
564
-- V_count counts rows of pixels
565
-- 400 lines + extra time for sync signals
566
-- 25 rows * 16 scan lines
567
--
568
--  Vert_sync      ---------------------------------_______------------
569
--  V_count         0                       400    413     414        444
570
--
571
      if (unsigned(v_count) = VER_SCAN_END) and (unsigned(h_count) = HOR_SCAN_END) then
572
        v_count <= "000000000";
573
      elsif unsigned(h_count) = HOR_SYNC_END then
574
        v_count <= std_logic_vector(unsigned(v_count) + 1);
575
      end if;
576
--
577
-- Generate Vertical Sync Signal using V_count
578
--
579
      if unsigned(v_count) = VER_SYNC_BEG then
580
        vert_sync <= '0';
581
      elsif unsigned(v_count) = VER_SYNC_END then
582
        vert_sync <= '1';
583
      else
584
        vert_sync <= vert_sync;
585
      end if;
586
 
587
-- Generate Video on Screen Signals for Pixel Data
588
      if unsigned(h_count) = HOR_SCAN_END then
589
        video_on_h <= '1';
590
      elsif unsigned(h_count) = HOR_DISP_END then
591
        video_on_h <= '0';
592
      else
593
        video_on_h <= video_on_h;
594
      end if;
595
 
596
      if unsigned(v_count) = VER_SCAN_END then
597
        video_on_v <= '1';
598
      elsif unsigned(v_count) = VER_DISP_END then
599
        video_on_v <= '0';
600
      else
601
        video_on_v <= video_on_v;
602
      end if;
603
 
604
 
605
      if h_count(9 downto 3) = reg_hcursor(6 downto 0) then
606
        cursor_on_h <= '1';
607
      else
608
        cursor_on_h <= '0';
609
      end if;
610
 
611
      if (v_count(8 downto 4) = reg_vcursor(4 downto 0)) then
612
        cursor_on_v <= '1';
613
      else
614
        cursor_on_v <= '0';
615
      end if;
616
 
617
      -- cursor_on is only active when on selected character
618
      blink_count <= std_logic_vector(unsigned(blink_count) + 1);
619
    end if;
620
 
621
  end process;
622
 
623
  -- video_on is high only when RGB data is displayed
624
  vga_hsync_o <= horiz_sync;
625
  vga_vsync_o <= vert_sync;
626
  video_on1   <= video_on_H and video_on_V;
627
  cursor_on1  <= cursor_on_h and cursor_on_v;
628
 
629
--
630
-- Here to look up character ROM
631
-- This will take one clock cycle
632
-- and should be performed on h_count = "111"
633
--
634
  char_addr(10 downto 4) <= vga_data_out(6 downto 0);
635
  char_addr(3 downto 0)  <= v_count(3 downto 0);
636
 
637
end RTL;

powered by: WebSVN 2.1.0

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