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

Subversion Repositories lq057q3dc02

[/] [lq057q3dc02/] [trunk/] [design/] [image_gen_bram.vhd] - Blame information for rev 47

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 jwdonal
------------------------------------------------------------------------------
2
-- Copyright (C) 2007 Jonathon W. Donaldson
3
--                    jwdonal a t opencores DOT org
4
--
5
--  This program is free software; you can redistribute it and/or modify
6
--  it under the terms of the GNU General Public License as published by
7
--  the Free Software Foundation; either version 2 of the License, or
8
--  (at your option) any later version.
9
--
10
--  This program is distributed in the hope that it will be useful,
11
--  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
--  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
--  GNU General Public License for more details.
14
--
15
--  You should have received a copy of the GNU General Public License
16
--  along with this program; if not, write to the Free Software
17
--  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18
--
19
------------------------------------------------------------------------------
20
--
21 38 jwdonal
-- $Id: image_gen_bram.vhd,v 1.2 2008-11-07 04:54:32 jwdonal Exp $
22 30 jwdonal
--
23
-- Description: This file controls the BRAM components for each color.
24
--
25
-- Structure:
26
--   - xupv2p.ucf
27
--   - components.vhd
28
--   - lq057q3dc02_tb.vhd
29
--   - lq057q3dc02.vhd
30
--     - dcm_sys_to_lcd.xaw
31
--     - video_controller.vhd
32
--       - enab_control.vhd
33
--       - hsyncx_control.vhd
34
--       - vsyncx_control.vhd
35
--       - clk_lcd_cyc_cntr.vhd
36
--     - image_gen_bram.vhd
37
--       - image_gen_bram_red.xco
38
--       - image_gen_bram_green.xco
39
--       - image_gen_bram_blue.xco
40
--
41
------------------------------------------------------------------------------
42
--
43
-- Naming Conventions:
44
--   active low signals                                       "*x"
45
--   clock signal                                             "CLK_*"
46
--   reset signal                                             "RST"
47
--   generic/constant                                         "C_*"
48
--   user defined type                                        "TYPE_*"
49
--   state machine next state                                 "*_ns"
50
--   state machine current state                              "*_cs""
51
--   pipelined signals                                        "*_d#"
52
--   register delay signals                                   "*_p#"
53
--   signal                                                   "*_sig"
54
--   variable                                                 "*_var"
55
--   storage register                                         "*_reg"
56
--   clock enable signals                                     "*_ce"
57
--   internal version of output port used as connecting wire  "*_wire"
58
--   input/output port                                        "ALL_CAPS"
59
--   process                                                  "*_PROC"
60
--
61
------------------------------------------------------------------------------
62
 
63
--////////////////////--
64
-- LIBRARY INCLUSIONS --
65
--////////////////////--
66
LIBRARY IEEE;
67
USE IEEE.STD_LOGIC_1164.ALL;
68
USE IEEE.STD_LOGIC_ARITH.ALL;
69
USE IEEE.STD_LOGIC_UNSIGNED.ALL;
70
USE work.components.ALL;
71
 
72
--////////////////////--
73
-- ENTITY DECLARATION --
74
--////////////////////--
75
ENTITY image_gen_bram IS
76
 
77
  generic (
78
    C_BIT_DEPTH,
79
 
80
    C_VSYNC_TVS,
81
    C_LINE_NUM_WIDTH,
82
 
83
    C_CLK_LCD_CYC_NUM_WIDTH,
84
 
85
    C_ENAB_TEP,
86
    C_ENAB_THE,
87
 
88
    C_BRAM_ADDR_WIDTH,
89
    C_IMAGE_WIDTH,
90
    C_IMAGE_HEIGHT : POSITIVE
91
 
92
  );
93
 
94
  port(
95
    RSTx,
96
    CLK_LCD : IN std_logic;
97
 
98
    LINE_NUM : IN std_logic_vector(C_LINE_NUM_WIDTH-1 downto 0);
99
 
100
    CLK_LCD_CYC_NUM : IN std_logic_vector(C_CLK_LCD_CYC_NUM_WIDTH-1 downto 0);
101
 
102
    R,
103
    G,
104
    B : OUT std_logic_vector(C_BIT_DEPTH/3-1 downto 0)
105
  );
106
 
107
END ENTITY image_gen_bram;
108
 
109
--////////////////////////--
110
-- ARCHITECTURE OF ENTITY --
111
--////////////////////////--
112
ARCHITECTURE image_gen_bram_arch OF image_gen_bram IS
113
 
114
   constant C_NUM_LCD_PIXELS : positive := 320;  -- number of drawable pixels per line in the LCD
115
 
116
   --Connecting signal wires between components
117
   signal SINIT_wire : std_logic := '0';
118
   signal ADDR_wire  : std_logic_vector(C_BRAM_ADDR_WIDTH-1 downto 0) := (others => '0');
119
 
120
begin
121
 
122
  --//////////////////////////--
123
  -- COMPONENT INSTANTIATIONS --
124
  --//////////////////////////--
125
  --You can't simply instantiate one XCO BRAM component 3 times because all
126
  --three components are initialized with 3 different COE files!
127
  image_RED_data : image_gen_bram_red
128
  port map (
129 38 jwdonal
    clka => CLK_LCD,
130
    addra => ADDR_wire,
131 30 jwdonal
 
132
    -- OUTPUTS --
133 38 jwdonal
    douta => R
134 30 jwdonal
  );
135
 
136
  image_GREEN_data : image_gen_bram_green
137
  port map (
138 38 jwdonal
    clka => CLK_LCD,
139
    addra => ADDR_wire,
140 30 jwdonal
 
141
    -- OUTPUTS --
142 38 jwdonal
    douta => G
143 30 jwdonal
  );
144
 
145
  image_BLUE_data : image_gen_bram_blue
146
  port map (
147 38 jwdonal
    clka => CLK_LCD,
148
    addra => ADDR_wire,
149 30 jwdonal
 
150
    -- OUTPUTS --
151 38 jwdonal
    douta => B
152 30 jwdonal
  );
153
 
154
 
155
  ------------------------------------------------------------------
156
  --  Process Description:
157
  --    This process controls the BRAM's SINIT signal which sets the
158
  --    DOUT pins of the BRAM to the value defined at the time of
159
  --    the Xilinx core customization.  The SINIT signal is enabled
160
  --    b/w every line and b/w every new frame.  This value is recommended
161
  --    to be zero to conserver power but it doesn't really matter what
162 38 jwdonal
  --    it is.  In this design it is not connected but feel free to connect
163
  --    it up yourself - everything should work exactly the same.
164 30 jwdonal
  --  
165
  --  Inputs:
166
  --    RSTx
167
  --    CLK_LCD
168
  --  
169
  --  Outputs:
170
  --    SINIT_wire
171
  --
172
  --  Notes:
173
  --    N/A
174
  ------------------------------------------------------------------
175
  image_gen_bram_sinit_cntrl_PROC : process( RSTx, CLK_LCD )
176
  begin
177
 
178
    if( RSTx = '0' ) then
179
 
180
      SINIT_wire <= '0';
181
 
182
    elsif( CLK_LCD'event and CLK_LCD = '1' ) then
183
 
184
      if( CLK_LCD_CYC_NUM >= (C_ENAB_THE - 2) -- start of image... Change from -1 to -2 to enable one clock earlier
185
          and
186
          CLK_LCD_CYC_NUM < (C_IMAGE_WIDTH - 1 + C_ENAB_THE - 1)
187
          and
188
          LINE_NUM < (C_IMAGE_HEIGHT + C_VSYNC_TVS + 1) ) then
189
 
190
        SINIT_wire <= '1'; --allow output to change based on ADDR
191
 
192
      else
193
 
194
        SINIT_wire <= '0';--reset output pins back to user-defined initial value (should be 0h to conserve power)
195
 
196
      end if;
197
 
198
    end if;
199
 
200
  end process image_gen_bram_sinit_cntrl_PROC;
201
 
202
 
203
  ------------------------------------------------------------------
204
  --  Process Description:
205
  --    This process controls the address value input to the BRAMs.
206
  --  
207
  --  Inputs:
208
  --    RSTx
209
  --    CLK_LCD
210
  --  
211
  --  Outputs:
212
  --    ADDR_wire
213
  --
214
  --  Notes:
215
  --    This process causes the Xilinx BRAM IP cores (instantiated
216
  --    above for each color) to generate warnings saying "Memory
217
  --    address is out of range" during simulation.  This is only
218
  --    because ADDR_wire is 76800 for a few clocks after it finishes
219
  --    drawing the last pixel on the screen.  The allowable range
220
  --    is only 0 - 76799, but driving 76800 doesn't cause any issues.
221
  --    I could fix it, but I'm too lazy.  :-)
222
  ------------------------------------------------------------------
223
  image_gen_bram_addr_cntrl_PROC : process( RSTx, CLK_LCD )
224
  begin
225
 
226
    if( RSTx = '0' ) then
227
 
228
      ADDR_wire <= (others => '0');
229
 
230
    elsif( CLK_LCD'event and CLK_LCD = '1' ) then
231
 
232
      --this condition signifies the start and end of each line
233
      if( CLK_LCD_CYC_NUM >= (C_ENAB_THE - 1)
234
          and
235
          CLK_LCD_CYC_NUM < (C_IMAGE_WIDTH + C_ENAB_THE - 1)
236
          and
237
          LINE_NUM < (C_IMAGE_HEIGHT + C_VSYNC_TVS + 1) ) then
238
 
239
        ADDR_wire <= ADDR_wire + 1;
240
 
241
      --reset address back to zero once a complete image has been drawn
242
      --(+ TVS timespec of course).  We only have to do this in case the
243
      --number of addressable image data bytes is less than
244
      --2^#BRAM_ADDR_bits (i.e. the number of addressable BRAM bytes).
245
      --This is almost always likely to be the case since the chances of
246
      --Xilinx automatically generating a BRAM block the _exact_ same size
247
      --as your image is highly unlikey.  This conditional statement will work
248
      --in either case.  :-)
249
      elsif( LINE_NUM >= (C_IMAGE_HEIGHT + C_VSYNC_TVS + 1) ) then
250
 
251
        ADDR_wire <= (others => '0');
252
 
253
      --if data should not be sent then just wait for the next line before
254
      --incrementing the address again
255
      else
256
 
257
        ADDR_wire <= ADDR_wire;
258
 
259
      end if; --end data OK TO SEND check
260
 
261
    end if; --end CLK'event and CLK = '1'
262
 
263
  end process image_gen_bram_addr_cntrl_PROC;
264
 
265
 
266
END ARCHITECTURE image_gen_bram_arch;

powered by: WebSVN 2.1.0

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