Line 180... |
Line 180... |
|
|
FIFOF#(OutState) outstatefifo <- mkFIFOF;
|
FIFOF#(OutState) outstatefifo <- mkFIFOF;
|
FIFOF#(NextOutput) nextoutputfifo <- mkFIFOF;
|
FIFOF#(NextOutput) nextoutputfifo <- mkFIFOF;
|
Reg#(Bit#(4)) outBlockNum <- mkReg(0);
|
Reg#(Bit#(4)) outBlockNum <- mkReg(0);
|
Reg#(Bit#(4)) outPixelNum <- mkReg(0);
|
Reg#(Bit#(4)) outPixelNum <- mkReg(0);
|
FIFO#(Vector#(4,Bit#(8))) predictedfifo <- mkSizedFIFO(prediction_predictedfifo_size);
|
FIFO#(Tuple3#(ChromaFlag,OutState,Vector#(4,Bit#(8)))) predictedfifoluma <- mkSizedFIFO(prediction_predictedfifo_size);
|
|
FIFO#(Tuple3#(ChromaFlag,OutState,Vector#(4,Bit#(8)))) predictedfifochroma <- mkSizedFIFO(prediction_predictedfifo_size);
|
Reg#(ChromaFlag) outChromaFlag <- mkReg(Luma);
|
Reg#(ChromaFlag) outChromaFlag <- mkReg(Luma);
|
Reg#(Bool) outFirstQPFlag <- mkReg(False);
|
Reg#(Bool) outFirstQPFlag <- mkReg(False);
|
|
|
|
|
DoNotFire donotfire <- mkDoNotFire();
|
DoNotFire donotfire <- mkDoNotFire();
|
|
|
//Reg#(Vector#(16,Bit#(8))) workVector <- mkRegU();
|
//Reg#(Vector#(16,Bit#(8))) workVector <- mkRegU();
|
|
|
//Inter state
|
//Inter state
|
Interpolator interpolator <- mkInterpolator();
|
Interpolator interpolator_luma <- mkInterpolator();
|
|
Interpolator interpolator_chroma <- mkInterpolator();
|
Reg#(InterState) interstate <- mkReg(Start);
|
Reg#(InterState) interstate <- mkReg(Start);
|
Reg#(Bit#(PicAreaSz)) interPskipCount <- mkReg(0);
|
Reg#(Bit#(PicAreaSz)) interPskipCount <- mkReg(0);
|
Reg#(Vector#(5,InterBlockMv)) interTopVal <- mkRegU();
|
Reg#(Vector#(5,InterBlockMv)) interTopVal <- mkRegU();
|
Reg#(Vector#(4,InterBlockMv)) interLeftVal <- mkRegU();
|
Reg#(Vector#(4,InterBlockMv)) interLeftVal <- mkRegU();
|
Reg#(Vector#(4,InterBlockMv)) interTopLeftVal <- mkRegU();
|
Reg#(Vector#(4,InterBlockMv)) interTopLeftVal <- mkRegU();
|
Line 241... |
Line 244... |
Reg#(Vector#(4,Bool)) interTopNonZeroTransCoeff <- mkRegU();
|
Reg#(Vector#(4,Bool)) interTopNonZeroTransCoeff <- mkRegU();
|
Reg#(Vector#(4,Bool)) interLeftNonZeroTransCoeff <- mkRegU();
|
Reg#(Vector#(4,Bool)) interLeftNonZeroTransCoeff <- mkRegU();
|
FIFO#(Tuple2#(Bit#(2),Bit#(2))) interBSfifo <- mkSizedFIFO(32);
|
FIFO#(Tuple2#(Bit#(2),Bit#(2))) interBSfifo <- mkSizedFIFO(32);
|
Reg#(Bool) interBSoutput <- mkReg(True);
|
Reg#(Bool) interBSoutput <- mkReg(True);
|
FIFO#(InterBlockMv) interOutBlockMvfifo <- mkSizedFIFO(8);
|
FIFO#(InterBlockMv) interOutBlockMvfifo <- mkSizedFIFO(8);
|
FIFO#(ChromaFlag) memReqTypeFIFO <- mkSizedFIFO(32);
|
FIFO#(InterpolatorLoadReq) interpolatorLoadReqQ <- mkFIFO;
|
|
|
|
|
//Intra state
|
//Intra state
|
Reg#(IntraState) intrastate <- mkReg(Start);
|
Reg#(IntraState) intrastate <- mkReg(Start);
|
Reg#(Bit#(1)) intraChromaFlag <- mkReg(0);
|
Reg#(ChromaFlag) intraChromaFlag <- mkReg(Luma);
|
FIFO#(MemReq#(TAdd#(PicWidthSz,2),68)) intraMemReqQ <- mkFIFO;
|
FIFO#(MemReq#(TAdd#(PicWidthSz,2),68)) intraMemReqQ <- mkFIFO;
|
Reg#(MemReq#(TAdd#(PicWidthSz,2),68)) intraMemReqQdelay <- mkRegU;
|
Reg#(MemReq#(TAdd#(PicWidthSz,2),68)) intraMemReqQdelay <- mkRegU;
|
FIFO#(MemResp#(68)) intraMemRespQ <- mkFIFO;
|
FIFO#(MemResp#(68)) intraMemRespQ <- mkFIFO;
|
Reg#(Vector#(4,Bit#(4))) intra4x4typeLeft <- mkRegU();//15=unavailable, 14=inter-MB, 13=intra-non-4x4
|
Reg#(Vector#(4,Bit#(4))) intra4x4typeLeft <- mkRegU();//15=unavailable, 14=inter-MB, 13=intra-non-4x4
|
Reg#(Vector#(4,Bit#(4))) intra4x4typeTop <- mkRegU();//15=unavailable, 14=inter-MB, 13=intra-non-4x4
|
Reg#(Vector#(4,Bit#(4))) intra4x4typeTop <- mkRegU();//15=unavailable, 14=inter-MB, 13=intra-non-4x4
|
Line 290... |
Line 293... |
// if(infifo.first() matches tagged ITBresidual .xdata)
|
// if(infifo.first() matches tagged ITBresidual .xdata)
|
// $display( "TRACE Prediction: stateMonitor outBlockNum outPixelNum outChromaFlag %0d %0d", outBlockNum, outPixelNum, outChromaFlag);////////////////////
|
// $display( "TRACE Prediction: stateMonitor outBlockNum outPixelNum outChromaFlag %0d %0d", outBlockNum, outPixelNum, outChromaFlag);////////////////////
|
// endrule
|
// endrule
|
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
Reg#(Bit#(64)) total_cycles <- mkReg(0);
|
|
|
|
|
|
rule incr;
|
|
total_cycles <= total_cycles + 1;
|
|
endrule
|
|
|
rule checkFIFO ( True );
|
rule checkFIFO ( True );
|
$display( "Trace Prediction: checkFIFO %h", infifo.first() );
|
$display( "Trace Prediction: checkFIFO %h", infifo.first() );
|
endrule
|
endrule
|
rule checkFIFO_ITB ( True );
|
rule checkFIFO_ITB ( True );
|
$display( "Trace Prediction: checkFIFO_ITB %h", infifo_ITB.first() );
|
$display( "Trace Prediction: checkFIFO_ITB %h", infifo_ITB.first() );
|
|
case ( infifo_ITB.first()) matches
|
|
tagged ITBcoeffLevelZeros: $display("Caused by ITBcoeffLevelZeros");
|
|
tagged ITBresidual .data: $display("Caused by ITBresidual");
|
|
tagged IBTmb_qp .data: $display("Caused by ITBmb_qp");
|
|
endcase
|
|
endrule
|
|
rule checkFIFO_predictedluma ( True );
|
|
$display( "Trace Prediction: checkFIFO_predictedluma %h", predictedfifoluma.first() );
|
|
endrule
|
|
rule checkFIFO_predictedchroma ( True );
|
|
$display( "Trace Prediction: checkFIFO_predictedchroma %h", predictedfifochroma.first() );
|
endrule
|
endrule
|
rule checkFIFO_predicted ( True );
|
rule checkFIFO_memreqchroma ( True );
|
$display( "Trace Prediction: checkFIFO_predicted %h", predictedfifo.first() );
|
$display( "Trace Prediction: checkFIFO_mem_req_chroma %h", interpolator_chroma.mem_request_first() );
|
endrule
|
endrule
|
|
rule checkFIFO_memreqluma ( True );
|
|
$display( "Trace Prediction: checkFIFO_mem_req_luma %h", interpolator_chroma.mem_request_first() );
|
|
endrule
|
|
|
|
|
|
|
rule passing ( passFlag && !outstatefifo.notEmpty() && currMbHor
|
rule passing ( passFlag && !outstatefifo.notEmpty() && currMbHor
|
$display( "Trace Prediction: passing infifo packed %h", pack(infifo.first()));
|
$display( "Trace Prediction: passing infifo packed %h", pack(infifo.first()));
|
case (infifo.first()) matches
|
case (infifo.first()) matches
|
Line 318... |
Line 343... |
begin
|
begin
|
infifo.deq();
|
infifo.deq();
|
outfifoluma.enq(infifo.first());
|
outfifoluma.enq(infifo.first());
|
outfifochroma.enq(infifo.first());
|
outfifochroma.enq(infifo.first());
|
picWidth <= xdata;
|
picWidth <= xdata;
|
interpolator.setPicWidth(xdata);
|
interpolator_luma.setPicWidth(xdata);
|
|
interpolator_chroma.setPicWidth(xdata);
|
end
|
end
|
tagged SPSpic_height_in_map_units .xdata :
|
tagged SPSpic_height_in_map_units .xdata :
|
begin
|
begin
|
infifo.deq();
|
infifo.deq();
|
outfifoluma.enq(infifo.first());
|
outfifoluma.enq(infifo.first());
|
outfifochroma.enq(infifo.first());
|
outfifochroma.enq(infifo.first());
|
picHeight <= xdata;
|
picHeight <= xdata;
|
interpolator.setPicHeight(xdata);
|
interpolator_luma.setPicHeight(xdata);
|
|
interpolator_chroma.setPicHeight(xdata);
|
end
|
end
|
tagged PPSconstrained_intra_pred_flag .xdata :
|
tagged PPSconstrained_intra_pred_flag .xdata :
|
begin
|
begin
|
infifo.deq();
|
infifo.deq();
|
ppsconstrained_intra_pred_flag <= xdata;
|
ppsconstrained_intra_pred_flag <= xdata;
|
Line 560... |
Line 587... |
end
|
end
|
default: passFlag <= True;
|
default: passFlag <= True;
|
endcase
|
endcase
|
endrule
|
endrule
|
|
|
|
// only 8 filter components for
|
|
// for bshor, chroma always ends in zero
|
|
// for bsver, bSfileVer.sub((chromaFlag==Luma?blockNumCols:{blockVer[0],blockHor[0],1'b0,columnNumber[1]}));
|
rule outputing ( currMbHor
|
rule outputing ( currMbHor
|
|
match{.predictedfifo, .outfifo} = (outChromaFlag==Luma)?tuple2(predictedfifoluma, outfifoluma):
|
|
tuple2(predictedfifochroma, outfifochroma);
|
Bit#(1) outputFlag = 0;
|
Bit#(1) outputFlag = 0;
|
Vector#(4,Bit#(8)) outputVector = replicate(0);
|
Vector#(4,Bit#(8)) outputVector = replicate(0);
|
Bit#(2) blockHor = {outBlockNum[2],outBlockNum[0]};
|
Bit#(2) blockHor = {outBlockNum[2],outBlockNum[0]};
|
Bit#(2) blockVer = {outBlockNum[3],outBlockNum[1]};
|
Bit#(2) blockVer = {outBlockNum[3],outBlockNum[1]};
|
Bit#(2) pixelVer = {outPixelNum[3],outPixelNum[2]};
|
Bit#(2) pixelVer = {outPixelNum[3],outPixelNum[2]};
|
Bit#(4) totalVer = {blockVer,pixelVer};
|
Bit#(4) totalVer = {blockVer,pixelVer};
|
|
|
$display( "bsFIFO Trace Prediction: outputing (%d,%d)", blockVer,blockHor );
|
$display( "bsFIFO Trace Prediction: outputing (%d,%d)", blockVer,blockHor );
|
if(outFirstQPFlag)
|
if(outFirstQPFlag)
|
begin
|
begin
|
if(infifo_ITB.first() matches tagged IBTmb_qp .xdata)
|
if(infifo_ITB.first() matches tagged IBTmb_qp .xdata)
|
begin
|
begin
|
Line 582... |
Line 614... |
$display( "Trace Prediction: outputing outFirstQP %h %h %h", outBlockNum, outPixelNum, xdata);
|
$display( "Trace Prediction: outputing outFirstQP %h %h %h", outBlockNum, outPixelNum, xdata);
|
end
|
end
|
else
|
else
|
$display( "ERROR Prediction: outputing unexpected infifo_ITB.first()");
|
$display( "ERROR Prediction: outputing unexpected infifo_ITB.first()");
|
end
|
end
|
else if(nextoutputfifo.first() == SkipMB)
|
else if(nextoutputfifo.first() == SkipMB) // if(!outFirstQPFlag)
|
|
// It's clear that we will first process either the nextoutputfifo or something similar
|
begin
|
begin
|
if(interBSoutput && outChromaFlag==Luma && outPixelNum==0)
|
if(interBSoutput && outChromaFlag==Luma && outPixelNum==0)
|
begin
|
begin
|
interBSoutput <= False;
|
interBSoutput <= False;
|
interBSfifo.deq();
|
interBSfifo.deq();
|
Line 598... |
Line 631... |
outfifochroma.enq(PBbS {bShor:horBS,bSver:verBS,blockNum: outBlockNum});
|
outfifochroma.enq(PBbS {bShor:horBS,bSver:verBS,blockNum: outBlockNum});
|
interLeftNonZeroTransCoeff <= update(interLeftNonZeroTransCoeff, blockVer, False);
|
interLeftNonZeroTransCoeff <= update(interLeftNonZeroTransCoeff, blockVer, False);
|
interTopNonZeroTransCoeff <= update(interTopNonZeroTransCoeff, blockHor, False);
|
interTopNonZeroTransCoeff <= update(interTopNonZeroTransCoeff, blockHor, False);
|
$display( "Trace Prediction: outputing SkipMB bS %h %h %h %h", outBlockNum, outPixelNum, currMbHor, currMbVer);
|
$display( "Trace Prediction: outputing SkipMB bS %h %h %h %h", outBlockNum, outPixelNum, currMbHor, currMbVer);
|
end
|
end
|
else
|
else // normally outputing
|
begin
|
begin
|
interBSoutput <= True;
|
interBSoutput <= True;
|
outputVector = predictedfifo.first();
|
match {.chromaFlag, .decodeType, .outputVectorTyped} = predictedfifo.first;
|
outfifoluma.enq(tagged PBoutput tuple2(outChromaFlag,outputVector));
|
outputVector = outputVectorTyped;
|
outfifochroma.enq(tagged PBoutput tuple2(outChromaFlag,outputVector));
|
outfifo.enq(tagged PBoutput tuple2(chromaFlag, outputVector));
|
|
predictedfifo.deq;
|
|
|
|
if(decodeType != outstatefifo.first)
|
|
begin
|
|
$display("Trace Prediction: ERROR! decode type is not the same as outfifo");
|
|
end
|
|
if(chromaFlag != outChromaFlag)
|
|
begin
|
|
$display("Trace Predicition ERROR! stream chroma flag not equal to outChromaFlag");
|
|
end
|
|
|
outputFlag = 1;
|
outputFlag = 1;
|
predictedfifo.deq();
|
|
$display( "Trace Prediction: outputing SkipMB out %h %h %h", outBlockNum, outPixelNum, outputVector);
|
$display( "Trace Prediction: outputing SkipMB out %h %h %h", (outChromaFlag==Luma)?"Luma":"Chroma",outBlockNum, outPixelNum, outputVector);
|
end
|
end
|
end
|
end
|
else
|
else // if(!(outFirstQPFlag || nextoutputfifo.first() == SkipMB))
|
begin
|
begin
|
case ( infifo_ITB.first() ) matches
|
case ( infifo_ITB.first() ) matches // Perhaps this has some latency
|
tagged IBTmb_qp .xdata :
|
tagged IBTmb_qp .xdata :
|
begin
|
begin
|
infifo_ITB.deq();
|
infifo_ITB.deq();
|
outfifoluma.enq(tagged IBTmb_qp {qpy:xdata.qpy,qpc:xdata.qpc});
|
outfifoluma.enq(tagged IBTmb_qp {qpy:xdata.qpy,qpc:xdata.qpc});
|
outfifochroma.enq(tagged IBTmb_qp {qpy:xdata.qpy,qpc:xdata.qpc});
|
outfifochroma.enq(tagged IBTmb_qp {qpy:xdata.qpy,qpc:xdata.qpc});
|
Line 644... |
Line 688... |
end
|
end
|
interLeftNonZeroTransCoeff <= update(interLeftNonZeroTransCoeff, blockVer, True);
|
interLeftNonZeroTransCoeff <= update(interLeftNonZeroTransCoeff, blockVer, True);
|
interTopNonZeroTransCoeff <= update(interTopNonZeroTransCoeff, blockHor, True);
|
interTopNonZeroTransCoeff <= update(interTopNonZeroTransCoeff, blockHor, True);
|
$display( "Trace Prediction: outputing ITBresidual bS %h %h %h %h %h", outChromaFlag, outBlockNum, outPixelNum, currMbHor, currMbVer);
|
$display( "Trace Prediction: outputing ITBresidual bS %h %h %h %h %h", outChromaFlag, outBlockNum, outPixelNum, currMbHor, currMbVer);
|
end
|
end
|
else
|
else // Normally we'd be outputing here too.
|
begin
|
begin
|
interBSoutput <= True;
|
interBSoutput <= True;
|
Bit#(11) tempOutputValue = 0;
|
Bit#(11) tempOutputValue = 0;
|
|
|
|
match {.chromaFlag, .decodeType, .outputVectorTyped} = predictedfifo.first;
|
|
|
|
predictedfifo.deq;
|
|
|
|
if(decodeType != outstatefifo.first)
|
|
begin
|
|
$display("Trace Prediction: ERROR! decode type is not the same as outfifo");
|
|
end
|
|
|
|
|
for(Integer ii=0; ii<4; ii=ii+1)
|
for(Integer ii=0; ii<4; ii=ii+1)
|
begin
|
begin
|
tempOutputValue = signExtend(xdata[ii]) + zeroExtend((predictedfifo.first())[ii]);
|
tempOutputValue = signExtend(xdata[ii]) + zeroExtend((outputVectorTyped)[ii]);
|
if(tempOutputValue[10]==1)
|
if(tempOutputValue[10]==1)
|
outputVector[ii] = 0;
|
outputVector[ii] = 0;
|
else if(tempOutputValue[9:0] > 255)
|
else if(tempOutputValue[9:0] > 255)
|
outputVector[ii] = 255;
|
outputVector[ii] = 255;
|
else
|
else
|
outputVector[ii] = tempOutputValue[7:0];
|
outputVector[ii] = tempOutputValue[7:0];
|
end
|
end
|
outfifoluma.enq(tagged PBoutput tuple2(outChromaFlag,outputVector));
|
|
outfifochroma.enq(tagged PBoutput tuple2(outChromaFlag,outputVector));
|
outfifo.enq(tagged PBoutput tuple2(chromaFlag,outputVector));
|
infifo_ITB.deq();
|
|
predictedfifo.deq();
|
if(chromaFlag != outChromaFlag)
|
|
begin
|
|
$display("Trace Predicition ERROR! stream chroma flag not equal to outChromaFlag");
|
|
end
|
|
|
outputFlag = 1;
|
outputFlag = 1;
|
$display( "Trace Prediction: outputing ITBresidual out %h %h %h %h %h %h", outChromaFlag, outBlockNum, outPixelNum, predictedfifo.first(), xdata, outputVector);
|
infifo_ITB.deq();
|
|
$display( "Trace Prediction: outputing ITBresidual %s %h %h %h", (chromaFlag == Luma)?"Luma":"Chroma",outChromaFlag, outBlockNum, outPixelNum);
|
end
|
end
|
end
|
end
|
tagged ITBcoeffLevelZeros :
|
tagged ITBcoeffLevelZeros :
|
begin
|
begin
|
if(interBSoutput && outChromaFlag==Luma && outPixelNum==0)
|
if(interBSoutput && outChromaFlag==Luma && outPixelNum==0) // Appears to be an initialization thing
|
begin
|
begin
|
interBSoutput <= False;
|
interBSoutput <= False;
|
if(outstatefifo.first() != Inter)
|
if(outstatefifo.first() != Inter)
|
begin
|
begin
|
outfifoluma.enq(tagged PBbS {bShor:(blockHor==0 ? 4 : 3),bSver:(blockVer==0 ? 4 : 3),blockNum: outBlockNum});
|
outfifoluma.enq(tagged PBbS {bShor:(blockHor==0 ? 4 : 3),bSver:(blockVer==0 ? 4 : 3),blockNum: outBlockNum});
|
Line 690... |
Line 750... |
end
|
end
|
interLeftNonZeroTransCoeff <= update(interLeftNonZeroTransCoeff, blockVer, False);
|
interLeftNonZeroTransCoeff <= update(interLeftNonZeroTransCoeff, blockVer, False);
|
interTopNonZeroTransCoeff <= update(interTopNonZeroTransCoeff, blockHor, False);
|
interTopNonZeroTransCoeff <= update(interTopNonZeroTransCoeff, blockHor, False);
|
$display( "Trace Prediction: outputing ITBcoeffLevelZeros bS %h %h %h %h %h", outChromaFlag, outBlockNum, outPixelNum, currMbHor, currMbVer);
|
$display( "Trace Prediction: outputing ITBcoeffLevelZeros bS %h %h %h %h %h", outChromaFlag, outBlockNum, outPixelNum, currMbHor, currMbVer);
|
end
|
end
|
else
|
else // Normally, we'd be outputing here
|
begin
|
begin
|
interBSoutput <= True;
|
interBSoutput <= True;
|
if(outPixelNum == 12)
|
if(outPixelNum == 12)
|
|
begin
|
infifo_ITB.deq();
|
infifo_ITB.deq();
|
outputVector = predictedfifo.first();
|
end
|
outfifoluma.enq(tagged PBoutput tuple2(outChromaFlag,outputVector));
|
match {.chromaFlag, .decodeType, .outputVectorTyped} = predictedfifo.first;
|
outfifochroma.enq(tagged PBoutput tuple2(outChromaFlag,outputVector));
|
outputVector = outputVectorTyped;
|
|
outfifo.enq(tagged PBoutput tuple2(chromaFlag, outputVector));
|
|
predictedfifo.deq;
|
|
if(chromaFlag != outChromaFlag)
|
|
begin
|
|
$display("Trace Predicition ERROR! stream chroma flag not equal to outChromaFlag");
|
|
end
|
|
|
|
if(decodeType != outstatefifo.first)
|
|
begin
|
|
$display("Trace Prediction: ERROR! decode type is not the same as outfifo");
|
|
end
|
|
|
outputFlag = 1;
|
outputFlag = 1;
|
predictedfifo.deq();
|
$display( "Trace Prediction: outputing ITBcoeffLevelZeros %s %h %h %h", (outChromaFlag == Luma)?"Luma":"Chroma",outChromaFlag, outBlockNum, outPixelNum);
|
$display( "Trace Prediction: outputing ITBcoeffLevelZeros out %h %h %h %h %h", outChromaFlag, outBlockNum, outPixelNum, predictedfifo.first(), outputVector);
|
|
end
|
end
|
end
|
end
|
default: $display( "ERROR Prediction: outputing unknown infifo_ITB input" );
|
default: $display( "ERROR Prediction: outputing unknown infifo_ITB input" );
|
endcase
|
endcase
|
end
|
end
|
Line 748... |
Line 820... |
else
|
else
|
intra4x4typeLeft <= update(intra4x4typeLeft,blockVer,14);
|
intra4x4typeLeft <= update(intra4x4typeLeft,blockVer,14);
|
end
|
end
|
endcase
|
endcase
|
end
|
end
|
else
|
else // chroma
|
begin
|
begin
|
if(outBlockNum[2]==0)
|
if(outBlockNum[2]==0)
|
intraLeftValChroma0 <= update(intraLeftValChroma0,totalVer+1,outputVector[3]);
|
intraLeftValChroma0 <= update(intraLeftValChroma0,totalVer+1,outputVector[3]);
|
else
|
else
|
intraLeftValChroma1 <= update(intraLeftValChroma1,totalVer+1,outputVector[3]);
|
intraLeftValChroma1 <= update(intraLeftValChroma1,totalVer+1,outputVector[3]);
|
Line 769... |
Line 841... |
else if(outstatefifo.first()==Intra)
|
else if(outstatefifo.first()==Intra)
|
intra4x4typeTop <= update(intra4x4typeTop,blockHor,13);
|
intra4x4typeTop <= update(intra4x4typeTop,blockHor,13);
|
else
|
else
|
intra4x4typeTop <= update(intra4x4typeTop,blockHor,14);
|
intra4x4typeTop <= update(intra4x4typeTop,blockHor,14);
|
end
|
end
|
else
|
else // Chroma stuff
|
begin
|
begin
|
if(outBlockNum[2]==0)
|
if(outBlockNum[2]==0)
|
begin
|
begin
|
Vector#(4,Bit#(16)) intraTopValChroma0Next = intraTopValChroma0;
|
Vector#(4,Bit#(16)) intraTopValChroma0Next = intraTopValChroma0;
|
intraTopValChroma0Next[{blockHor[0],1'b0}] = {outputVector[1],outputVector[0]};
|
intraTopValChroma0Next[{blockHor[0],1'b0}] = {outputVector[1],outputVector[0]};
|
Line 833... |
Line 905... |
if(outBlockNum == 15)
|
if(outBlockNum == 15)
|
outChromaFlag <= Chroma;
|
outChromaFlag <= Chroma;
|
if(nextoutputfifo.first() == Intra4x4)
|
if(nextoutputfifo.first() == Intra4x4)
|
nextoutputfifo.deq();
|
nextoutputfifo.deq();
|
end
|
end
|
else
|
else // Luma
|
begin
|
begin
|
if(outBlockNum == 7)
|
if(outBlockNum == 7)
|
begin
|
begin
|
outBlockNum <= 0;
|
outBlockNum <= 0;
|
outChromaFlag <= Luma;
|
outChromaFlag <= Luma;
|
Line 845... |
Line 917... |
currMbHor <= currMbHor+1;
|
currMbHor <= currMbHor+1;
|
interCurrMbDiff <= interCurrMbDiff-1;
|
interCurrMbDiff <= interCurrMbDiff-1;
|
outstatefifo.deq;
|
outstatefifo.deq;
|
intrastate <= Start;
|
intrastate <= Start;
|
if(truncate(currMbHor)==picWidth-1 && currMbVer==picHeight-1)
|
if(truncate(currMbHor)==picWidth-1 && currMbVer==picHeight-1)
|
interpolator.endOfFrame();
|
begin
|
|
interpolator_luma.endOfFrame();
|
|
interpolator_chroma.endOfFrame();
|
|
end
|
nextoutputfifo.deq();
|
nextoutputfifo.deq();
|
end
|
end
|
else
|
else
|
outBlockNum <= outBlockNum+1;
|
outBlockNum <= outBlockNum+1;
|
end
|
end
|
end
|
end
|
end
|
end
|
endrule
|
endrule
|
|
|
|
|
|
|
|
|
rule currMbHorUpdate( !(currMbHor
|
rule currMbHorUpdate( !(currMbHor
|
Bit#(PicAreaSz) temp = zeroExtend(picWidth);
|
Bit#(PicAreaSz) temp = zeroExtend(picWidth);
|
if((currMbHor >> 3) >= temp)
|
if((currMbHor >> 3) >= temp)
|
begin
|
begin
|
currMbHor <= currMbHor - (temp << 3);
|
currMbHor <= currMbHor - (temp << 3);
|
Line 1389... |
Line 1466... |
interIPMbPartNumTemp = interIPMbPartNumTemp-2;
|
interIPMbPartNumTemp = interIPMbPartNumTemp-2;
|
refIndex = ((interstate==InterPskip||interstate==InterP8x8ref0) ? 0 : interRefIdxVector[interIPMbPartNumTemp]);
|
refIndex = ((interstate==InterPskip||interstate==InterP8x8ref0) ? 0 : interRefIdxVector[interIPMbPartNumTemp]);
|
btTemp = IP8x8;
|
btTemp = IP8x8;
|
mvhorTemp = tpl_1(interMvFile.sub({interIPMbPartNumTemp,2'b00}));
|
mvhorTemp = tpl_1(interMvFile.sub({interIPMbPartNumTemp,2'b00}));
|
mvverTemp = tpl_2(interMvFile.sub({interIPMbPartNumTemp,2'b00}));
|
mvverTemp = tpl_2(interMvFile.sub({interIPMbPartNumTemp,2'b00}));
|
$display("PARDEBLOCK issuing luma");
|
$display("PARDEBLOCK issuing luma at %0d", total_cycles);
|
interpolator.request(IPLuma {refIdx:refIndex,hor:horTemp,ver:verTemp,mvhor:mvhorTemp,mvver:mvverTemp,bt:btTemp});
|
interpolator_luma.request(IPLuma {refIdx:refIndex,hor:horTemp,ver:verTemp,mvhor:mvhorTemp,mvver:mvverTemp,bt:btTemp});
|
end
|
end
|
else
|
else
|
begin
|
begin
|
$display("PARDEBLOCK issuing luma");
|
$display("PARDEBLOCK issuing luma at %0d", total_cycles);
|
interpolator.request(IPLuma {refIdx:refIndex,hor:horTemp,ver:verTemp,mvhor:mvhorTemp,mvver:mvverTemp,bt:btTemp});
|
interpolator_luma.request(IPLuma {refIdx:refIndex,hor:horTemp,ver:verTemp,mvhor:mvhorTemp,mvver:mvverTemp,bt:btTemp});
|
end
|
end
|
end
|
end
|
else
|
else
|
begin
|
begin
|
$display("PARDEBLOCK issuing Chroma");
|
$display("PARDEBLOCK issuing Chroma at %0d", total_cycles);
|
interpolator.request(IPChroma {refIdx:refIndex,uv:interIPStepCount[0],hor:horTemp,ver:truncate(verTemp>>1),mvhor:mvhorTemp,mvver:mvverTemp,bt:btTemp});
|
interpolator_chroma.request(IPChroma {refIdx:refIndex,uv:interIPStepCount[0],hor:horTemp,ver:truncate(verTemp>>1),mvhor:mvhorTemp,mvver:mvverTemp,bt:btTemp});
|
end
|
end
|
if(interIPSubMbPartNum >= truncate(numSubPart-1))
|
if(interIPSubMbPartNum >= truncate(numSubPart-1))
|
begin
|
begin
|
interIPSubMbPartNum <= 0;
|
interIPSubMbPartNum <= 0;
|
if(interIPMbPartNum >= truncate(numPart-1))
|
if(interIPMbPartNum >= truncate(numPart-1))
|
Line 1435... |
Line 1512... |
rule interDone ( interstate!=Start && interReqCount==0 && interRespCount==0 && interStepCount==0 && interIPStepCount==0 );
|
rule interDone ( interstate!=Start && interReqCount==0 && interRespCount==0 && interStepCount==0 && interIPStepCount==0 );
|
interstate <= Start;
|
interstate <= Start;
|
//$display( "Trace Prediction: interOutputTransfer %h %h", interstate, interOutputCount);
|
//$display( "Trace Prediction: interOutputTransfer %h %h", interstate, interOutputCount);
|
endrule
|
endrule
|
|
|
|
//Can probably just drop these rules. They don't add any value
|
rule interOutputTransfer ( True );
|
rule interOutputTransferChroma (True);
|
predictedfifo.enq(interpolator.first());
|
predictedfifochroma.enq(tuple3(Chroma,Inter,interpolator_chroma.first()));
|
interpolator.deq();
|
interpolator_chroma.deq();
|
//$display( "Trace Prediction: interOutputTransfer %h %h", interstate, interOutputCount);
|
$display( "PARDEBLOCK(%0d): Trace Prediction: interOutputTransfer %h", total_cycles, interstate);
|
endrule
|
endrule
|
|
|
|
|
|
rule interOutputTransferLuma (True);
|
|
predictedfifoluma.enq(tuple3(Luma,Inter,interpolator_luma.first()));
|
|
interpolator_luma.deq();
|
|
$display( "PARDEBLOCK(%0d):: Trace Prediction: interOutputTransfer %h", total_cycles, interstate);
|
|
endrule
|
|
|
// intra prediction rules
|
|
|
|
|
// intra prediction rules
|
rule intraSendReq ( intraReqCount>0 && currMbHor
|
rule intraSendReq ( intraReqCount>0 && currMbHor
|
Bit#(PicWidthSz) temp2 = truncate(currMbHor);
|
Bit#(PicWidthSz) temp2 = truncate(currMbHor);
|
Bit#(TAdd#(PicWidthSz,2)) temp = 0;
|
Bit#(TAdd#(PicWidthSz,2)) temp = 0;
|
Bit#(1) noMoreReq = 0;
|
Bit#(1) noMoreReq = 0;
|
if( currMb-firstMb < zeroExtend(picWidth) )
|
if( currMb-firstMb < zeroExtend(picWidth) )
|
Line 1652... |
Line 1734... |
topAvailable = 1;
|
topAvailable = 1;
|
if(leftType==15 || (leftType==14 && ppsconstrained_intra_pred_flag==1))
|
if(leftType==15 || (leftType==14 && ppsconstrained_intra_pred_flag==1))
|
leftAvailable = 0;
|
leftAvailable = 0;
|
else
|
else
|
leftAvailable = 1;
|
leftAvailable = 1;
|
if(blockNum==0 && pixelNum==0 && intraChromaFlag==0)
|
if(blockNum==0 && pixelNum==0 && intraChromaFlag==Luma)
|
begin
|
begin
|
intraChromaTopAvailable <= topAvailable;
|
intraChromaTopAvailable <= topAvailable;
|
intraChromaLeftAvailable <= leftAvailable;
|
intraChromaLeftAvailable <= leftAvailable;
|
end
|
end
|
if(intrastate==Intra4x4 && intraChromaFlag==0)
|
if(intrastate==Intra4x4 && intraChromaFlag==Luma)
|
begin
|
begin
|
if(intraStepCount==2)
|
if(intraStepCount==2)
|
begin
|
begin
|
outFlag = 1;
|
outFlag = 1;
|
Bit#(40) leftValSet = select(intraLeftVal,blockVer);
|
Bit#(40) leftValSet = select(intraLeftVal,blockVer);
|
Line 1910... |
Line 1992... |
endcase
|
endcase
|
end
|
end
|
else
|
else
|
$display( "ERROR Prediction: intraProcessStep intra4x4 unknown intraStepCount");
|
$display( "ERROR Prediction: intraProcessStep intra4x4 unknown intraStepCount");
|
end
|
end
|
else if(intrastate==Intra16x16 && intraChromaFlag==0)
|
else if(intrastate==Intra16x16 && intraChromaFlag==Luma)
|
begin
|
begin
|
//$display( "TRACE Prediction: intraProcessStep intra16x16 %0d %0d %0d %h", intra16x16_pred_mode, currMb, blockNum, select(intraTopVal,blockHor));/////////////////
|
//$display( "TRACE Prediction: intraProcessStep intra16x16 %0d %0d %0d %h", intra16x16_pred_mode, currMb, blockNum, select(intraTopVal,blockHor));/////////////////
|
case(intra16x16_pred_mode)
|
case(intra16x16_pred_mode)
|
0://vertical
|
0://vertical
|
begin
|
begin
|
Line 2080... |
Line 2162... |
else
|
else
|
$display( "ERROR Prediction: intraProcessStep intra16x16 plane unknown intraStepCount");
|
$display( "ERROR Prediction: intraProcessStep intra16x16 plane unknown intraStepCount");
|
end
|
end
|
endcase
|
endcase
|
end
|
end
|
else if(intraChromaFlag==1)
|
else if(intraChromaFlag==Chroma)
|
begin
|
begin
|
//$display( "TRACE Prediction: intraProcessStep intraChroma %0d %0d %0d %0d %0d %0d %h %h %h %h %h %h %h %h",intra_chroma_pred_mode.first(),intraChromaTopAvailable,intraChromaLeftAvailable,currMb,blockNum,pixelNum,pack(intraLeftValChroma0),pack(intraTopValChroma0),pack(intraLeftValChroma1),pack(intraTopValChroma1),intraLeftValChroma0[0],intraTopValChroma0[3][15:8],intraLeftValChroma1[0],intraTopValChroma1[3][15:8]);///////////////////
|
//$display( "TRACE Prediction: intraProcessStep intraChroma %0d %0d %0d %0d %0d %0d %h %h %h %h %h %h %h %h",intra_chroma_pred_mode.first(),intraChromaTopAvailable,intraChromaLeftAvailable,currMb,blockNum,pixelNum,pack(intraLeftValChroma0),pack(intraTopValChroma0),pack(intraLeftValChroma1),pack(intraTopValChroma1),intraLeftValChroma0[0],intraTopValChroma0[3][15:8],intraLeftValChroma1[0],intraTopValChroma1[3][15:8]);///////////////////
|
Vector#(9,Bit#(8)) tempLeftVec;
|
Vector#(9,Bit#(8)) tempLeftVec;
|
Vector#(4,Bit#(16)) tempTopVec;
|
Vector#(4,Bit#(16)) tempTopVec;
|
if(blockNum[2] == 0)
|
if(blockNum[2] == 0)
|
Line 2250... |
Line 2332... |
else
|
else
|
$display( "ERROR Prediction: intraProcessStep unknown intrastate");
|
$display( "ERROR Prediction: intraProcessStep unknown intrastate");
|
|
|
if(outFlag==1)
|
if(outFlag==1)
|
begin
|
begin
|
predictedfifo.enq(predVector);
|
if(intraChromaFlag == Luma)
|
|
begin
|
|
predictedfifoluma.enq(tuple3(intraChromaFlag,(intrastate==Intra4x4)?Intra4x4:Intra,predVector));
|
|
end
|
|
else
|
|
begin
|
|
predictedfifochroma.enq(tuple3(intraChromaFlag,(intrastate==Intra4x4)?Intra4x4:Intra,predVector));
|
|
end
|
pixelNum <= pixelNum+4;
|
pixelNum <= pixelNum+4;
|
if(pixelNum == 12)
|
if(pixelNum == 12)
|
begin
|
begin
|
if(intraChromaFlag==0)
|
if(intraChromaFlag==Luma)
|
begin
|
begin
|
blockNum <= blockNum+1;
|
blockNum <= blockNum+1;
|
if(blockNum == 15)
|
if(blockNum == 15)
|
begin
|
begin
|
intraChromaFlag <= 1;
|
intraChromaFlag <= Chroma;
|
intraStepCount <= 2;
|
intraStepCount <= 2;
|
end
|
end
|
else if(intrastate==Intra4x4)
|
else if(intrastate==Intra4x4)
|
intraStepCount <= 1;
|
intraStepCount <= 1;
|
end
|
end
|
else
|
else
|
begin
|
begin
|
if(blockNum == 7)
|
if(blockNum == 7)
|
begin
|
begin
|
blockNum <= 0;
|
blockNum <= 0;
|
intraChromaFlag <= 0;
|
intraChromaFlag <= Luma;
|
intraStepCount <= 0;
|
intraStepCount <= 0;
|
intra_chroma_pred_mode.deq();
|
intra_chroma_pred_mode.deq();
|
end
|
end
|
else
|
else
|
begin
|
begin
|
Line 2290... |
Line 2379... |
else
|
else
|
intraStepCount <= nextIntraStepCount;
|
intraStepCount <= nextIntraStepCount;
|
//$display( "Trace Prediction: intraProcessStep");
|
//$display( "Trace Prediction: intraProcessStep");
|
endrule
|
endrule
|
|
|
|
|
|
|
interface Client mem_client_intra;
|
interface Client mem_client_intra;
|
interface Get request = fifoToGet(intraMemReqQ);
|
interface Get request = fifoToGet(intraMemReqQ);
|
interface Put response = fifoToPut(intraMemRespQ);
|
interface Put response = fifoToPut(intraMemRespQ);
|
endinterface
|
endinterface
|
interface Client mem_client_inter;
|
interface Client mem_client_inter;
|
interface Get request = fifoToGet(interMemReqQ);
|
interface Get request = fifoToGet(interMemReqQ);
|
interface Put response = fifoToPut(interMemRespQ);
|
interface Put response = fifoToPut(interMemRespQ);
|
endinterface
|
endinterface
|
|
|
interface Client mem_client_buffer;
|
interface Client mem_client_buffer_luma;
|
interface Get request;
|
interface Get request;
|
method ActionValue#(InterpolatorLoadReq) get();
|
method ActionValue#(InterpolatorLoadReq) get();
|
InterpolatorLoadReq req <- interpolator.mem_client.request.get();
|
$display("PARDEBLOCK: Pulling Luma memory request from interpolator");
|
if(req matches tagged IPLoadLuma .data)
|
interpolator_luma.mem_request_deq;
|
begin
|
return interpolator_luma.mem_request_first;
|
memReqTypeFIFO.enq(Luma);
|
endmethod
|
end
|
endinterface
|
else if(req matches tagged IPLoadChroma .data)
|
|
begin
|
interface Put response;
|
memReqTypeFIFO.enq(Chroma);
|
method Action put(InterpolatorLoadResp resp);
|
end
|
interpolator_luma.mem_client_resp.put(resp);
|
return req;
|
endmethod
|
|
endinterface
|
|
endinterface
|
|
|
|
interface Client mem_client_buffer_chroma;
|
|
interface Get request;
|
|
method ActionValue#(InterpolatorLoadReq) get();
|
|
$display("PARDEBLOCK: Pulling Chroma memory request from interpolator");
|
|
interpolator_chroma.mem_request_deq;
|
|
return interpolator_chroma.mem_request_first;
|
endmethod
|
endmethod
|
endinterface
|
endinterface
|
|
|
interface Put response;
|
interface Put response;
|
method Action put(InterpolatorLoadResp resp);
|
method Action put(InterpolatorLoadResp resp);
|
memReqTypeFIFO.deq();
|
interpolator_chroma.mem_client_resp.put(resp);
|
interpolator.mem_client.response.put(resp);
|
|
endmethod
|
endmethod
|
endinterface
|
endinterface
|
endinterface
|
endinterface
|
|
|
interface Put ioin = fifoToPut(infifo);
|
interface Put ioin = fifoToPut(infifo);
|
interface Put ioin_InverseTrans = fifoToPut(infifo_ITB);
|
interface Put ioin_InverseTrans = fifoToPut(infifo_ITB);
|
interface Get iooutchroma = fifoToGet(outfifoluma);
|
interface Get iooutchroma = fifoToGet(outfifochroma);
|
interface Get iooutluma = fifoToGet(outfifochroma);
|
interface Get iooutluma = fifoToGet(outfifoluma);
|
|
|
endmodule
|
endmodule
|
|
|
endpackage
|
endpackage
|