OpenCores
URL https://opencores.org/ocsvn/bluespec-h264/bluespec-h264/trunk

Subversion Repositories bluespec-h264

[/] [bluespec-h264/] [trunk/] [src/] [H264Types.bsv] - Blame information for rev 100

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 83 jamey.hick
 
2
// The MIT License
3
 
4
// Copyright (c) 2006-2007 Massachusetts Institute of Technology
5
 
6
// Permission is hereby granted, free of charge, to any person obtaining a copy
7
// of this software and associated documentation files (the "Software"), to deal
8
// in the Software without restriction, including without limitation the rights
9
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
// copies of the Software, and to permit persons to whom the Software is
11
// furnished to do so, subject to the following conditions:
12
 
13
// The above copyright notice and this permission notice shall be included in
14
// all copies or substantial portions of the Software.
15
 
16
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
// THE SOFTWARE.
23
 
24 2 jamey.hick
//**********************************************************************
25
// H264 Types
26
//----------------------------------------------------------------------
27
//
28
//
29
//
30
 
31
 
32
package H264Types;
33
 
34
import Vector::*;
35
import RegFile::*;
36
 
37 19 jamey.hick
typedef 7   PicWidthSz;//number of bits to represent the horizontal position of a MB
38
typedef 7   PicHeightSz;//number of bits to represent the vertical position of a MB
39
typedef 14  PicAreaSz;//number of bits to represent the 2D position of a MB (max 16)
40
Bit#(PicWidthSz) maxPicWidthInMB=127;//(2^PicWidthSz)-1
41 2 jamey.hick
 
42 19 jamey.hick
Bit#(PicAreaSz) maxPicAreaInMB=14'b10000000000000;
43
typedef 25  FrameBufferSz;//number of bits to address the frame buffer (5+PicAreaSz+6)
44
typedef 16  MaxRefFrames;//max number of frames in the frame buffer
45
Bit#(5) maxRefFrames=16;//max number of frames in the frame buffer
46
Bit#(FrameBufferSz) frameBufferSize=25'b0110110000000000000000000;//size of frame buffer ((maxRefFrames+2)*maxPicAreaInMB*1.5*64)
47 2 jamey.hick
 
48
Integer entropyDec_infifo_size = 2;
49
Integer inverseTrans_infifo_size = 8;
50
Integer prediction_infifo_size = 4;
51
Integer prediction_infifo_ITB_size = 16;
52
Integer prediction_predictedfifo_size = 16;
53
Integer interpolator_reqfifoLoad_size = 4;
54
Integer interpolator_reqfifoWork_size = 8;
55
Integer interpolator_memRespQ_size = 4;
56 45 jamey.hick
Integer deblockFilter_infifo_size = 4;
57 2 jamey.hick
Integer bufferControl_infifo_size = 2;
58
 
59
 
60
//-----------------------------------------------------------
61
// 1 read port register file module
62
 
63
interface RFile1#(type idx_t, type d_t);
64
   method Action upd(idx_t x1, d_t x2);
65 19 jamey.hick
   method d_t sub(idx_t x1);
66 2 jamey.hick
endinterface
67
 
68
module mkRFile1#( idx_t lo, idx_t hi ) ( RFile1#(idx_t, d_t) )
69
   provisos (Bits#(idx_t, si),Bits#(d_t, sa));
70
   RegFile#(idx_t,d_t) rf <- mkRegFile(lo,hi);
71
   method Action upd( idx_t index, d_t data );
72
      rf.upd( index, data );
73
   endmethod
74 19 jamey.hick
   method d_t sub( idx_t index );
75 2 jamey.hick
      return rf.sub(index);
76
   endmethod
77
endmodule
78
 
79
module mkRFile1Full( RFile1#(idx_t, d_t) )
80
   provisos (Bits#(idx_t, si),Bits#(d_t, sa),Bounded#(idx_t) );
81
   RegFile#(idx_t,d_t) rf <- mkRegFileFull();
82
   method Action upd( idx_t index, d_t data );
83
      rf.upd( index, data );
84
   endmethod
85 19 jamey.hick
   method d_t sub( idx_t index );
86 2 jamey.hick
      return rf.sub(index);
87
   endmethod
88
endmodule
89
 
90
 
91
//-----------------------------------------------------------
92
// Do not fire module
93
 
94
interface DoNotFire;
95
   method Action doNotFire();
96
endinterface
97
 
98
module mkDoNotFire( DoNotFire );
99
   method Action doNotFire() if(False);
100
      noAction;
101
   endmethod
102
endmodule
103
 
104
 
105
typedef union tagged
106
{
107
 void P_L0_16x16;
108
 void P_L0_L0_16x8;
109
 void P_L0_L0_8x16;
110
 void P_8x8;
111
 void P_8x8ref0;
112
 void I_NxN;
113
 struct{
114
 Bit#(2) intra16x16PredMode;
115
 Bit#(2) codedBlockPatternChroma;
116
 Bit#(1) codedBlockPatternLuma;
117
 }I_16x16;
118
 void I_PCM;
119
 void P_Skip;
120
} MbType deriving(Eq,Bits);
121
 
122
 
123
typedef enum
124
{
125
 Pred_L0,
126
 Intra_4x4,
127
 Intra_16x16,
128
 NA
129
} MbPartPredModeType deriving(Eq,Bits);
130
 
131
 
132
typedef Bit#(64) Buffer;//not sure size
133
typedef Bit#(7) Bufcount;
134
Nat buffersize = 64;//not sure size
135
 
136
 
137
 
138
function MbPartPredModeType mbPartPredMode( MbType mbtype, Bit#(1) mbPartIdx );
139
   if(mbPartIdx == 1)
140
      begin
141
         if(mbtype == P_L0_L0_16x8 || mbtype == P_L0_L0_8x16)
142
            return Pred_L0;
143
         else
144
            return NA;
145
      end
146
   else
147
      begin
148
         if(mbtype==P_L0_16x16 || mbtype==P_L0_L0_16x8 || mbtype==P_L0_L0_8x16 || mbtype==P_Skip)
149
            return Pred_L0;
150
         else if(mbtype == I_NxN)
151
            return Intra_4x4;
152
         else if(mbtype == P_8x8 || mbtype == P_8x8ref0 || mbtype == I_PCM )
153
            return NA;
154
         else
155
            return Intra_16x16;
156
      end
157
endfunction
158
 
159
 
160
function Bit#(3) numMbPart( MbType mbtype );
161
   if(mbtype == P_L0_16x16  || mbtype == P_Skip)
162
      return 1;
163
   else if(mbtype == P_L0_L0_16x8 || mbtype == P_L0_L0_8x16)
164
      return 2;
165
   else if(mbtype == P_8x8 || mbtype == P_8x8ref0)
166
      return 4;
167
   else
168
      return 0;//should never happen
169
endfunction
170
 
171
 
172
function Bit#(3) numSubMbPart( Bit#(2) submbtype );
173
   if(submbtype == 0)
174
      return 1;
175
   else if(submbtype == 1 || submbtype == 2)
176
      return 2;
177
   else
178
      return 4;
179
endfunction
180
 
181
 
182
//----------------------------------------------------------------------
183
// Inter-module FIFO types
184
//----------------------------------------------------------------------
185
 
186
 
187
typedef union tagged
188
{
189
 Bit#(8) DataByte;
190
 void    EndOfFile;
191
}
192
InputGenOT deriving(Eq,Bits);
193
 
194
 
195
typedef union tagged
196
{
197
 void    NewUnit;
198
 Bit#(8) RbspByte;
199
 void    EndOfFile;
200
}
201
NalUnwrapOT deriving(Eq,Bits);
202
 
203
 
204
typedef union tagged
205
{
206
 Bit#(8)  NewUnit;
207
 
208
 ////Sequence Parameter Set
209
 Bit#(5)  SPSseq_parameter_set_id;//ue 0 to 31
210
 Bit#(5)  SPSlog2_max_frame_num;//ue+4 4 to 16
211
 Bit#(2)  SPSpic_order_cnt_type;//ue 0 to 2
212
 Bit#(5)  SPSlog2_max_pic_order_cnt_lsb;//ue+4 4 to 16
213
 Bit#(1)  SPSdelta_pic_order_always_zero_flag;//u(1)
214
 Bit#(32) SPSoffset_for_non_ref_pic;//se -2^31 to 2^31-1
215
 Bit#(32) SPSoffset_for_top_to_bottom_field;//se -2^31 to 2^31-1
216
 Bit#(8)  SPSnum_ref_frames_in_pic_order_cnt_cycle;//ue 0 to 255
217
 Bit#(32) SPSoffset_for_ref_frame;//se -2^31 to 2^31-1
218
 Bit#(5)  SPSnum_ref_frames;//ue 0 to MaxDpbSize (depends on Level)
219
 Bit#(1)  SPSgaps_in_frame_num_allowed_flag;//u(1)
220
 Bit#(PicWidthSz) SPSpic_width_in_mbs;//ue+1 1 to ?
221
 Bit#(PicHeightSz) SPSpic_height_in_map_units;//ue+1 1 to ?
222
//// Bit#(1)  SPSframe_mbs_only_flag//u(1) (=1 for baseline)
223
 Bit#(1)  SPSdirect_8x8_inference_flag;//u(1)
224
 Bit#(1)  SPSframe_cropping_flag;//u(1)
225
 Bit#(16) SPSframe_crop_left_offset;//ue 0 to ?
226
 Bit#(16) SPSframe_crop_right_offset;//ue 0 to ?
227
 Bit#(16) SPSframe_crop_top_offset;//ue 0 to ?
228
 Bit#(16) SPSframe_crop_bottom_offset;//ue 0 to ?
229
 
230
 ////Picture Parameter Set
231
 Bit#(8)  PPSpic_parameter_set_id;//ue 0 to 255
232
 Bit#(5)  PPSseq_parameter_set_id;//ue 0 to 31
233
//// Bit#(1)  PPSentropy_coding_mode_flag//u(1) (=0 for baseline)
234
 Bit#(1)  PPSpic_order_present_flag;//u(1)
235
//// Bit#(4)  PPSnum_slice_groups;//ue+1 1 to 8 (=1 for main)
236
////some info if PPSnum_slice_groups>1 (not in main)
237
 Bit#(5)  PPSnum_ref_idx_l0_active;//ue+1 1 to 32 (16 for frame mb)
238
 Bit#(5)  PPSnum_ref_idx_l1_active;//ue+1 1 to 32 (16 for frame mb)
239
//// Bit#(1)  PPSweighted_pred_flag;//u(1) (=0 for baseline)
240
//// Bit#(2)  PPSweighted_bipred_flag;//u(2) (=0 for baseline)
241
//////// Bit#(7)  PPSpic_init_qp;//se+26 0 to 51
242
//////// Bit#(7)  PPSpic_init_qs;//se+26 0 to 51
243
//////// Bit#(5)  PPSchroma_qp_index_offset;//se -12 to 12
244
 Bit#(1)  PPSdeblocking_filter_control_present_flag;//u(1)
245
 Bit#(1)  PPSconstrained_intra_pred_flag;//u(1)
246
//// Bit#(1)  PPSredundant_pic_cnt_present_flag;//u(1) (=0 for main)
247
 
248
 ////Slice Header
249
 Bit#(PicAreaSz) SHfirst_mb_in_slice;//ue 0 to PicSizeInMbs-1
250
 Bit#(4)  SHslice_type;//ue 0 to 9
251
 Bit#(8)  SHpic_parameter_set_id;//ue 0 to 255
252
 Bit#(16) SHframe_num;//u(log2_max_frame_num)
253
 Bit#(16) SHidr_pic_id;//ue 0 to 65535
254
 Bit#(16) SHpic_order_cnt_lsb;//u(log2_max_pic_order_cnt_lsb)
255
 Bit#(32) SHdelta_pic_order_cnt_bottom;//se -2^31 to 2^31-1
256
 Bit#(32) SHdelta_pic_order_cnt0;//se -2^31 to 2^31-1
257
 Bit#(32) SHdelta_pic_order_cnt1;//se -2^31 to 2^31-1
258
 Bit#(1)  SHnum_ref_idx_active_override_flag;//u(1)
259
 Bit#(5)  SHnum_ref_idx_l0_active;//ue+1 1 to 32 (16 for frame mb)
260
 ////reference picture list reordering
261
 Bit#(1)  SHRref_pic_list_reordering_flag_l0;//u(1)
262
 Bit#(2)  SHRreordering_of_pic_nums_idc;//ue 0 to 3
263
 Bit#(17) SHRabs_diff_pic_num;//ue 1 to MaxPicNum
264
 Bit#(5)  SHRlong_term_pic_num;//ue 0 to ?
265
 ////decoded reference picture marking
266
 Bit#(1)  SHDno_output_of_prior_pics_flag;//u(1)
267
 Bit#(1)  SHDlong_term_reference_flag;//u(1)
268
 Bit#(1)  SHDadaptive_ref_pic_marking_mode_flag;//u(1)
269
 Bit#(3)  SHDmemory_management_control_operation;//ue 0 to 6
270
 Bit#(17) SHDdifference_of_pic_nums;//ue 1 to MaxPicNum
271
 Bit#(5)  SHDlong_term_pic_num;//ue 0 to 32 (16 for frame mb)
272
 Bit#(5)  SHDlong_term_frame_idx;//ue 0 to MaxLongTermFrameIdx
273
 Bit#(5)  SHDmax_long_term_frame_idx_plus1;//ue 0 to num_ref_frames (0 to 16)
274
 ////Slice Header (continued)
275
//////// Bit#(7)  SHslice_qp_delta;//se -51 to 51
276
 Bit#(2)  SHdisable_deblocking_filter_idc;//ue 0 to 2
277
 Bit#(5)  SHslice_alpha_c0_offset;//se*2 -12 to 12
278
 Bit#(5)  SHslice_beta_offset;//se*2 -12 to 12
279
 
280
 ////Slice Data
281
 Bit#(PicAreaSz) SDmb_skip_run;//ue 0 to PicSizeInMbs
282
//// Bit#(PicAreaSz) SDcurrMbAddr;//ue ->process-> 0 to PicSizeInMbs
283
 ////macroblock layer
284
 MbType   SDMmbtype;//ue ->process-> MbType
285
 Bit#(8)  SDMpcm_sample_luma;//ue 0 to 255
286
 Bit#(8)  SDMpcm_sample_chroma;//ue 0 to 255
287
//// Bit#(6)  SDMcoded_block_pattern;//me
288
//////// Bit#(7)  SDMmb_qp_delta;//se -26 to 25
289
 ////macroblock prediction
290
// Bit#(1)  SDMMprev_intra4x4_pred_mode_flag;//u(1)
291
 Bit#(4)  SDMMrem_intra4x4_pred_mode;//(SDMMprev_intra4x4_pred_mode_flag ? 4'b1000 : {1'b0,u(3)})
292
 Bit#(2)  SDMMintra_chroma_pred_mode;//ue 0 to 3
293
 Bit#(5)  SDMMref_idx_l0;//te 0 to num_ref_idx_active_minus1
294
 Bit#(16) SDMMmvd_l0;//se ? to ? (see Annex A)
295
 ////sub-macroblock prediction
296
 Bit#(2)  SDMSsub_mb_type;//ue 0 to 3
297
 Bit#(5)  SDMSref_idx_l0;//te 0 to num_ref_idx_active_minus1
298
 Bit#(16) SDMSmvd_l0;//se ? to ? (see Annex A)
299
 ////residual data
300
//////// Bit#(13) SDMRcoeffLevel;//cavlc output in reverse order (high frequency first)
301
//////// Bit#(5)  SDMRcoeffLevelZeros;//# of consecutive zeros (also used for ITBresidual)
302
 
303
 ////Prediction Block output
304
 struct {Bit#(6) qpy; Bit#(6) qpc;} IBTmb_qp;//qp for luma and chroma for the current MB
305
 struct {Bit#(3) bShor; Bit#(3) bSver;} PBbS;//
306
 Vector#(4,Bit#(8)) PBoutput;//prediction+residual in regular h.264 order
307
 
308
 //// various delimiters
309
 Bit#(3)  AUDPrimaryPicType;
310
 void     EndOfSequence;
311
 void     EndOfStream;
312
 void     EndOfFile;
313
}
314
EntropyDecOT deriving(Eq,Bits);
315
 
316
 
317
typedef union tagged
318
{
319
 Bit#(8)  NewUnit;
320
 
321
 ////Picture Parameter Set
322
 Bit#(8)  PPSpic_parameter_set_id;//ue 0 to 255
323
 Bit#(7)  PPSpic_init_qp;//se+26 0 to 51
324
 Bit#(7)  PPSpic_init_qs;//se+26 0 to 51
325
 Bit#(5)  PPSchroma_qp_index_offset;//se -12 to 12
326
 
327
 ////Slice Header
328
 Bit#(7)  SHslice_qp_delta;//se -51 to 51
329
 
330
 ////macroblock layer
331
 MbType   SDMmbtype;//ue ->process-> MbType
332
 Bit#(7)  SDMmb_qp_delta;//se -26 to 25
333
 ////residual data (cavlc output in reverse order (high frequency first))
334
 struct {Bit#(13) level; Bit#(5) zeros;} SDMRcoeffLevelPlusZeros;//one non-zero coeff level followed by # of consecutive zeros
335
 Bit#(5)  SDMRcoeffLevelZeros;//# of consecutive zeros
336
}
337
EntropyDecOT_InverseTrans deriving(Eq,Bits);
338
 
339
 
340
typedef union tagged
341
{
342
 void ITBcoeffLevelZeros;//16 consecutive zeros
343
 Vector#(4,Bit#(10)) ITBresidual;//residual data in regular h.264 order
344
 struct {Bit#(6) qpy; Bit#(6) qpc;} IBTmb_qp;//qp for luma and chroma for the current MB
345
}
346
InverseTransOT deriving(Eq,Bits);
347
 
348
 
349
typedef union tagged
350
{
351
 struct {Bit#(TAdd#(PicWidthSz,2)) hor; Bit#(TAdd#(PicHeightSz,4)) ver; Bit#(32) data;} DFBLuma;
352
 struct {Bit#(1) uv; Bit#(TAdd#(PicWidthSz,1)) hor; Bit#(TAdd#(PicHeightSz,3)) ver; Bit#(32) data;} DFBChroma;
353
 void EndOfFrame;
354
 EntropyDecOT EDOT;
355
}
356
DeblockFilterOT deriving(Eq,Bits);
357
 
358
 
359
typedef union tagged
360
{
361
 Bit#(32)  YUV;
362
 void      EndOfFile;
363
}
364
BufferControlOT deriving(Eq,Bits);
365
 
366
 
367
typedef union tagged
368
{
369
 Bit#(FrameBufferSz) FBLoadReq;
370
 void FBEndFrameSync;
371
}
372
FrameBufferLoadReq deriving(Eq,Bits);
373
 
374
typedef union tagged
375
{
376
 Bit#(32) FBLoadResp;
377
}
378
FrameBufferLoadResp deriving(Eq,Bits);
379
 
380
typedef union tagged
381
{
382
 struct { Bit#(FrameBufferSz) addr; Bit#(32) data; } FBStoreReq;
383
 void FBEndFrameSync;
384
}
385
FrameBufferStoreReq deriving(Eq,Bits);
386
 
387
 
388
typedef enum
389
{
390
 IP16x16,
391
 IP16x8,
392
 IP8x16,
393
 IP8x8,
394
 IP8x4,
395
 IP4x8,
396
 IP4x4
397
} IPBlockType deriving(Eq,Bits);
398
 
399
typedef union tagged
400
{
401
 struct { Bit#(4) refIdx; Bit#(TAdd#(PicWidthSz,2)) hor; Bit#(TAdd#(PicHeightSz,4)) ver; Bit#(14) mvhor; Bit#(12) mvver; IPBlockType bt; } IPLuma;
402
 struct { Bit#(4) refIdx; Bit#(1) uv; Bit#(TAdd#(PicWidthSz,2)) hor; Bit#(TAdd#(PicHeightSz,3)) ver; Bit#(14) mvhor; Bit#(12) mvver; IPBlockType bt; } IPChroma;
403
}
404
InterpolatorIT deriving(Eq,Bits);
405
 
406
typedef union tagged
407
{
408
 struct { Bit#(4) refIdx; Bit#(1) horOutOfBounds; Bit#(TAdd#(PicWidthSz,2)) hor; Bit#(TAdd#(PicHeightSz,4)) ver; } IPLoadLuma;
409
 struct { Bit#(4) refIdx; Bit#(1) uv; Bit#(1) horOutOfBounds; Bit#(TAdd#(PicWidthSz,1)) hor; Bit#(TAdd#(PicHeightSz,3)) ver; } IPLoadChroma;
410
 void IPLoadEndFrame;
411
}
412
InterpolatorLoadReq deriving(Eq,Bits);
413
 
414
typedef union tagged
415
{
416
 Bit#(32) IPLoadResp;
417
}
418
InterpolatorLoadResp deriving(Eq,Bits);
419
 
420
 
421
typedef union tagged
422
{
423
  Bit#(addrSz) LoadReq;
424
  struct { Bit#(addrSz) addr; Bit#(dataSz) data; } StoreReq;
425
}
426
MemReq#( type addrSz, type dataSz )
427
deriving(Eq,Bits);
428
 
429
typedef union tagged
430
{
431
  Bit#(dataSz) LoadResp;
432
}
433
MemResp#( type dataSz )
434
deriving(Eq,Bits);
435
 
436
 
437
 
438
endpackage

powered by: WebSVN 2.1.0

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