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

Subversion Repositories bluespec-h264

[/] [bluespec-h264/] [trunk/] [src/] [DeblockTee.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 21 jamey.hick
import GetPut::*;
25
import H264Types::*;
26 38 jamey.hick
import RegFile::*;
27 21 jamey.hick
 
28 38 jamey.hick
typedef enum
29
{
30
  Forwarding,
31
  DumpingY,
32
  DumpingU,
33
  DumpingV
34
}
35
  State deriving (Bits, Eq);
36 21 jamey.hick
 
37 38 jamey.hick
module mkDeblockTee#(Get#(DeblockFilterOT) inputData, Put#(DeblockFilterOT) outputData, String prefix, Bool recordFrames) ();
38 21 jamey.hick
 
39 24 jamey.hick
 Reg#(Bit#(32)) cycles <- mkReg(0);
40 38 jamey.hick
 Reg#(State) state <- mkReg(Forwarding);
41
 Reg#(Bit#(32)) horCounter;
42
 Reg#(Bit#(32)) verCounter;
43
 Reg#(Bit#(32)) counter;
44
 Reg#(Bit#(PicWidthSz))  picWidth;
45
 Reg#(Bit#(PicHeightSz)) picHeight;
46
 Reg#(Bit#(PicAreaSz))   frameinmb;
47
 RegFile#(Bit#(TAdd#(PicAreaSz,6)), Bit#(32)) yValues;
48
 RegFile#(Bit#(TAdd#(PicAreaSz,4)), Bit#(32)) uValues;
49
 RegFile#(Bit#(TAdd#(PicAreaSz,4)), Bit#(32)) vValues;
50
 
51
 if(recordFrames)
52
   begin
53
     counter <- mkReg(0);
54
     horCounter <- mkReg(0);
55
     verCounter <- mkReg(0);
56
     picWidth  <- mkReg(maxPicWidthInMB);
57
     picHeight <- mkReg(0);
58
     frameinmb <- mkReg(0);
59
     yValues <- mkRegFileFull();
60
     uValues <- mkRegFileFull();
61
     vValues <- mkRegFileFull();
62
   end
63 24 jamey.hick
 
64 38 jamey.hick
 
65 24 jamey.hick
 rule cycleup;
66
   cycles <= cycles + 1;
67
 endrule
68
 
69 38 jamey.hick
 rule processData(state == Forwarding);
70 21 jamey.hick
   let dataIn <- inputData.get();
71
   outputData.put(dataIn);
72
   $write(prefix);
73
   case (dataIn) matches
74 38 jamey.hick
     tagged DFBLuma .data:
75
       begin
76
         $display("DFBLuma(%d): hor: %d ver:%d data:%h\n", cycles,data.hor, data.ver, data.data);
77
         if(recordFrames)
78
           begin
79
             Bit#(TAdd#(PicAreaSz,6)) addr = {(zeroExtend(data.ver)*zeroExtend(picWidth)),2'b00}+zeroExtend(data.hor);
80
             $write(prefix);
81
             $display("Writing to %d, %h", addr, data);
82
             yValues.upd(addr,{data.data[7:0],data.data[15:8],data.data[23:16],data.data[31:24]});
83
           end
84
       end
85
     tagged DFBChroma .data:
86
       begin
87
         $display("DFBChroma(%d): flag: %d hor: %d ver:%d data:%h\n", cycles, data.uv, data.hor, data.ver, data.data);
88
         if(recordFrames)
89
           begin
90
             Bit#(TAdd#(PicAreaSz,4)) addr = {(zeroExtend(data.ver)*zeroExtend(picWidth)),1'b0}+zeroExtend(data.hor);
91
             if(data.uv == 1)
92
               begin
93
                 $write(prefix);
94
                 $display("Writing to %d, %h", addr, data);
95
                 vValues.upd(addr, {data.data[7:0],data.data[15:8],data.data[23:16],data.data[31:24]});
96
               end
97
             else
98
               begin
99
                 $write(prefix);
100
                 $display("Writing to %d, %h", addr, data);
101
                 uValues.upd(addr, {data.data[7:0],data.data[15:8],data.data[23:16],data.data[31:24]});
102
               end
103
           end
104
       end
105
     tagged EndOfFrame:
106
       begin
107
         if(recordFrames)
108
           begin
109
             state <= DumpingY;
110
             counter <= 0;
111
           end
112
           $display("EndOfFrame(%d)", cycles);
113
       end
114
     tagged EDOT .data:
115
       case (data) matches
116
         tagged SPSpic_width_in_mbs .xdata :
117
           begin
118
             if(recordFrames)
119
               begin
120
                 picWidth <= xdata;
121
               end
122
           end
123
         tagged SPSpic_height_in_map_units .xdata :
124
           begin
125
             if(recordFrames)
126
               begin
127
                 picHeight <= xdata;
128
                 frameinmb <= zeroExtend(picWidth)*zeroExtend(xdata);
129
               end
130
           end
131
       endcase
132 21 jamey.hick
   endcase
133
 endrule
134 38 jamey.hick
 
135
if(recordFrames)
136
 begin
137
   rule dumpY(state == DumpingY);
138
     Bit#(TAdd#(PicAreaSz,6)) addr = truncate({(verCounter*zeroExtend(picWidth)),2'b00}+zeroExtend(horCounter));
139
     $write(prefix);
140
     //$write("(%d,%d,%d,%d,%d,%d)", counter, addr, horCounter, verCounter, picWidth, picHeight);
141
     $write("DUMP ");
142
     $display("%h", yValues.sub(addr));
143
 
144
     yValues.upd(addr,0);
145
     if(horCounter + 1 == zeroExtend(picWidth)*4) // 4 values per Mb
146
       begin
147
         horCounter <= 0;
148
         if(verCounter + 1 == zeroExtend(picHeight)*16)
149
           begin
150
             state <= DumpingU;
151
             verCounter <= 0;
152
             counter <= 0;
153
           end
154
         else
155
           begin
156
             verCounter <= verCounter + 1;
157
             counter <= counter + 1;
158
           end
159
       end
160
     else
161
       begin
162
         horCounter <= horCounter + 1;
163
         counter <= counter + 1;
164
       end
165
   endrule
166
 
167
   rule dumpU(state == DumpingU);
168
     Bit#(TAdd#(PicAreaSz,4)) addr = truncate({(verCounter*zeroExtend(picWidth)),1'b0}+zeroExtend(horCounter));
169
     $write(prefix);
170
     //$write("(%d,%d,%d,%d)", counter, addr, horCounter, verCounter);
171
 
172
     $write("DUMP ");
173
     $display("%h", uValues.sub(addr));
174
     uValues.upd(addr, 0);
175
 
176
     if(horCounter + 1 == zeroExtend(picWidth)*2) // 2 values per Mb
177
       begin
178
         horCounter <= 0;
179
         if(verCounter + 1 == zeroExtend(picHeight)*8) // Chroma have half as much data
180
           begin
181
             state <= DumpingV;
182
             verCounter <= 0;
183
             counter <= 0;
184
           end
185
         else
186
           begin
187
             verCounter <= verCounter + 1;
188
             counter <= counter + 1;
189
           end
190
       end
191
     else
192
       begin
193
         horCounter <= horCounter + 1;
194
         counter <= counter + 1;
195
       end
196
   endrule
197
 
198
   rule dumpV(state == DumpingV);
199
     Bit#(TAdd#(PicAreaSz,4)) addr = truncate({(verCounter*zeroExtend(picWidth)),1'b0}+zeroExtend(horCounter));
200
     $write(prefix);
201
     //$write("(%d,%d,%d,%d)", counter, addr, horCounter, verCounter);
202
     $write("DUMP ");
203
     $display("%h", vValues.sub(addr));
204
     vValues.upd(addr, 0);
205
     if(horCounter + 1 == zeroExtend(picWidth)*2) // 2 values per Mb
206
       begin
207
         horCounter <= 0;
208
         if(verCounter + 1 == zeroExtend(picHeight)*8) // Chroma have half as much data
209
           begin
210
             state <= Forwarding;
211
             verCounter <= 0;
212
           end
213
         else
214
           begin
215
             verCounter <= verCounter + 1;
216
             counter <= counter + 1;
217
           end
218
       end
219
     else
220
       begin
221
         horCounter <= horCounter + 1;
222
         counter <= counter + 1;
223
       end
224
   endrule
225
 end
226 21 jamey.hick
endmodule
227
 
228
 

powered by: WebSVN 2.1.0

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