URL
https://opencores.org/ocsvn/bluespec-h264/bluespec-h264/trunk
Subversion Repositories bluespec-h264
Compare Revisions
- This comparison shows the changes necessary to convert path
/
- from Rev 5 to Rev 6
- ↔ Reverse comparison
Rev 5 → Rev 6
/trunk/src/mkDeblockFilter.bsv
167,11 → 167,26
|
|
|
|
|
//----------------------------------------------------------- |
// Deblocking Filter Module |
//----------------------------------------------------------- |
interface ILeftVector; |
method Bit#(32) sub(Bit#(7) addr); |
method Action upd(Bit#(7) addr, Bit#(32) data); |
endinterface |
|
(*synthesize*) |
module mkLeftVector(ILeftVector); |
RFile1#(Bit#(7),Bit#(32)) leftVector <- mkRFile1(0,95); |
method sub = leftVector.sub; |
method upd = leftVector.upd; |
endmodule |
|
|
|
|
(* synthesize *) |
module mkDeblockFilter( IDeblockFilter ); |
|
245,7 → 260,7
{ 9,12,18 }, {10,13,20 }, {11,15,23 }, {13,17,25 }}; |
|
Reg#(Vector#(64,Bit#(32))) workVector <- mkRegU(); |
Reg#(Vector#(96,Bit#(32))) leftVector <- mkRegU(); |
ILeftVector leftVector <- mkLeftVector(); |
Reg#(Vector#(16,Bit#(32))) topVector <- mkRegU(); |
|
Reg#(Bool) startLastOutput <- mkReg(False); |
255,7 → 270,9
|
RFile1#(Bit#(4),Tuple2#(Bit#(3),Bit#(3))) bSfile <- mkRFile1Full(); |
|
Reg#(Bit#(6)) cleanup_state <- mkReg(0); |
|
|
//----------------------------------------------------------- |
// Rules |
|
447,7 → 464,7
Bit#(2) blockHor = {blockNum[2],blockNum[0]}; |
Bit#(2) blockVer = {blockNum[3],blockNum[1]}; |
Bit#(2) pixelVer = {pixelNum[3],pixelNum[2]}; |
Vector#(96,Bit#(32)) leftVectorNext = leftVector; |
//Vector#(96,Bit#(32)) leftVectorNext = leftVector; |
Vector#(64,Bit#(32)) workVectorNext = workVector; |
Bool leftEdge = (blockNum[0]==0 && (blockNum[2]==0 || chromaFlag==1)); |
if(blockNum==0 && pixelNum==0) |
477,7 → 494,7
Bit#(32) pixelq = {xdata[3],xdata[2],xdata[1],xdata[0]}; |
Bit#(32) pixelp; |
if(leftEdge) |
pixelp = leftVector[addrpLeft]; |
pixelp = leftVector.sub(addrpLeft); |
else |
pixelp = workVector[addrpCurr]; |
Bit#(64) result = {pixelq,pixelp}; |
492,11 → 509,11
result = filter_input({pixelq,pixelp},chromaFlag==1,tpl_1(bSfile.sub((chromaFlag==0?blockNum:{blockNum[1:0],pixelVer[1],1'b0}))),alphaInternal,betaInternal,tc0Internal); |
end |
if(leftEdge) |
leftVectorNext[addrpLeft] = result[31:0]; |
leftVector.upd(addrpLeft,result[31:0]); |
else |
workVectorNext[addrpCurr] = result[31:0]; |
workVectorNext[addrq] = result[63:32]; |
leftVector <= leftVectorNext; |
|
workVector <= workVectorNext; |
if(pixelNum==12 && (blockNum==15 || (blockNum==7 && chromaFlag==1))) |
begin |
634,7 → 651,7
leftAddr = {1'b0,blockHor,blockVer,pixelVer}; |
else |
leftAddr = {2'b10,blockHor,blockVer[0],pixelVer}; |
Bit#(32) leftData = leftVector[leftAddr]; |
Bit#(32) leftData = leftVector.sub(leftAddr); |
if(!(blockNum==3 || (blockNum==1 && chromaFlag==1))) |
begin |
if(chromaFlag==0) |
685,44 → 702,66
outputingFinished <= False; |
endrule |
|
rule cleanup_unroll ( process==Cleanup && currMbHor<zeroExtend(picWidth) && cleanup_state > 0 ); |
if(chromaFlag == 0) |
begin |
cleanup_state <= cleanup_state + 1; |
if(cleanup_state + 1 == 0) |
begin |
chromaFlag <= 1; |
process <= Initialize; |
end |
leftVector.upd(zeroExtend(cleanup_state), workVector[cleanup_state]); |
end |
else |
begin |
if(cleanup_state + 1 == 32) |
begin |
cleanup_state <= 0; |
chromaFlag <= 0; |
process <= Passing; |
Bit#(PicWidthSz) temp = truncate(currMbHor); |
parameterMemReqQ.enq(StoreReq {addr:temp,data:{curr_intra,curr_qpc,curr_qpy}}); |
left_intra <= curr_intra; |
left_qpc <= curr_qpc; |
left_qpy <= curr_qpy; |
currMb <= currMb+1; |
currMbHor <= currMbHor+1; |
if(currMbVer==picHeight-1 && currMbHor==zeroExtend(picWidth-1)) |
begin |
outfifo.enq(EndOfFrame); |
end |
end |
else |
begin |
cleanup_state <= cleanup_state + 1; |
end |
Bit#(5) tempAddr = cleanup_state[4:0]; |
leftVector.upd({2'b10,tempAddr}, workVector[{tempAddr[4:3],1'b0,tempAddr[2:0]}]); |
end |
endrule |
|
rule cleanup ( process==Cleanup && currMbHor<zeroExtend(picWidth) ); |
rule cleanup ( process==Cleanup && currMbHor<zeroExtend(picWidth) && cleanup_state == 0 ); |
//$display( "TRACE Deblocking Filter: cleanup %0d %0d", blockNum, pixelNum); |
Bit#(2) blockHor = pixelNum[1:0]; |
Bit#(2) blockVer = blockNum[1:0]; |
Bit#(2) pixelVer = pixelNum[3:2]; |
Bit#(PicWidthSz) currMbHorT = truncate(currMbHor); |
Vector#(96,Bit#(32)) leftVectorNext = leftVector; |
|
if(blockNum==0) |
begin |
if(chromaFlag==0) |
begin |
for(Integer ii=0; ii<64; ii=ii+1) |
leftVectorNext[fromInteger(ii)] = workVector[fromInteger(ii)]; |
chromaFlag <= 1; |
process <= Initialize; |
end |
else |
begin |
for(Integer ii=0; ii<32; ii=ii+1) |
begin |
Bit#(5) tempAddr = fromInteger(ii); |
leftVectorNext[{2'b10,tempAddr}] = workVector[{tempAddr[4:3],1'b0,tempAddr[2:0]}]; |
end |
chromaFlag <= 0; |
process <= Passing; |
Bit#(PicWidthSz) temp = truncate(currMbHor); |
parameterMemReqQ.enq(StoreReq {addr:temp,data:{curr_intra,curr_qpc,curr_qpy}}); |
left_intra <= curr_intra; |
left_qpc <= curr_qpc; |
left_qpy <= curr_qpy; |
currMb <= currMb+1; |
currMbHor <= currMbHor+1; |
if(currMbVer==picHeight-1 && currMbHor==zeroExtend(picWidth-1)) |
outfifo.enq(EndOfFrame); |
end |
leftVector <= leftVectorNext; |
end |
begin |
if(chromaFlag==0) |
begin |
leftVector.upd(0, workVector[0]); |
cleanup_state <= cleanup_state + 1; |
end |
else |
begin |
Bit#(5) tempAddr = 0; |
leftVector.upd({2'b10,tempAddr}, workVector[{tempAddr[4:3],1'b0,tempAddr[2:0]}]); |
cleanup_state <= cleanup_state + 1; |
end |
end |
else if(blockNum < 8) |
begin |
Bit#(7) leftAddr; |
730,7 → 769,7
leftAddr = {1'b0,blockHor,blockVer,pixelVer}; |
else |
leftAddr = {2'b10,blockHor,blockVer[0],pixelVer}; |
Bit#(32) leftData = leftVector[leftAddr]; |
Bit#(32) leftData = leftVector.sub(leftAddr); |
if(chromaFlag==0) |
outfifo.enq(DFBLuma {ver:{(currMbHorT==0 ? currMbVer-1 : currMbVer),blockVer,pixelVer},hor:{(currMbHorT==0 ? picWidth-1 : currMbHorT-1),blockHor},data:leftData}); |
else |
764,8 → 803,6
endrule |
|
|
|
|
|
|
interface Client mem_client_data; |
/trunk/src/mkFinalOutput.bsv
9,10 → 9,13
import H264Types::*; |
import IFinalOutput::*; |
import FIFO::*; |
import RegFile::*; |
|
import Connectable::*; |
import GetPut::*; |
|
`define INPUT_SIZE 17740800 |
|
//----------------------------------------------------------- |
// Final Output Module |
//----------------------------------------------------------- |
20,16 → 23,64
module mkFinalOutput( IFinalOutput ); |
|
FIFO#(BufferControlOT) infifo <- mkFIFO; |
RegFile#(Bit#(27), Bit#(8)) rfile <- mkRegFileLoad("golden.hex", 0, `INPUT_SIZE); |
|
Reg#(Bit#(27)) index <- mkReg(0); |
|
Reg#(Bit#(32)) tick_counter <- mkReg(0); |
Reg#(Bit#(32)) data_seen_counter <- mkReg(0); |
Reg#(Bit#(32)) last_f_count <- mkReg(0); |
Reg#(Bit#(32)) f_count <- mkReg(0); |
|
rule tick; |
tick_counter <= tick_counter + 1; |
if(tick_counter%2000000 == 0) |
begin |
if(last_f_count == f_count) |
begin |
$display("mkFinalOutput: Warning: no new frames, stuck at %d", last_f_count); |
end |
else |
begin |
$display("mkFinalOutput: Feelin' fine current frames: %d", last_f_count); |
end |
last_f_count <= f_count; |
end |
endrule |
|
//----------------------------------------------------------- |
// Rules |
rule finalout (True); |
rule finalout (True); |
Bit#(32) data_constant = pack(fromInteger(horizontal_pixels * vertical_pixels))*3/2; |
if(data_seen_counter + 4 > data_constant) |
begin |
f_count <= f_count + 1; |
data_seen_counter <= 0; |
end |
else |
begin |
data_seen_counter <= data_seen_counter+4; |
end |
|
index <= index + 4; |
if(infifo.first() matches tagged YUV .xdata) |
begin |
$display("ccl5finalout %h", xdata[7:0]); |
$display("ccl5finalout %h", xdata[15:8]); |
$display("ccl5finalout %h", xdata[23:16]); |
$display("ccl5finalout %h", xdata[31:24]); |
if( xdata[7:0] != rfile.sub(index)) |
begin |
$display("ccl5finalout ERROR %h, index %d", xdata[7:0], index); |
end |
if( xdata[15:8] != rfile.sub(index + 1)) |
begin |
$display("ccl5finalout ERROR %h, index %d", xdata[15:8], index + 1); |
end |
if( xdata[23:16] != rfile.sub(index+2)) |
begin |
$display("ccl5finalout ERROR %h, index %d", xdata[23:16], index+2); |
end |
if( xdata[31:24] != rfile.sub(index+3)) |
begin |
$display("ccl5finalout ERROR %h, index %d", xdata[31:24], index+3); |
end |
infifo.deq(); |
end |
else |
/trunk/src/H264Types.bsv
33,6 → 33,8
Integer deblockFilter_infifo_size = 32; |
Integer bufferControl_infifo_size = 2; |
|
Integer horizontal_pixels = 224; |
Integer vertical_pixels = 176; |
|
//----------------------------------------------------------- |
// 1 read port register file module |
/trunk/src/mkInputGen.bsv
14,21 → 14,22
import Connectable::*; |
import GetPut::*; |
|
`define INPUT_SIZE 1480433 |
|
module mkInputGen( IInputGen ); |
|
RegFile#(Bit#(27), Bit#(8)) rfile <- mkRegFileLoad("720p50_parkrun_ter1-20inter.hex", 0, 2282510); |
RegFile#(Bit#(27), Bit#(8)) rfile <- mkRegFileLoad("akiyo224x176_1-300.hex", 0, `INPUT_SIZE); |
|
FIFO#(InputGenOT) outfifo <- mkFIFO; |
Reg#(Bit#(27)) index <- mkReg(0); |
|
rule output_byte (index < 2282511); |
rule output_byte (index < `INPUT_SIZE); |
//$display( "ccl0inputbyte %x", rfile.sub(index) ); |
outfifo.enq(DataByte rfile.sub(index)); |
index <= index+1; |
endrule |
|
rule end_of_file (index == 2282511); |
rule end_of_file (index == `INPUT_SIZE); |
//$finish(0); |
outfifo.enq(EndOfFile); |
endrule |