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

Subversion Repositories z80soc

[/] [z80soc/] [trunk/] [V0.7.2/] [DE1/] [vhdl/] [video.vhd.bak] - Blame information for rev 44

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 44 rrred
-- Z80SoC for Altera DE1
2
-- Ronivon Candido Costa
3
--
4
-- 2010 - 02 - 17 Update
5
-- Changed the entity to include signals for the char memory
6
-- The char memory is a dual port ram memory, and now
7
--     the char paterns can be modified by software.
8
--
9
--
10
library IEEE;
11
use  IEEE.STD_LOGIC_1164.all;
12
use  IEEE.STD_LOGIC_ARITH.all;
13
use  IEEE.STD_LOGIC_UNSIGNED.all;
14
 
15
ENTITY video is
16
        PORT(   CLOCK_25                : IN STD_LOGIC;
17
                        VRAM_DATA               : IN STD_LOGIC_VECTOR(7 DOWNTO 0);
18
                        VRAM_ADDR               : OUT STD_LOGIC_VECTOR(13 DOWNTO 0);
19
                        VRAM_CLOCK              : OUT STD_LOGIC;
20
                        VRAM_WREN               : OUT STD_LOGIC;
21
                        CRAM_DATA               : IN STD_LOGIC_VECTOR(7 DOWNTO 0);
22
                        CRAM_ADDR               : OUT STD_LOGIC_VECTOR(10 DOWNTO 0);
23
                        CRAM_WEB                : OUT STD_LOGIC;
24
                        VGA_R,
25
                        VGA_G,
26
                        VGA_B                   : OUT STD_LOGIC_VECTOR(3 DOWNTO 0);
27
                        VGA_HS,
28
                        VGA_VS                  : OUT STD_LOGIC);
29
END video;
30
 
31
ARCHITECTURE A OF video IS
32
 
33
    use work.z80soc_pack.all;
34
 
35
        -- Added for VDU support
36
        constant vid_width                      : std_logic_vector := "001010000"; -- 80 columns
37
        signal Clock_video                      : std_logic;
38
        signal VGA_R_sig                        : std_logic_vector(3 downto 0);
39
        signal VGA_G_sig                        : std_logic_vector(3 downto 0);
40
        signal VGA_B_sig                        : std_logic_vector(3 downto 0);
41
        signal pixel_row_sig            : std_logic_vector(9 downto 0);
42
        signal pixel_column_sig         : std_logic_vector(9 downto 0);
43
        signal pixel_clock_sig          : std_logic;
44
        signal char_addr_sig            : std_logic_vector(7 downto 0);
45
        signal font_row_sig                     : std_logic_vector(2 downto 0);
46
        signal font_col_sig                     : std_logic_vector(2 downto 0);
47
        signal pixel_sig                        : std_logic;
48
        signal video_on_sig                     : std_logic;
49
 
50
        constant sv1                            : integer := 3 + pixelsxchar - 1;
51
        constant sv2                            : integer := 9 + pixelsxchar - 1;
52
        constant cv1                            : integer := 0 + pixelsxchar - 1;
53
        constant cv2                            : integer := 2 + pixelsxchar - 1;
54
        signal fix                                      : integer;
55
 
56
COMPONENT VGA_SYNC
57
        PORT(   clock_25Mhz                                             : IN    STD_LOGIC;
58
                        red, green, blue                                : IN    STD_LOGIC_VECTOR(3 DOWNTO 0);
59
                        red_out, green_out, blue_out    : OUT   STD_LOGIC_VECTOR(3 DOWNTO 0);
60
                        horiz_sync_out, vert_sync_out,
61
                        video_on, pixel_clock                   : OUT   STD_LOGIC;
62
                        pixel_row, pixel_column                 : OUT   STD_LOGIC_VECTOR(9 DOWNTO 0));
63
END COMPONENT;
64
 
65
BEGIN
66
 
67
        VGA_R_sig <= "0000";
68
        VGA_G_sig <= "0000";
69
        VGA_B_sig <= pixel_sig & pixel_sig & pixel_sig & pixel_sig;
70
 
71
        -- Fonts ROM read
72
        -- Picks next letter for a 80 Columns x 30 Lines display
73
        VRAM_WREN <= '1';
74
        VRAM_CLOCK <= pixel_clock_sig;
75
        VRAM_ADDR <= pixel_row_sig(sv2 downto sv1) * conv_std_logic_vector(vid_cols,7) + pixel_column_sig(sv2 downto sv1);
76
 
77
        -- Fonts RAM read
78
        -- Takes the letter, calculates the position in the char memory to get the pixel pattern
79
        -- Plot the pixel in the video
80
        -- Using pixel_row(3 downto 1) has the effect of "shifting" (multiplying by 2)
81
        -- This will plot 2 pixels on video for every pixel defined on char memory
82
        CRAM_WEB <= '1';
83
        CRAM_ADDR <= VRAM_DATA & pixel_row_sig(cv2 downto cv1);
84
        fix <= 1 when pixelsxchar = 2 else 2;
85
        pixel_sig <= CRAM_DATA (CONV_INTEGER(NOT (pixel_column_sig(cv2 downto cv1) - fix)))  when
86
                    ( (pixel_row_sig < (pixelsxchar * 8 * vid_lines)) and (pixel_column_sig < (pixelsxchar * 8 * vid_cols)) ) else
87
                '0';
88
 
89
        vga_sync_inst: VGA_SYNC
90
                port map (
91
                        clock_25Mhz                     => CLOCK_25,
92
                        red                                     => VGA_R_sig,
93
                        green                           => VGA_G_sig,
94
                        blue                            => VGA_B_sig,
95
                        red_out                         => VGA_R,
96
                        green_out                       => VGA_G,
97
                        blue_out                        => VGA_B,
98
                        horiz_sync_out          => VGA_HS,
99
                        vert_sync_out           => VGA_VS,
100
                        video_on                        => video_on_sig,
101
                        pixel_clock                     => pixel_clock_sig,
102
                        pixel_row                       => pixel_row_sig,
103
                        pixel_column            => pixel_column_sig
104
        );
105
 
106
END A;

powered by: WebSVN 2.1.0

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