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 19

Go to most recent revision | Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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