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

Subversion Repositories mpeg2fpga

[/] [mpeg2fpga/] [trunk/] [rtl/] [mpeg2/] [mem_codes.v] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 kdv
/*
2
 * mem_codes.v
3
 *
4
 * Copyright (c) 2007 Koen De Vleeschauwer.
5
 *
6
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
7
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
8
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
9
 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
10
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
11
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
12
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
13
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
14
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
15
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
16
 * SUCH DAMAGE.
17
 */
18
 
19
/*
20
 * Memory controller commands.
21
 */
22
  parameter [1:0]
23
    CMD_NOOP       = 2'b00,  // no operation
24
    CMD_REFRESH    = 2'b01,  // refresh memory
25
    CMD_READ       = 2'b10,  // read 64-bit word
26
    CMD_WRITE      = 2'b11;  // write 64-bit word
27
 
28
  /*
29
   * When submitting a memory request to the memory controller, a 'tag' is added, indicating the memory request source.
30
   * This allows us to route the data read back to the port which originated the request.
31
   *
32
   * Tags used:
33
   *   TAG_CTRL   Request from the memory controller. Used when initializing or refreshing DRAM.
34
   *   TAG_FWD    Request from motion compensation. Read request for forward reference frame.
35
   *   TAG_BWD    Request from motion compensation. Read request for backward reference frame.
36
   *   TAG_RECON  Request from motion compensation. Write request for reconstructed frame.
37
   *   TAG_DISP   Request from chroma resampling. Read request for reconstructed frame.
38
   *   TAG_OSD    Request from register file. Write request for on-screen display.
39
   */
40
 
41
  parameter [2:0]
42
    TAG_CTRL  = 3'd0,
43
    TAG_FWD   = 3'd1,
44
    TAG_BWD   = 3'd2,
45
    TAG_RECON = 3'd3,
46
    TAG_DISP  = 3'd4,
47
    TAG_OSD   = 3'd5,
48
    TAG_VBUF  = 3'd6;
49
 
50
/*
51
 * Frame store layout.
52
 *
53
 * Writing to and reading from the framestore uses 22-bit frame store addresses.
54
 * Each address uniquely identifies an 8-pixel row of luminance or chrominance values in a block.
55
 *
56
 *   chroma_format: (CHROMA420, CHROMA422, or CHROMA444)
57
 *   image width is mb_width macroblocks, height is mb_height macroblocks.
58
 *
59
 *   4:2:0 frame: (CHROMA420)
60
 *        mb_width
61
 *   +---------------+
62
 *   |               |
63
 *   |      Y        | mb_height
64
 *   |               |
65
 *   | mb_width/2    |
66
 *   +-------+-------+
67
 *   |  Cb   |
68
 *   |       | mb_height/2
69
 *   +-------+
70
 *   |  Cr   |
71
 *   |       | mb_height/2
72
 *   +-------+
73
 *
74
 *   Macroblocks in memory.
75
 *   Each number represents a block row.
76
 *   A block row is a 64-bit word, consisting of 8 8-bit luminance or chrominance values of 8 consecutive pixels.
77
 *
78
 *   +MB 0 ------------+MB 1 ------------+MB 2 -----------
79
 *   |      0      1   |      0      1   |      0      1
80
 *   |      2      3   |      2      3   |      2      3
81
 *   |      4      5   |      4      5   |      4      5
82
 *   |      6      7   |      6      7   |      6      7
83
 *   |      8      9   |      8      9   |      8      9
84
 *   |     10     11   |     10     11   |     10     11
85
 *   |     12     13   |     12     13   |     12     13
86
 *   |     14     15   |     14     15   |     14     15
87
 *   |     16     17   |     16     17   |     16     17
88
 *   |     18     19   |     18     19   |     18     19
89
 *   |     20     21   |     20     21   |     20     21
90
 *   |     22     23   |     22     23   |     22     23
91
 *   |     24     25   |     24     25   |     24     25
92
 *   |     26     27   |     26     27   |     26     27
93
 *   |     28     29   |     28     29   |     28     29
94
 *   |     30     31   |     30     31   |     30     31
95
 *   +MB mb_width -----+MB mb_width+1 ---+MB mb_width+2 --
96
 *   |      0      1   |      0      1   |      0      1
97
 *   |      2      3   |      2      3   |      2      3
98
 *   |      4      5   |      4      5   |      4      5
99
 *   |      6      7   |      6      7   |      6      7
100
 *   |      8      9   |      8      9   |      8      9
101
 *   |     10     11   |     10     11   |     10     11
102
 *   |     12     13   |     12     13   |     12     13
103
 *   |     14     15   |     14     15   |     14     15
104
 *   |     16     17   |     16     17   |     16     17
105
 *   |     18     19   |     18     19   |     18     19
106
 *   |     20     21   |     20     21   |     20     21
107
 *   |     22     23   |     22     23   |     22     23
108
 *   |     24     25   |     24     25   |     24     25
109
 *   |     26     27   |     26     27   |     26     27
110
 *   |     28     29   |     28     29   |     28     29
111
 *   |     30     31   |     30     31   |     30     31
112
 *   +MB 2*mb_width ---+MB 2*mb_width+1 -+MB 2*mb_width+2 -
113
 *   |      0      1   |      0      1   |      0      1
114
 *   |      2      3   |      2      3   |      2      3
115
 *   |      4      5   |      4      5   |      4      5
116
 *   |      6      7   |      6      7   |      6      7
117
 *   |      8      9   |      8      9   |      8      9
118
 *   |     10     11   |     10     11   |     10     11
119
 *   |     12     13   |     12     13   |     12     13
120
 *   |     14     15   |     14     15   |     14     15
121
 *   |     16     17   |     16     17   |     16     17
122
 *   |     18     19   |     18     19   |     18     19
123
 *   |     20     21   |     20     21   |     20     21
124
 *   |     22     23   |     22     23   |     22     23
125
 *   |     24     25   |     24     25   |     24     25
126
 *   |     26     27   |     26     27   |     26     27
127
 *   |     28     29   |     28     29   |     28     29
128
 *   |     30     31   |     30     31   |     30     31
129
 *
130
 *   Blocks within a macroblock.
131
 *   Each digit represents an 8-bit luminance or chrominance value.
132
 *
133
 *   +block0--+block1--+
134
 *   |01234567|01234567|
135
 *   |01234567|01234567|
136
 *   |01234567|01234567|
137
 *   |01234567|01234567|
138
 *   |01234567|01234567|
139
 *   |01234567|01234567|
140
 *   |01234567|01234567|
141
 *   |01234567|01234567|
142
 *   +block2--+block3--+
143
 *   |01234567|01234567|
144
 *   |01234567|01234567|
145
 *   |01234567|01234567|
146
 *   |01234567|01234567|
147
 *   |01234567|01234567|
148
 *   |01234567|01234567|
149
 *   |01234567|01234567|
150
 *   |01234567|01234567|
151
 *   +--------+--------+
152
 *
153
 *   Rows within a block.
154
 *
155
 *   +block0--+
156
 *   |01234567| row 0
157
 *   |01234567| row 1
158
 *   |01234567| row 2
159
 *   |01234567| row 3
160
 *   |01234567| row 4
161
 *   |01234567| row 5
162
 *   |01234567| row 6
163
 *   |01234567| row 7
164
 *   +--------+
165
 *
166
 * To calculate a block row's address in memory, use memory_address().
167
 *
168
 */
169
 
170
  parameter [1:0]
171
    COMP_Y       = 2'b00,  // Y operation
172
    COMP_CR      = 2'b01,  // Cr
173
    COMP_CB      = 2'b10;  // Cb
174
 
175
// Uncomment next line for HDTV memory mapping
176
`define MP_AT_HL 1
177
`ifdef MP_AT_HL
178
/*
179
 * Memory mapping.
180
 *
181
 * This memory mapping is sufficient for up to MP@HL, 1920x1088 pixels, 4:2:0. Requires 15 mbyte ram.
182
 * Consists of four frames, on-screen display and video buffer.
183
 * Note that as the vbuf_wr_addr and vbuf_rd_addr counters are 18 bit, VBUF needs to end in 18 zeroes binary. eg. VBUF = 22'h1c0000 is ok, 22'h1d0000 isn't.
184
 *
185
 */
186
 
187
  parameter [21:0]
188
    WIDTH_Y         = 22'd18,     // Luminance size = 2 ** WIDTH_Y. 2 mbyte of 8-byte words.
189
    WIDTH_C         = 22'd16,     // Chrominance size = 2 ** WIDTH_C. 512 kbyte of 8-byte words.
190
    VBUF            = 22'h1c0000, // Table E-23: MP@HL: vbv buffer size is 9781248 bits.
191
    VBUF_END        = 22'h1efffe,
192
    ADDR_ERR        = 22'h1effff; // Error address; used to signal overflow. (eg. macroblock address too large, or motion vector outside frame). Points to somewhere harmless.
193
 
194
`else
195
 
196
/*
197
 * Memory mapping.
198
 *
199
 * This memory mapping is sufficient for up to MP@ML, up to 768x576 pixels SDTV, 4:2:0. Requires 4 mbyte ram.
200
 * Consists of four frames, on-screen display and video buffer.
201
 */
202
 
203
  parameter [21:0]
204
    WIDTH_Y         = 22'd16,     // Luminance size = 2 ** WIDTH_Y. 512 kbyte of 8-byte words
205
    WIDTH_C         = 22'd14,     // Chrominance size = 2 ** WIDTH_C. 128 kbyte of 8-byte words
206
    VBUF            = 22'h070000, // Table E-23: MP@ML: vbv buffer size is 1835008 bits.
207
    VBUF_END        = 22'h077ffe,
208
    ADDR_ERR        = 22'h077fff; // Error address; used to signal overflow. (eg. macroblock address too large, or motion vector outside frame). Points to somewhere harmless.
209
 
210
`endif
211
 
212
  parameter [21:0]
213
    FRAME_0_Y       = 22'h000000,
214
    FRAME_0_CR      =                                           (22'h1 << WIDTH_Y),
215
    FRAME_0_CB      =                                           (22'h1 << WIDTH_Y) + (22'h1 << WIDTH_C),
216
    FRAME_1_Y       = (22'h1 << WIDTH_Y) + (22'h2 << WIDTH_C),
217
    FRAME_1_CR      = (22'h1 << WIDTH_Y) + (22'h2 << WIDTH_C) + (22'h1 << WIDTH_Y),
218
    FRAME_1_CB      = (22'h1 << WIDTH_Y) + (22'h2 << WIDTH_C) + (22'h1 << WIDTH_Y) + (22'h1 << WIDTH_C),
219
    FRAME_2_Y       = (22'h2 << WIDTH_Y) + (22'h4 << WIDTH_C),
220
    FRAME_2_CR      = (22'h2 << WIDTH_Y) + (22'h4 << WIDTH_C) + (22'h1 << WIDTH_Y),
221
    FRAME_2_CB      = (22'h2 << WIDTH_Y) + (22'h4 << WIDTH_C) + (22'h1 << WIDTH_Y) + (22'h1 << WIDTH_C),
222
    FRAME_3_Y       = (22'h3 << WIDTH_Y) + (22'h6 << WIDTH_C),
223
    FRAME_3_CR      = (22'h3 << WIDTH_Y) + (22'h6 << WIDTH_C) + (22'h1 << WIDTH_Y),
224
    FRAME_3_CB      = (22'h3 << WIDTH_Y) + (22'h6 << WIDTH_C) + (22'h1 << WIDTH_Y) + (22'h1 << WIDTH_C),
225
    OSD             = (22'h4 << WIDTH_Y) + (22'h8 << WIDTH_C);
226
 
227
  parameter [2:0]
228
    OSD_FRAME       = 3'd4;
229
 
230
  parameter [21:0]
231
    END_OF_MEM      = ADDR_ERR;   // End of memory.
232
 
233
/* not truncated */

powered by: WebSVN 2.1.0

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