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

Subversion Repositories yavga

[/] [yavga/] [trunk/] [vhdl/] [s3e_starter_1600k.vhd] - Blame information for rev 2

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

Line No. Rev Author Line
1 2 sandroamt
--------------------------------------------------------------------------------
2
----                                                                        ----
3
---- This file is part of the yaVGA project                                 ----
4
---- http://www.opencores.org/?do=project&who=yavga                         ----
5
----                                                                        ----
6
---- Description                                                            ----
7
---- Implementation of yaVGA IP core                                        ----
8
----                                                                        ----
9
---- To Do:                                                                 ----
10
----                                                                        ----
11
----                                                                        ----
12
---- Author(s):                                                             ----
13
---- Sandro Amato, sdroamt@netscape.net                                     ----
14
----                                                                        ----
15
--------------------------------------------------------------------------------
16
----                                                                        ----
17
---- Copyright (c) 2009, Sandro Amato                                       ----
18
---- All rights reserved.                                                   ----
19
----                                                                        ----
20
---- Redistribution  and  use in  source  and binary forms, with or without ----
21
---- modification,  are  permitted  provided that  the following conditions ----
22
---- are met:                                                               ----
23
----                                                                        ----
24
----     * Redistributions  of  source  code  must  retain the above        ----
25
----       copyright   notice,  this  list  of  conditions  and  the        ----
26
----       following disclaimer.                                            ----
27
----     * Redistributions  in  binary form must reproduce the above        ----
28
----       copyright   notice,  this  list  of  conditions  and  the        ----
29
----       following  disclaimer in  the documentation and/or  other        ----
30
----       materials provided with the distribution.                        ----
31
----     * Neither  the  name  of  SANDRO AMATO nor the names of its        ----
32
----       contributors may be used to  endorse or  promote products        ----
33
----       derived from this software without specific prior written        ----
34
----       permission.                                                      ----
35
----                                                                        ----
36
---- THIS SOFTWARE IS PROVIDED  BY THE COPYRIGHT  HOLDERS AND  CONTRIBUTORS ----
37
---- "AS IS"  AND  ANY EXPRESS OR  IMPLIED  WARRANTIES, INCLUDING,  BUT NOT ----
38
---- LIMITED  TO, THE  IMPLIED  WARRANTIES  OF MERCHANTABILITY  AND FITNESS ----
39
---- FOR  A PARTICULAR  PURPOSE  ARE  DISCLAIMED. IN  NO  EVENT  SHALL  THE ----
40
---- COPYRIGHT  OWNER  OR CONTRIBUTORS  BE LIABLE FOR ANY DIRECT, INDIRECT, ----
41
---- INCIDENTAL,  SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, ----
42
---- BUT  NOT LIMITED  TO,  PROCUREMENT OF  SUBSTITUTE  GOODS  OR SERVICES; ----
43
---- LOSS  OF  USE,  DATA,  OR PROFITS;  OR  BUSINESS INTERRUPTION) HOWEVER ----
44
---- CAUSED  AND  ON  ANY THEORY  OF LIABILITY, WHETHER IN CONTRACT, STRICT ----
45
---- LIABILITY,  OR  TORT  (INCLUDING  NEGLIGENCE  OR OTHERWISE) ARISING IN ----
46
---- ANY  WAY OUT  OF THE  USE  OF  THIS  SOFTWARE,  EVEN IF ADVISED OF THE ----
47
---- POSSIBILITY OF SUCH DAMAGE.                                            ----
48
--------------------------------------------------------------------------------
49
 
50
library IEEE;
51
use IEEE.STD_LOGIC_1164.all;
52
use IEEE.STD_LOGIC_ARITH.all;
53
use IEEE.STD_LOGIC_UNSIGNED.all;
54
 
55
---- Uncomment the following library declaration if instantiating
56
---- any Xilinx primitives in this code.
57
--library UNISIM;
58
--use UNISIM.VComponents.all;
59
 
60
entity s3e_starter_1600k is
61
  port (i_clk    : in  std_logic;
62
         o_hsync : out std_logic;
63
         o_vsync : out std_logic;
64
         o_r     : out std_logic;
65
         o_g     : out std_logic;
66
         o_b     : out std_logic);
67
end s3e_starter_1600k;
68
 
69
architecture Behavioral of s3e_starter_1600k is
70
 
71
  component vga_ctrl
72
    port(
73
      i_clk          : in  std_logic;
74
      i_reset        : in  std_logic;
75
      i_background   : in  std_logic;
76
      i_cursor_color : in  std_logic_vector(2 downto 0);
77
      i_cursor_x     : in  std_logic_vector(10 downto 0);
78
      i_cursor_y     : in  std_logic_vector(9 downto 0);
79
      i_h_sync_en    : in  std_logic;
80
      i_v_sync_en    : in  std_logic;
81
      i_chr_addr     : in  std_logic_vector(10 downto 0);
82
      i_chr_data     : in  std_logic_vector(31 downto 0);
83
      i_chr_clk      : in  std_logic;
84
      i_chr_en       : in  std_logic;
85
      i_chr_we       : in  std_logic_vector(3 downto 0);
86
      i_chr_rst      : in  std_logic;
87
      i_wav_d        : in  std_logic_vector(15 downto 0);
88
      i_wav_we       : in  std_logic;
89
      i_wav_addr     : in  std_logic_vector(9 downto 0);
90
      o_h_sync       : out std_logic;
91
      o_v_sync       : out std_logic;
92
      o_r            : out std_logic;
93
      o_g            : out std_logic;
94
      o_b            : out std_logic;
95
      o_chr_data     : out std_logic_vector(31 downto 0)
96
      );
97
  end component;
98
 
99
  signal s_hsync : std_logic;
100
  signal s_vsync : std_logic;
101
  signal s_r     : std_logic;
102
  signal s_g     : std_logic;
103
  signal s_b     : std_logic;
104
 
105
  signal s_vsync_count : std_logic_vector(7 downto 0) := (others => '0');
106
  signal s_vsync1      : std_logic;
107
 
108
  signal s_chr_addr : std_logic_vector(10 downto 0) := (others => '0');
109
  signal s_rnd      : std_logic_vector(31 downto 0) := (others => '0');
110
  signal s_chr_we   : std_logic_vector(3 downto 0);
111
 
112
  attribute U_SET                      : string;
113
  attribute U_SET of "u1_vga_ctrl"    : label is "u1_vga_ctrl_uset";
114
 
115
begin
116
  o_hsync <= s_hsync;
117
  o_vsync <= s_vsync;
118
  o_r     <= s_r;
119
  o_g     <= s_g;
120
  o_b     <= s_b;
121
 
122
  u1_vga_ctrl : vga_ctrl port map(
123
    i_clk          => i_clk,
124
    i_reset        => '0',
125
    i_background   => '0',
126
    i_cursor_color => "001",
127
    i_cursor_x     => "00101000000",
128
    i_cursor_y     => "0011000000",
129
    o_h_sync       => s_hsync,
130
    o_v_sync       => s_vsync,
131
    i_h_sync_en    => '1',
132
    i_v_sync_en    => '1',
133
    o_r            => s_r,
134
    o_g            => s_g,
135
    o_b            => s_b,
136
    i_chr_addr     => s_chr_addr,       --B"000_0000_0000",
137
    i_chr_data     => s_rnd,            --X"00000000",
138
    o_chr_data     => open,
139
    i_chr_clk      => i_clk,
140
    i_chr_en       => '1',
141
    i_chr_we       => s_chr_we,
142
    i_chr_rst      => '0',
143
    i_wav_d        => X"0000",  --s_rnd(15 downto 0), -- 
144
    i_wav_we       => '0',  --s_chr_we(0), --
145
    i_wav_addr     => B"00_0000_0000"  --s_chr_addr(9 downto 0) --
146
    );
147
 
148
  p_write_chars : process(i_clk)
149
  begin
150
    if rising_edge(i_clk) then
151
      -- during the sync time in order to avoid flickering
152
      -- and each 128 vsync in order to stop for a while
153
      -- will write random chars...
154
      if s_vsync_count(7) = '1' and (s_hsync = '0' or s_vsync = '0') then
155
        -- generate a pseudo random 32 bit number
156
        s_rnd <= s_rnd(30 downto 0) & (s_rnd(31) xnor s_rnd(21) xnor s_rnd(1) xnor s_rnd(0));
157
        -- increment the address and write enable...
158
        s_chr_addr <= s_chr_addr + 1;
159
        s_chr_we   <= "1111";
160
      else
161
        s_chr_addr <= s_chr_addr;
162
        s_chr_we   <= "0000";
163
        s_rnd      <= s_rnd;
164
      end if;
165
    end if;
166
  end process;
167
 
168
--  p_rnd_bit : process(i_clk)
169
--    variable v_rnd_fb : std_logic;
170
--    variable v_rnd : std_logic_vector(31 downto 0);
171
--  begin
172
--    if rising_edge(i_clk) then
173
--      s_rnd_bit <= v_rnd_fb;
174
--      v_rnd_fb := v_rnd(31) xnor v_rnd(21) xnor v_rnd(1) xnor v_rnd(0);
175
--      v_rnd    := v_rnd(30 downto 0) & v_rnd_fb;
176
--    end if;
177
--  end process;
178
 
179
  p_vsync_count : process(i_clk)
180
  begin
181
    if rising_edge(i_clk) then
182
      s_vsync1 <= s_vsync;
183
      if (not s_vsync and s_vsync1) = '1' then  -- pulse on vsync falling
184
        s_vsync_count <= s_vsync_count + 1;
185
      end if;
186
    end if;
187
  end process;
188
 
189
 
190
 
191
end Behavioral;
192
 

powered by: WebSVN 2.1.0

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