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

Subversion Repositories yavga

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

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

powered by: WebSVN 2.1.0

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