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

Subversion Repositories bluespec-h264

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

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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