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

Subversion Repositories yavga

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

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_h_sync_en    : in  std_logic;
76
      i_v_sync_en    : in  std_logic;
77
      i_chr_addr     : in  std_logic_vector(10 downto 0);
78
      i_chr_data     : in  std_logic_vector(31 downto 0);
79
      i_chr_clk      : in  std_logic;
80
      i_chr_en       : in  std_logic;
81
      i_chr_we       : in  std_logic_vector(3 downto 0);
82
      i_chr_rst      : in  std_logic;
83
      i_wav_d        : in  std_logic_vector(15 downto 0);
84 23 sandroamt
      i_wav_clk      : in  std_logic;
85 2 sandroamt
      i_wav_we       : in  std_logic;
86
      i_wav_addr     : in  std_logic_vector(9 downto 0);
87
      o_h_sync       : out std_logic;
88
      o_v_sync       : out std_logic;
89
      o_r            : out std_logic;
90
      o_g            : out std_logic;
91
      o_b            : out std_logic;
92
      o_chr_data     : out std_logic_vector(31 downto 0)
93
      );
94
  end component;
95
 
96
  signal s_hsync : std_logic;
97
  signal s_vsync : std_logic;
98
  signal s_r     : std_logic;
99
  signal s_g     : std_logic;
100
  signal s_b     : std_logic;
101
 
102
  signal s_vsync_count : std_logic_vector(7 downto 0) := (others => '0');
103
  signal s_vsync1      : std_logic;
104
 
105 23 sandroamt
  signal s_chr_addr : std_logic_vector(10 downto 0);-- := (others => '0');
106
  signal s_chr_data : std_logic_vector(31 downto 0);-- := (others => '0');
107
  signal s_rnd      : std_logic_vector(31 downto 0);-- := (others => '0');
108 2 sandroamt
  signal s_chr_we   : std_logic_vector(3 downto 0);
109
 
110 23 sandroamt
  signal s_wav_addr : std_logic_vector(9 downto 0);
111
  signal s_wav_d : std_logic_vector(15 downto 0);
112
  signal s_mul : std_logic_vector(7 downto 0);
113
 
114
  signal s_initialized : std_logic := '0';
115
 
116 2 sandroamt
  attribute U_SET                      : string;
117
  attribute U_SET of "u1_vga_ctrl"    : label is "u1_vga_ctrl_uset";
118
 
119
begin
120
  o_hsync <= s_hsync;
121
  o_vsync <= s_vsync;
122
  o_r     <= s_r;
123
  o_g     <= s_g;
124
  o_b     <= s_b;
125
 
126
  u1_vga_ctrl : vga_ctrl port map(
127
    i_clk          => i_clk,
128
    i_reset        => '0',
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 23 sandroamt
    i_chr_data     => s_chr_data,            --X"00000000",
138 2 sandroamt
    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 23 sandroamt
    i_wav_d        => s_wav_d, --X"0000",  --s_rnd(15 downto 0), --
144
    i_wav_clk      => i_clk,
145
    i_wav_we       => '0', --'0',  -- '1',
146
    i_wav_addr     => s_wav_addr --B"00_0000_0000"  --s_chr_addr(9 downto 0) --
147 2 sandroamt
    );
148 23 sandroamt
         s_wav_addr <= s_rnd(1 downto 0) & s_vsync_count;
149
         s_mul <= s_vsync_count(3 downto 0) * s_vsync_count(3 downto 0);
150
         s_wav_d <= B"000" & s_rnd(2 downto 0) & B"00" & s_mul;
151
         --s_wav_d <= B"000" & "100" & B"00" & s_mul;
152 2 sandroamt
 
153 23 sandroamt
--  s_chr_data <= s_rnd;
154
--  p_write_chars : process(i_clk)
155
--  begin
156
--    if rising_edge(i_clk) then
157
--      -- during the sync time in order to avoid flickering
158
--      -- and each 128 vsync in order to stop for a while
159
--      -- will write random chars...
160
--      if s_vsync_count(7) = '1' and (s_hsync = '0' or s_vsync = '0') then
161
--        -- generate a pseudo random 32 bit number
162
--        s_rnd <= s_rnd(30 downto 0) & (s_rnd(31) xnor s_rnd(21) xnor s_rnd(1) xnor s_rnd(0));
163
--        -- increment the address and write enable...
164
--        s_chr_addr <= s_chr_addr + 1;
165
--        s_chr_we   <= "1111";
166
--      else
167
--        s_chr_addr <= s_chr_addr;
168
--        s_chr_we   <= "0000";
169
--        s_rnd      <= s_rnd;
170
--      end if;
171
--    end if;
172
--  end process;
173
 
174
--              cols              cols
175
--           00_01_02_03  ...  96_97_98_99
176
--   row_00 "00000000000" ... "00000011000"
177
--   row_01 "00000100000" ... "00000111000"
178
--    ...        ...               ...
179
--   row_37 "10010100000" ... "10010111000"
180 2 sandroamt
  p_write_chars : process(i_clk)
181
  begin
182
    if rising_edge(i_clk) then
183 23 sandroamt
      if s_initialized = '0' then
184
        case s_vsync_count(2 downto 0) is
185
          when "000" => -- write ABCD
186
            s_chr_we   <= "1111";
187
            s_chr_addr <= "00000000000";
188
            s_chr_data <= "01000001" & "01000010" & "01000011" & "01000100";
189
          when "001" => -- write EFGH
190
            s_chr_we   <= "1111";
191
            s_chr_addr <= "00000011000";
192
            s_chr_data <= "01000101" & "01000110" & "01000111" & "01001000";
193
          when "010" => -- write IJKL
194
            s_chr_we   <= "1111";
195
            s_chr_addr <= "00000100000";
196
            s_chr_data <= "01001001" & "01001010" & "01001011" & "01001100";
197
          when "011" => -- write MNOP
198
            s_chr_we   <= "1111";
199
            s_chr_addr <= "10010100000";
200
            s_chr_data <= "01001101" & "01001110" & "01001111" & "01010000";
201
          when "100" => -- write QRST
202
            s_chr_we   <= "1111";
203
            s_chr_addr <= "10010111000";
204
            s_chr_data <= "01010001" & "01010010" & "01010011" & "01010100";
205
          when "101" => -- write config grid and cursor color
206
            s_chr_we   <= "1111";
207
            s_chr_addr <= "00000011011"; -- 108 >> 2
208
            --             ND   bgColor grid,cur   ND       curs_x          curs_y
209
            s_chr_data <= "00" & "000" & "101" & "000" & "00111000010" & "0101011110";
210
            --            |--------108-------|-------109-------|----110-----|--111--|
211
            s_initialized <= '1';
212
          when others =>
213
            s_chr_we   <= (others => '0');
214
            s_chr_addr <= (others => '1');
215
            s_chr_data <= "11111111" & "11111101" & "11111100" & "11111110";
216
        end case;
217 2 sandroamt
      else
218 23 sandroamt
        s_chr_we   <= (others => '0');
219 2 sandroamt
      end if;
220
    end if;
221
  end process;
222 23 sandroamt
 
223 2 sandroamt
--  p_rnd_bit : process(i_clk)
224
--    variable v_rnd_fb : std_logic;
225
--    variable v_rnd : std_logic_vector(31 downto 0);
226
--  begin
227
--    if rising_edge(i_clk) then
228
--      s_rnd_bit <= v_rnd_fb;
229
--      v_rnd_fb := v_rnd(31) xnor v_rnd(21) xnor v_rnd(1) xnor v_rnd(0);
230
--      v_rnd    := v_rnd(30 downto 0) & v_rnd_fb;
231
--    end if;
232
--  end process;
233
 
234
  p_vsync_count : process(i_clk)
235
  begin
236
    if rising_edge(i_clk) then
237
      s_vsync1 <= s_vsync;
238
      if (not s_vsync and s_vsync1) = '1' then  -- pulse on vsync falling
239
        s_vsync_count <= s_vsync_count + 1;
240
      end if;
241
    end if;
242
  end process;
243
 
244
 
245
 
246
end Behavioral;
247
 

powered by: WebSVN 2.1.0

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