// The MIT License
|
// The MIT License
|
|
|
// Copyright (c) 2006-2007 Massachusetts Institute of Technology
|
// Copyright (c) 2006-2007 Massachusetts Institute of Technology
|
|
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
// of this software and associated documentation files (the "Software"), to deal
|
// of this software and associated documentation files (the "Software"), to deal
|
// in the Software without restriction, including without limitation the rights
|
// in the Software without restriction, including without limitation the rights
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
// copies of the Software, and to permit persons to whom the Software is
|
// copies of the Software, and to permit persons to whom the Software is
|
// furnished to do so, subject to the following conditions:
|
// furnished to do so, subject to the following conditions:
|
|
|
// The above copyright notice and this permission notice shall be included in
|
// The above copyright notice and this permission notice shall be included in
|
// all copies or substantial portions of the Software.
|
// all copies or substantial portions of the Software.
|
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
// THE SOFTWARE.
|
// THE SOFTWARE.
|
//**********************************************************************
|
//**********************************************************************
|
// Prediction
|
// Prediction
|
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
//
|
//
|
//
|
//
|
|
|
package mkPrediction;
|
package mkPrediction;
|
|
|
import H264Types::*;
|
import H264Types::*;
|
|
|
import IPrediction::*;
|
import IPrediction::*;
|
import IInterpolator::*;
|
import IInterpolator::*;
|
import mkInterpolator::*;
|
import mkInterpolator::*;
|
import FIFO::*;
|
import FIFO::*;
|
import FIFOF::*;
|
import FIFOF::*;
|
import Vector::*;
|
import Vector::*;
|
|
|
import Connectable::*;
|
import Connectable::*;
|
import GetPut::*;
|
import GetPut::*;
|
import ClientServer::*;
|
import ClientServer::*;
|
|
|
|
|
//-----------------------------------------------------------
|
//-----------------------------------------------------------
|
// Local Datatypes
|
// Local Datatypes
|
//-----------------------------------------------------------
|
//-----------------------------------------------------------
|
|
|
typedef union tagged
|
typedef union tagged
|
{
|
{
|
void Intra; //Intra non-4x4
|
void Intra; //Intra non-4x4
|
void Intra4x4;
|
void Intra4x4;
|
void Inter;
|
void Inter;
|
}
|
}
|
OutState deriving(Eq,Bits);
|
OutState deriving(Eq,Bits);
|
|
|
typedef union tagged
|
typedef union tagged
|
{
|
{
|
void Start; //not working on anything in particular
|
void Start; //not working on anything in particular
|
void Intra16x16;
|
void Intra16x16;
|
void Intra4x4;
|
void Intra4x4;
|
void IntraPCM;
|
void IntraPCM;
|
}
|
}
|
IntraState deriving(Eq,Bits);
|
IntraState deriving(Eq,Bits);
|
|
|
typedef union tagged
|
typedef union tagged
|
{
|
{
|
void Start; //not working on anything in particular
|
void Start; //not working on anything in particular
|
void InterP16x16;
|
void InterP16x16;
|
void InterP16x8;
|
void InterP16x8;
|
void InterP8x16;
|
void InterP8x16;
|
void InterP8x8;
|
void InterP8x8;
|
void InterP8x8ref0;
|
void InterP8x8ref0;
|
void InterPskip;
|
void InterPskip;
|
}
|
}
|
InterState deriving(Eq,Bits);
|
InterState deriving(Eq,Bits);
|
|
|
typedef union tagged
|
typedef union tagged
|
{
|
{
|
Bit#(1) NotInter;//0 for not available, 1 for intra-coded
|
Bit#(1) NotInter;//0 for not available, 1 for intra-coded
|
struct {Bit#(4) refIdx; Bit#(14) mvhor; Bit#(12) mvver; Bit#(1) nonZeroTransCoeff;} BlockMv;
|
struct {Bit#(4) refIdx; Bit#(14) mvhor; Bit#(12) mvver; Bit#(1) nonZeroTransCoeff;} BlockMv;
|
}
|
}
|
InterBlockMv deriving(Eq,Bits);
|
InterBlockMv deriving(Eq,Bits);
|
|
|
typedef union tagged
|
typedef union tagged
|
{
|
{
|
void SkipMB;
|
void SkipMB;
|
void NonSkipMB;
|
void NonSkipMB;
|
void Intra4x4;
|
void Intra4x4;
|
void Intra4x4PlusChroma;
|
void Intra4x4PlusChroma;
|
}
|
}
|
NextOutput deriving(Eq,Bits);
|
NextOutput deriving(Eq,Bits);
|
|
|
|
|
|
|
//-----------------------------------------------------------
|
//-----------------------------------------------------------
|
// Helper functions
|
// Helper functions
|
|
|
function Bit#(8) intra4x4SelectTop( Bit#(72) valVector, Bit#(4) idx );
|
function Bit#(8) intra4x4SelectTop( Bit#(72) valVector, Bit#(4) idx );
|
case(idx)
|
case(idx)
|
0: return valVector[15:8];
|
0: return valVector[15:8];
|
1: return valVector[23:16];
|
1: return valVector[23:16];
|
2: return valVector[31:24];
|
2: return valVector[31:24];
|
3: return valVector[39:32];
|
3: return valVector[39:32];
|
4: return valVector[47:40];
|
4: return valVector[47:40];
|
5: return valVector[55:48];
|
5: return valVector[55:48];
|
6: return valVector[63:56];
|
6: return valVector[63:56];
|
7: return valVector[71:64];
|
7: return valVector[71:64];
|
default: return valVector[7:0];
|
default: return valVector[7:0];
|
endcase
|
endcase
|
endfunction
|
endfunction
|
|
|
function Bit#(8) intra4x4SelectLeft( Bit#(40) valVector, Bit#(3) idx );
|
function Bit#(8) intra4x4SelectLeft( Bit#(40) valVector, Bit#(3) idx );
|
case(idx)
|
case(idx)
|
0: return valVector[15:8];
|
0: return valVector[15:8];
|
1: return valVector[23:16];
|
1: return valVector[23:16];
|
2: return valVector[31:24];
|
2: return valVector[31:24];
|
3: return valVector[39:32];
|
3: return valVector[39:32];
|
default: return valVector[7:0];
|
default: return valVector[7:0];
|
endcase
|
endcase
|
endfunction
|
endfunction
|
|
|
function Bit#(8) select32to8( Bit#(32) valVector, Bit#(2) idx );
|
function Bit#(8) select32to8( Bit#(32) valVector, Bit#(2) idx );
|
case(idx)
|
case(idx)
|
0: return valVector[7:0];
|
0: return valVector[7:0];
|
1: return valVector[15:8];
|
1: return valVector[15:8];
|
2: return valVector[23:16];
|
2: return valVector[23:16];
|
3: return valVector[31:24];
|
3: return valVector[31:24];
|
endcase
|
endcase
|
endfunction
|
endfunction
|
|
|
function Bit#(8) select16to8( Bit#(16) valVector, Bit#(1) idx );
|
function Bit#(8) select16to8( Bit#(16) valVector, Bit#(1) idx );
|
case(idx)
|
case(idx)
|
0: return valVector[7:0];
|
0: return valVector[7:0];
|
1: return valVector[15:8];
|
1: return valVector[15:8];
|
endcase
|
endcase
|
endfunction
|
endfunction
|
|
|
function Bool absDiffGEFour14( Bit#(14) val1, Bit#(14) val2 );
|
function Bool absDiffGEFour14( Bit#(14) val1, Bit#(14) val2 );
|
Int#(15) int1 = unpack(signExtend(val1));
|
Int#(15) int1 = unpack(signExtend(val1));
|
Int#(15) int2 = unpack(signExtend(val2));
|
Int#(15) int2 = unpack(signExtend(val2));
|
if(int1>=int2)
|
if(int1>=int2)
|
return (int1 >= (int2+4));
|
return (int1 >= (int2+4));
|
else
|
else
|
return (int2 >= (int1+4));
|
return (int2 >= (int1+4));
|
endfunction
|
endfunction
|
|
|
function Bool absDiffGEFour12( Bit#(12) val1, Bit#(12) val2 );
|
function Bool absDiffGEFour12( Bit#(12) val1, Bit#(12) val2 );
|
Int#(13) int1 = unpack(signExtend(val1));
|
Int#(13) int1 = unpack(signExtend(val1));
|
Int#(13) int2 = unpack(signExtend(val2));
|
Int#(13) int2 = unpack(signExtend(val2));
|
if(int1>=int2)
|
if(int1>=int2)
|
return (int1 >= (int2+4));
|
return (int1 >= (int2+4));
|
else
|
else
|
return (int2 >= (int1+4));
|
return (int2 >= (int1+4));
|
endfunction
|
endfunction
|
|
|
|
|
//-----------------------------------------------------------
|
//-----------------------------------------------------------
|
// Prediction Module
|
// Prediction Module
|
//-----------------------------------------------------------
|
//-----------------------------------------------------------
|
|
|
|
|
(* synthesize *)
|
(* synthesize *)
|
module mkPrediction( IPrediction );
|
module mkPrediction( IPrediction );
|
|
|
//Common state
|
//Common state
|
FIFO#(EntropyDecOT) infifo <- mkSizedFIFO(prediction_infifo_size);
|
FIFO#(EntropyDecOT) infifo <- mkSizedFIFO(prediction_infifo_size);
|
FIFO#(InverseTransOT) infifo_ITB <- mkSizedFIFO(prediction_infifo_ITB_size);
|
FIFO#(InverseTransOT) infifo_ITB <- mkSizedFIFO(prediction_infifo_ITB_size);
|
FIFO#(EntropyDecOT) outfifochroma <- mkFIFO;
|
FIFO#(EntropyDecOT) outfifochroma <- mkFIFO;
|
FIFO#(EntropyDecOT) outfifoluma <- mkFIFO;
|
FIFO#(EntropyDecOT) outfifoluma <- mkFIFO;
|
Reg#(Bool) passFlag <- mkReg(True);
|
Reg#(Bool) passFlag <- mkReg(True);
|
Reg#(Bit#(4)) blockNum <- mkReg(0);
|
Reg#(Bit#(4)) blockNum <- mkReg(0);
|
Reg#(Bit#(4)) pixelNum <- mkReg(0);
|
Reg#(Bit#(4)) pixelNum <- mkReg(0);
|
|
|
Reg#(Bit#(PicWidthSz)) picWidth <- mkReg(maxPicWidthInMB);
|
Reg#(Bit#(PicWidthSz)) picWidth <- mkReg(maxPicWidthInMB);
|
Reg#(Bit#(PicHeightSz)) picHeight <- mkReg(0);
|
Reg#(Bit#(PicHeightSz)) picHeight <- mkReg(0);
|
Reg#(Bit#(PicAreaSz)) firstMb <- mkReg(0);
|
Reg#(Bit#(PicAreaSz)) firstMb <- mkReg(0);
|
Reg#(Bit#(PicAreaSz)) currMb <- mkReg(0);
|
Reg#(Bit#(PicAreaSz)) currMb <- mkReg(0);
|
Reg#(Bit#(PicAreaSz)) currMbHor <- mkReg(0);//horizontal position of currMb
|
Reg#(Bit#(PicAreaSz)) currMbHor <- mkReg(0);//horizontal position of currMb
|
Reg#(Bit#(PicHeightSz)) currMbVer <- mkReg(0);//vertical position of currMb
|
Reg#(Bit#(PicHeightSz)) currMbVer <- mkReg(0);//vertical position of currMb
|
|
|
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();
|
FIFO#(MemReq#(TAdd#(PicWidthSz,2),32)) interMemReqQ <- mkFIFO;
|
FIFO#(MemReq#(TAdd#(PicWidthSz,2),32)) interMemReqQ <- mkFIFO;
|
|
|
Reg#(MemReq#(TAdd#(PicWidthSz,2),32)) interMemReqQdelay <- mkRegU();
|
Reg#(MemReq#(TAdd#(PicWidthSz,2),32)) interMemReqQdelay <- mkRegU();
|
FIFO#(MemResp#(32)) interMemRespQ <- mkFIFO;
|
FIFO#(MemResp#(32)) interMemRespQ <- mkFIFO;
|
Reg#(Bit#(3)) interReqCount <- mkReg(0);
|
Reg#(Bit#(3)) interReqCount <- mkReg(0);
|
Reg#(Bit#(3)) interRespCount <- mkReg(0);
|
Reg#(Bit#(3)) interRespCount <- mkReg(0);
|
|
|
Reg#(Bit#(2)) interStepCount <- mkReg(0);
|
Reg#(Bit#(2)) interStepCount <- mkReg(0);
|
Reg#(Bit#(2)) interMbPartNum <- mkReg(0);
|
Reg#(Bit#(2)) interMbPartNum <- mkReg(0);
|
Reg#(Bit#(2)) interSubMbPartNum <- mkReg(0);
|
Reg#(Bit#(2)) interSubMbPartNum <- mkReg(0);
|
Reg#(Bit#(2)) interPassingCount <- mkReg(0);
|
Reg#(Bit#(2)) interPassingCount <- mkReg(0);
|
Reg#(Vector#(4,Bit#(4))) interRefIdxVector <- mkRegU();
|
Reg#(Vector#(4,Bit#(4))) interRefIdxVector <- mkRegU();
|
Reg#(Vector#(4,Bit#(2))) interSubMbTypeVector <- mkRegU();
|
Reg#(Vector#(4,Bit#(2))) interSubMbTypeVector <- mkRegU();
|
RFile1#(Bit#(4),Tuple2#(Bit#(14),Bit#(12))) interMvFile <- mkRFile1Full();
|
RFile1#(Bit#(4),Tuple2#(Bit#(14),Bit#(12))) interMvFile <- mkRFile1Full();
|
Reg#(Bit#(15)) interMvDiffTemp <- mkReg(0);
|
Reg#(Bit#(15)) interMvDiffTemp <- mkReg(0);
|
FIFO#(Tuple2#(Bit#(15),Bit#(13))) interMvDiff <- mkFIFO;
|
FIFO#(Tuple2#(Bit#(15),Bit#(13))) interMvDiff <- mkFIFO;
|
Reg#(Bit#(5)) interNewestMv <- mkReg(0);
|
Reg#(Bit#(5)) interNewestMv <- mkReg(0);
|
|
|
|
|
// Registers for pipelining the interStage rule
|
// Registers for pipelining the interStage rule
|
|
|
Reg#(Bit#(3)) partWidthR <- mkRegU();
|
Reg#(Bit#(3)) partWidthR <- mkRegU();
|
Reg#(Bit#(3)) partHeightR <- mkRegU();
|
Reg#(Bit#(3)) partHeightR <- mkRegU();
|
Reg#(Bit#(3)) numPartR <- mkRegU();
|
Reg#(Bit#(3)) numPartR <- mkRegU();
|
Reg#(Bit#(3)) numSubPartR <- mkRegU();
|
Reg#(Bit#(3)) numSubPartR <- mkRegU();
|
Reg#(Bit#(2)) subMbTypeR <- mkRegU();
|
Reg#(Bit#(2)) subMbTypeR <- mkRegU();
|
Reg#(Bool) calcmvR <- mkRegU();
|
Reg#(Bool) calcmvR <- mkRegU();
|
Reg#(Bool) leftmvR <- mkRegU();
|
Reg#(Bool) leftmvR <- mkRegU();
|
Reg#(Bit#(4)) refIndexR <- mkRegU();
|
Reg#(Bit#(4)) refIndexR <- mkRegU();
|
Reg#(Vector#(3,InterBlockMv)) blockABCR <- mkRegU();
|
Reg#(Vector#(3,InterBlockMv)) blockABCR <- mkRegU();
|
Reg#(Bit#(14)) mvhorfinalR <- mkRegU();
|
Reg#(Bit#(14)) mvhorfinalR <- mkRegU();
|
Reg#(Bit#(12)) mvverfinalR <- mkRegU();
|
Reg#(Bit#(12)) mvverfinalR <- mkRegU();
|
Reg#(Bit#(5)) interNewestMvNextR <- mkRegU();
|
Reg#(Bit#(5)) interNewestMvNextR <- mkRegU();
|
|
|
|
|
Reg#(Bit#(2)) interIPStepCount <- mkReg(0);
|
Reg#(Bit#(2)) interIPStepCount <- mkReg(0);
|
Reg#(Bit#(2)) interIPMbPartNum <- mkReg(0);
|
Reg#(Bit#(2)) interIPMbPartNum <- mkReg(0);
|
Reg#(Bit#(2)) interIPSubMbPartNum <- mkReg(0);
|
Reg#(Bit#(2)) interIPSubMbPartNum <- mkReg(0);
|
|
|
Reg#(Bit#(PicWidthSz)) interCurrMbDiff <- mkReg(0);
|
Reg#(Bit#(PicWidthSz)) interCurrMbDiff <- mkReg(0);
|
|
|
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
|
Reg#(Bit#(1)) ppsconstrained_intra_pred_flag <- mkReg(0);
|
Reg#(Bit#(1)) ppsconstrained_intra_pred_flag <- mkReg(0);
|
Reg#(Vector#(4,Bit#(40))) intraLeftVal <- mkRegU();
|
Reg#(Vector#(4,Bit#(40))) intraLeftVal <- mkRegU();
|
Reg#(Vector#(9,Bit#(8))) intraLeftValChroma0 <- mkRegU();
|
Reg#(Vector#(9,Bit#(8))) intraLeftValChroma0 <- mkRegU();
|
Reg#(Vector#(9,Bit#(8))) intraLeftValChroma1 <- mkRegU();
|
Reg#(Vector#(9,Bit#(8))) intraLeftValChroma1 <- mkRegU();
|
Reg#(Vector#(5,Bit#(32))) intraTopVal <- mkRegU();
|
Reg#(Vector#(5,Bit#(32))) intraTopVal <- mkRegU();
|
Reg#(Vector#(4,Bit#(16))) intraTopValChroma0 <- mkRegU();
|
Reg#(Vector#(4,Bit#(16))) intraTopValChroma0 <- mkRegU();
|
Reg#(Vector#(4,Bit#(16))) intraTopValChroma1 <- mkRegU();
|
Reg#(Vector#(4,Bit#(16))) intraTopValChroma1 <- mkRegU();
|
Reg#(Bit#(32)) intraLeftValNext <- mkReg(0);
|
Reg#(Bit#(32)) intraLeftValNext <- mkReg(0);
|
Reg#(Bit#(2)) intra16x16_pred_mode <- mkReg(0);
|
Reg#(Bit#(2)) intra16x16_pred_mode <- mkReg(0);
|
FIFO#(Bit#(4)) rem_intra4x4_pred_mode <- mkSizedFIFO(16);
|
FIFO#(Bit#(4)) rem_intra4x4_pred_mode <- mkSizedFIFO(16);
|
FIFO#(Bit#(2)) intra_chroma_pred_mode <- mkFIFO;
|
FIFO#(Bit#(2)) intra_chroma_pred_mode <- mkFIFO;
|
Reg#(Bit#(4)) cur_intra4x4_pred_mode <- mkReg(0);
|
Reg#(Bit#(4)) cur_intra4x4_pred_mode <- mkReg(0);
|
Reg#(Bit#(1)) intraChromaTopAvailable <- mkReg(0);
|
Reg#(Bit#(1)) intraChromaTopAvailable <- mkReg(0);
|
Reg#(Bit#(1)) intraChromaLeftAvailable <- mkReg(0);
|
Reg#(Bit#(1)) intraChromaLeftAvailable <- mkReg(0);
|
|
|
Reg#(Bit#(3)) intraReqCount <- mkReg(0);
|
Reg#(Bit#(3)) intraReqCount <- mkReg(0);
|
Reg#(Bit#(3)) intraRespCount <- mkReg(0);
|
Reg#(Bit#(3)) intraRespCount <- mkReg(0);
|
Reg#(Bit#(4)) intraStepCount <- mkReg(0);
|
Reg#(Bit#(4)) intraStepCount <- mkReg(0);
|
Reg#(Bit#(13)) intraSumA <- mkReg(0);
|
Reg#(Bit#(13)) intraSumA <- mkReg(0);
|
Reg#(Bit#(15)) intraSumB <- mkReg(0);
|
Reg#(Bit#(15)) intraSumB <- mkReg(0);
|
Reg#(Bit#(15)) intraSumC <- mkReg(0);
|
Reg#(Bit#(15)) intraSumC <- mkReg(0);
|
|
|
Reg#(Vector#(4,Bit#(8))) intraPredVector <- mkRegU();
|
Reg#(Vector#(4,Bit#(8))) intraPredVector <- mkRegU();
|
|
|
//-----------------------------------------------------------
|
//-----------------------------------------------------------
|
// Rules
|
// Rules
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
// rule stateMonitor ( True );
|
// rule stateMonitor ( True );
|
// if(predictedfifo.notEmpty())
|
// if(predictedfifo.notEmpty())
|
// $display( "TRACE Prediction: stateMonitor predictedfifo.first() %0d", predictedfifo.first());////////////////////
|
// $display( "TRACE Prediction: stateMonitor predictedfifo.first() %0d", predictedfifo.first());////////////////////
|
// if(infifo.first() matches tagged ITBresidual .xdata)
|
// if(infifo.first() matches tagged ITBresidual .xdata)
|
// $display( "TRACE Prediction: stateMonitor infifo.first() %0d", xdata);////////////////////
|
// $display( "TRACE Prediction: stateMonitor infifo.first() %0d", xdata);////////////////////
|
// 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
|
tagged NewUnit . xdata :
|
tagged NewUnit . xdata :
|
begin
|
begin
|
infifo.deq();
|
infifo.deq();
|
outfifoluma.enq(infifo.first());
|
outfifoluma.enq(infifo.first());
|
outfifochroma.enq(infifo.first());
|
outfifochroma.enq(infifo.first());
|
$display("ccl4newunit");
|
$display("ccl4newunit");
|
$display("ccl4rbspbyte %h", xdata);
|
$display("ccl4rbspbyte %h", xdata);
|
end
|
end
|
tagged SPSpic_width_in_mbs .xdata :
|
tagged SPSpic_width_in_mbs .xdata :
|
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;
|
end
|
end
|
tagged SHfirst_mb_in_slice .xdata :
|
tagged SHfirst_mb_in_slice .xdata :
|
begin
|
begin
|
infifo.deq();
|
infifo.deq();
|
outfifoluma.enq(infifo.first());
|
outfifoluma.enq(infifo.first());
|
outfifochroma.enq(infifo.first());
|
outfifochroma.enq(infifo.first());
|
firstMb <= xdata;
|
firstMb <= xdata;
|
currMb <= xdata;
|
currMb <= xdata;
|
currMbHor <= xdata;
|
currMbHor <= xdata;
|
currMbVer <= 0;
|
currMbVer <= 0;
|
intra4x4typeLeft <= replicate(15);
|
intra4x4typeLeft <= replicate(15);
|
interTopLeftVal <= replicate(tagged NotInter 0);
|
interTopLeftVal <= replicate(tagged NotInter 0);
|
if(xdata==0)
|
if(xdata==0)
|
interLeftVal <= replicate(tagged NotInter 0);
|
interLeftVal <= replicate(tagged NotInter 0);
|
outFirstQPFlag <= True;
|
outFirstQPFlag <= True;
|
end
|
end
|
tagged SDmb_skip_run .xdata : passFlag <= False;
|
tagged SDmb_skip_run .xdata : passFlag <= False;
|
tagged SDMmbtype .xdata : passFlag <= False;
|
tagged SDMmbtype .xdata : passFlag <= False;
|
tagged EndOfFile :
|
tagged EndOfFile :
|
begin
|
begin
|
infifo.deq();
|
infifo.deq();
|
outfifochroma.enq(infifo.first());
|
outfifochroma.enq(infifo.first());
|
outfifoluma.enq(infifo.first());
|
outfifoluma.enq(infifo.first());
|
$display( "INFO Prediction: EndOfFile reached" );
|
$display( "INFO Prediction: EndOfFile reached" );
|
//$finish(0);////////////////////////////////
|
//$finish(0);////////////////////////////////
|
end
|
end
|
default:
|
default:
|
begin
|
begin
|
infifo.deq();
|
infifo.deq();
|
outfifoluma.enq(infifo.first());
|
outfifoluma.enq(infifo.first());
|
outfifochroma.enq(infifo.first());
|
outfifochroma.enq(infifo.first());
|
end
|
end
|
endcase
|
endcase
|
endrule
|
endrule
|
|
|
|
|
rule inputing ( !passFlag );
|
rule inputing ( !passFlag );
|
$display( "Trace Prediction: inputing infifo packed %h", pack(infifo.first()));
|
$display( "Trace Prediction: inputing infifo packed %h", pack(infifo.first()));
|
case (infifo.first()) matches
|
case (infifo.first()) matches
|
tagged SDmb_skip_run .xdata :
|
tagged SDmb_skip_run .xdata :
|
begin
|
begin
|
if(interstate==Start && intrastate==Start)
|
if(interstate==Start && intrastate==Start)
|
begin
|
begin
|
if(interPskipCount < xdata)
|
if(interPskipCount < xdata)
|
begin
|
begin
|
if(!outstatefifo.notEmpty() || interCurrMbDiff
|
if(!outstatefifo.notEmpty() || interCurrMbDiff
|
begin
|
begin
|
$display( "Trace Prediction: passing SDmb_skip_run %0d", xdata);
|
$display( "Trace Prediction: passing SDmb_skip_run %0d", xdata);
|
outstatefifo.enq(Inter);
|
outstatefifo.enq(Inter);
|
interstate <= InterPskip;
|
interstate <= InterPskip;
|
interReqCount <= 1;
|
interReqCount <= 1;
|
interRespCount <= 1;
|
interRespCount <= 1;
|
intra4x4typeLeft <= replicate(14);
|
intra4x4typeLeft <= replicate(14);
|
intra4x4typeTop <= replicate(14);
|
intra4x4typeTop <= replicate(14);
|
interTopLeftVal <= update(interTopLeftVal , 0, (tagged NotInter 0));
|
interTopLeftVal <= update(interTopLeftVal , 0, (tagged NotInter 0));
|
interTopVal <= replicate(tagged NotInter 0);
|
interTopVal <= replicate(tagged NotInter 0);
|
interPskipCount <= interPskipCount+1;
|
interPskipCount <= interPskipCount+1;
|
interNewestMv <= 0;
|
interNewestMv <= 0;
|
interRefIdxVector <= replicate(0);
|
interRefIdxVector <= replicate(0);
|
interCurrMbDiff <= interCurrMbDiff+1;
|
interCurrMbDiff <= interCurrMbDiff+1;
|
nextoutputfifo.enq(SkipMB);
|
nextoutputfifo.enq(SkipMB);
|
end
|
end
|
else
|
else
|
donotfire.doNotFire();
|
donotfire.doNotFire();
|
end
|
end
|
else
|
else
|
begin
|
begin
|
$display( "Trace Prediction: passing no SDmb_skip_run");
|
$display( "Trace Prediction: passing no SDmb_skip_run");
|
interPskipCount <= 0;
|
interPskipCount <= 0;
|
infifo.deq();
|
infifo.deq();
|
end
|
end
|
end
|
end
|
else
|
else
|
donotfire.doNotFire();
|
donotfire.doNotFire();
|
end
|
end
|
tagged SDMmbtype .xdata :
|
tagged SDMmbtype .xdata :
|
begin
|
begin
|
if(interstate==Start && intrastate==Start)//not necessary (just need to keep inter from feeding predictedfifo or change intra state until intrastate==Start)
|
if(interstate==Start && intrastate==Start)//not necessary (just need to keep inter from feeding predictedfifo or change intra state until intrastate==Start)
|
begin
|
begin
|
infifo.deq();
|
infifo.deq();
|
$display( "INFO Prediction: SDMmbtype %0d", xdata);
|
$display( "INFO Prediction: SDMmbtype %0d", xdata);
|
if(mbPartPredMode(xdata,0)==Intra_16x16)
|
if(mbPartPredMode(xdata,0)==Intra_16x16)
|
begin
|
begin
|
if(!outstatefifo.notEmpty())
|
if(!outstatefifo.notEmpty())
|
begin
|
begin
|
outstatefifo.enq(Intra);
|
outstatefifo.enq(Intra);
|
intrastate <= Intra16x16;
|
intrastate <= Intra16x16;
|
if(xdata matches tagged I_16x16 {intra16x16PredMode:.tempv1, codedBlockPatternChroma:.tempv2, codedBlockPatternLuma:.tempv3})
|
if(xdata matches tagged I_16x16 {intra16x16PredMode:.tempv1, codedBlockPatternChroma:.tempv2, codedBlockPatternLuma:.tempv3})
|
intra16x16_pred_mode <= tempv1;
|
intra16x16_pred_mode <= tempv1;
|
else
|
else
|
$display( "ERROR Prediction: MacroblockLayer 5 sdmmbtype not I_16x16" );
|
$display( "ERROR Prediction: MacroblockLayer 5 sdmmbtype not I_16x16" );
|
intraReqCount <= 1;
|
intraReqCount <= 1;
|
intraRespCount <= 1;
|
intraRespCount <= 1;
|
interTopLeftVal <= replicate(tagged NotInter 1);
|
interTopLeftVal <= replicate(tagged NotInter 1);
|
interLeftVal <= replicate(tagged NotInter 1);
|
interLeftVal <= replicate(tagged NotInter 1);
|
interTopVal <= replicate(tagged NotInter 1);
|
interTopVal <= replicate(tagged NotInter 1);
|
end
|
end
|
else
|
else
|
donotfire.doNotFire();
|
donotfire.doNotFire();
|
end
|
end
|
else if(xdata==I_NxN)
|
else if(xdata==I_NxN)
|
begin
|
begin
|
if(!outstatefifo.notEmpty())
|
if(!outstatefifo.notEmpty())
|
begin
|
begin
|
outstatefifo.enq(Intra4x4);
|
outstatefifo.enq(Intra4x4);
|
intrastate <= Intra4x4;
|
intrastate <= Intra4x4;
|
intraReqCount <= 1;
|
intraReqCount <= 1;
|
intraRespCount <= 1;
|
intraRespCount <= 1;
|
interTopLeftVal <= replicate(tagged NotInter 1);
|
interTopLeftVal <= replicate(tagged NotInter 1);
|
interLeftVal <= replicate(tagged NotInter 1);
|
interLeftVal <= replicate(tagged NotInter 1);
|
interTopVal <= replicate(tagged NotInter 1);
|
interTopVal <= replicate(tagged NotInter 1);
|
end
|
end
|
else
|
else
|
donotfire.doNotFire();
|
donotfire.doNotFire();
|
end
|
end
|
else if(xdata==I_PCM)
|
else if(xdata==I_PCM)
|
begin
|
begin
|
$display( "ERROR Prediction: I_PCM not implemented yet");
|
$display( "ERROR Prediction: I_PCM not implemented yet");
|
$finish;////////////////////////////////////////////////////////////////////////////////////////
|
$finish;////////////////////////////////////////////////////////////////////////////////////////
|
intra4x4typeLeft <= replicate(13);
|
intra4x4typeLeft <= replicate(13);
|
intra4x4typeTop <= replicate(13);
|
intra4x4typeTop <= replicate(13);
|
interTopLeftVal <= replicate(tagged NotInter 1);
|
interTopLeftVal <= replicate(tagged NotInter 1);
|
interLeftVal <= replicate(tagged NotInter 1);
|
interLeftVal <= replicate(tagged NotInter 1);
|
interTopVal <= replicate(tagged NotInter 1);
|
interTopVal <= replicate(tagged NotInter 1);
|
end
|
end
|
else
|
else
|
begin
|
begin
|
if(!outstatefifo.notEmpty() || interCurrMbDiff
|
if(!outstatefifo.notEmpty() || interCurrMbDiff
|
begin
|
begin
|
outstatefifo.enq(Inter);
|
outstatefifo.enq(Inter);
|
case(xdata)
|
case(xdata)
|
P_L0_16x16: interstate <= InterP16x16;
|
P_L0_16x16: interstate <= InterP16x16;
|
P_L0_L0_16x8: interstate <= InterP16x8;
|
P_L0_L0_16x8: interstate <= InterP16x8;
|
P_L0_L0_8x16: interstate <= InterP8x16;
|
P_L0_L0_8x16: interstate <= InterP8x16;
|
P_8x8: interstate <= InterP8x8;
|
P_8x8: interstate <= InterP8x8;
|
P_8x8ref0: interstate <= InterP8x8ref0;
|
P_8x8ref0: interstate <= InterP8x8ref0;
|
default: $display( "ERROR Prediction: passing SDMmbtype inter prediction unknown mbtype");
|
default: $display( "ERROR Prediction: passing SDMmbtype inter prediction unknown mbtype");
|
endcase
|
endcase
|
interReqCount <= 1;
|
interReqCount <= 1;
|
interRespCount <= 1;
|
interRespCount <= 1;
|
intra4x4typeLeft <= replicate(14);/////////////////////////////////////////////////////////////////////////////
|
intra4x4typeLeft <= replicate(14);/////////////////////////////////////////////////////////////////////////////
|
intra4x4typeTop <= replicate(14);
|
intra4x4typeTop <= replicate(14);
|
interTopLeftVal <= update(interTopLeftVal , 0, (tagged NotInter 0));
|
interTopLeftVal <= update(interTopLeftVal , 0, (tagged NotInter 0));
|
interTopVal <= replicate(tagged NotInter 0);
|
interTopVal <= replicate(tagged NotInter 0);
|
interNewestMv <= 0;
|
interNewestMv <= 0;
|
interRefIdxVector <= replicate(0);
|
interRefIdxVector <= replicate(0);
|
nextoutputfifo.enq(NonSkipMB);
|
nextoutputfifo.enq(NonSkipMB);
|
end
|
end
|
else
|
else
|
donotfire.doNotFire();
|
donotfire.doNotFire();
|
end
|
end
|
interCurrMbDiff <= interCurrMbDiff+1;
|
interCurrMbDiff <= interCurrMbDiff+1;
|
end
|
end
|
else
|
else
|
donotfire.doNotFire();
|
donotfire.doNotFire();
|
end
|
end
|
tagged SDMMrem_intra4x4_pred_mode .xdata :
|
tagged SDMMrem_intra4x4_pred_mode .xdata :
|
begin
|
begin
|
infifo.deq();
|
infifo.deq();
|
////outfifo.enq(infifo.first());
|
////outfifo.enq(infifo.first());
|
rem_intra4x4_pred_mode.enq(xdata);
|
rem_intra4x4_pred_mode.enq(xdata);
|
end
|
end
|
tagged SDMMintra_chroma_pred_mode .xdata :
|
tagged SDMMintra_chroma_pred_mode .xdata :
|
begin
|
begin
|
infifo.deq();
|
infifo.deq();
|
////outfifo.enq(infifo.first());
|
////outfifo.enq(infifo.first());
|
intra_chroma_pred_mode.enq(xdata);
|
intra_chroma_pred_mode.enq(xdata);
|
end
|
end
|
tagged SDMMref_idx_l0 .xdata :
|
tagged SDMMref_idx_l0 .xdata :
|
begin
|
begin
|
infifo.deq();
|
infifo.deq();
|
////outfifo.enq(infifo.first());
|
////outfifo.enq(infifo.first());
|
interRefIdxVector <= update(interRefIdxVector,interPassingCount,xdata[3:0]);
|
interRefIdxVector <= update(interRefIdxVector,interPassingCount,xdata[3:0]);
|
if(interstate==InterP16x16 || interPassingCount==1)
|
if(interstate==InterP16x16 || interPassingCount==1)
|
interPassingCount <= 0;
|
interPassingCount <= 0;
|
else
|
else
|
interPassingCount <= interPassingCount+1;
|
interPassingCount <= interPassingCount+1;
|
end
|
end
|
tagged SDMMmvd_l0 .xdata :
|
tagged SDMMmvd_l0 .xdata :
|
begin
|
begin
|
infifo.deq();
|
infifo.deq();
|
////outfifo.enq(infifo.first());
|
////outfifo.enq(infifo.first());
|
if(interPassingCount==1)
|
if(interPassingCount==1)
|
begin
|
begin
|
Bit#(13) interMvDiffTemp2 = truncate(xdata);
|
Bit#(13) interMvDiffTemp2 = truncate(xdata);
|
interMvDiff.enq(tuple2(interMvDiffTemp,interMvDiffTemp2));
|
interMvDiff.enq(tuple2(interMvDiffTemp,interMvDiffTemp2));
|
interPassingCount <= 0;
|
interPassingCount <= 0;
|
end
|
end
|
else
|
else
|
begin
|
begin
|
interMvDiffTemp <= truncate(xdata);
|
interMvDiffTemp <= truncate(xdata);
|
interPassingCount <= interPassingCount+1;
|
interPassingCount <= interPassingCount+1;
|
end
|
end
|
end
|
end
|
tagged SDMSsub_mb_type .xdata :
|
tagged SDMSsub_mb_type .xdata :
|
begin
|
begin
|
infifo.deq();
|
infifo.deq();
|
////outfifo.enq(infifo.first());
|
////outfifo.enq(infifo.first());
|
interSubMbTypeVector <= update(interSubMbTypeVector,interPassingCount,xdata);
|
interSubMbTypeVector <= update(interSubMbTypeVector,interPassingCount,xdata);
|
interPassingCount <= interPassingCount+1;
|
interPassingCount <= interPassingCount+1;
|
end
|
end
|
tagged SDMSref_idx_l0 .xdata :
|
tagged SDMSref_idx_l0 .xdata :
|
begin
|
begin
|
infifo.deq();
|
infifo.deq();
|
////outfifo.enq(infifo.first());
|
////outfifo.enq(infifo.first());
|
interRefIdxVector <= update(interRefIdxVector,interPassingCount,xdata[3:0]);
|
interRefIdxVector <= update(interRefIdxVector,interPassingCount,xdata[3:0]);
|
interPassingCount <= interPassingCount+1;
|
interPassingCount <= interPassingCount+1;
|
end
|
end
|
tagged SDMSmvd_l0 .xdata :
|
tagged SDMSmvd_l0 .xdata :
|
begin
|
begin
|
infifo.deq();
|
infifo.deq();
|
////outfifo.enq(infifo.first());
|
////outfifo.enq(infifo.first());
|
if(interPassingCount==1)
|
if(interPassingCount==1)
|
begin
|
begin
|
Bit#(13) interMvDiffTemp2 = truncate(xdata);
|
Bit#(13) interMvDiffTemp2 = truncate(xdata);
|
interMvDiff.enq(tuple2(interMvDiffTemp,interMvDiffTemp2));
|
interMvDiff.enq(tuple2(interMvDiffTemp,interMvDiffTemp2));
|
interPassingCount <= 0;
|
interPassingCount <= 0;
|
end
|
end
|
else
|
else
|
begin
|
begin
|
interMvDiffTemp <= truncate(xdata);
|
interMvDiffTemp <= truncate(xdata);
|
interPassingCount <= interPassingCount+1;
|
interPassingCount <= interPassingCount+1;
|
end
|
end
|
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
|
infifo_ITB.deq();
|
infifo_ITB.deq();
|
outfifoluma.enq(IBTmb_qp {qpy:xdata.qpy,qpc:xdata.qpc});
|
outfifoluma.enq(IBTmb_qp {qpy:xdata.qpy,qpc:xdata.qpc});
|
outfifochroma.enq(IBTmb_qp {qpy:xdata.qpy,qpc:xdata.qpc});
|
outfifochroma.enq(IBTmb_qp {qpy:xdata.qpy,qpc:xdata.qpc});
|
outFirstQPFlag <= False;
|
outFirstQPFlag <= False;
|
$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();
|
Bit#(2) tempHorBS = tpl_1(interBSfifo.first());
|
Bit#(2) tempHorBS = tpl_1(interBSfifo.first());
|
Bit#(2) tempVerBS = tpl_2(interBSfifo.first());
|
Bit#(2) tempVerBS = tpl_2(interBSfifo.first());
|
Bit#(3) horBS = (tempHorBS==3 ? 4 : (interLeftNonZeroTransCoeff[blockVer] ? 2 : zeroExtend(tempHorBS)));
|
Bit#(3) horBS = (tempHorBS==3 ? 4 : (interLeftNonZeroTransCoeff[blockVer] ? 2 : zeroExtend(tempHorBS)));
|
Bit#(3) verBS = (tempVerBS==3 ? 4 : (interTopNonZeroTransCoeff[blockHor]&&blockVer!=0 ? 2 : zeroExtend(tempVerBS)));
|
Bit#(3) verBS = (tempVerBS==3 ? 4 : (interTopNonZeroTransCoeff[blockHor]&&blockVer!=0 ? 2 : zeroExtend(tempVerBS)));
|
outfifoluma.enq(PBbS {bShor:horBS,bSver:verBS,blockNum: outBlockNum});
|
outfifoluma.enq(PBbS {bShor:horBS,bSver:verBS,blockNum: outBlockNum});
|
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});
|
outFirstQPFlag <= False;
|
outFirstQPFlag <= False;
|
$display( "Trace Prediction: outputing ITBmb_qp %h %h %h", outBlockNum, outPixelNum, xdata);
|
$display( "Trace Prediction: outputing ITBmb_qp %h %h %h", outBlockNum, outPixelNum, xdata);
|
end
|
end
|
tagged ITBresidual .xdata :
|
tagged ITBresidual .xdata :
|
begin
|
begin
|
if(interBSoutput && outChromaFlag==Luma && outPixelNum==0)
|
if(interBSoutput && outChromaFlag==Luma && outPixelNum==0)
|
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});
|
outfifochroma.enq(tagged PBbS {bShor:(blockHor==0 ? 4 : 3),bSver:(blockVer==0 ? 4 : 3),blockNum: outBlockNum});
|
outfifochroma.enq(tagged PBbS {bShor:(blockHor==0 ? 4 : 3),bSver:(blockVer==0 ? 4 : 3),blockNum: outBlockNum});
|
end
|
end
|
else
|
else
|
begin
|
begin
|
interBSfifo.deq();
|
interBSfifo.deq();
|
Bit#(2) tempHorBS = tpl_1(interBSfifo.first());
|
Bit#(2) tempHorBS = tpl_1(interBSfifo.first());
|
Bit#(2) tempVerBS = tpl_2(interBSfifo.first());
|
Bit#(2) tempVerBS = tpl_2(interBSfifo.first());
|
Bit#(3) horBS = (tempHorBS==3 ? 4 : 2);
|
Bit#(3) horBS = (tempHorBS==3 ? 4 : 2);
|
Bit#(3) verBS = (tempVerBS==3 ? 4 : 2);
|
Bit#(3) verBS = (tempVerBS==3 ? 4 : 2);
|
outfifoluma.enq(tagged PBbS {bShor:horBS,bSver:verBS,blockNum: outBlockNum});
|
outfifoluma.enq(tagged PBbS {bShor:horBS,bSver:verBS,blockNum: outBlockNum});
|
outfifochroma.enq(tagged PBbS {bShor:horBS,bSver:verBS,blockNum: outBlockNum});
|
outfifochroma.enq(tagged PBbS {bShor:horBS,bSver:verBS,blockNum: outBlockNum});
|
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});
|
outfifochroma.enq(tagged PBbS {bShor:(blockHor==0 ? 4 : 3),bSver:(blockVer==0 ? 4 : 3),blockNum: outBlockNum});
|
outfifochroma.enq(tagged PBbS {bShor:(blockHor==0 ? 4 : 3),bSver:(blockVer==0 ? 4 : 3),blockNum: outBlockNum});
|
end
|
end
|
else
|
else
|
begin
|
begin
|
interBSfifo.deq();
|
interBSfifo.deq();
|
Bit#(2) tempHorBS = tpl_1(interBSfifo.first());
|
Bit#(2) tempHorBS = tpl_1(interBSfifo.first());
|
Bit#(2) tempVerBS = tpl_2(interBSfifo.first());
|
Bit#(2) tempVerBS = tpl_2(interBSfifo.first());
|
Bit#(3) horBS = (tempHorBS==3 ? 4 : (interLeftNonZeroTransCoeff[blockVer] ? 2 : zeroExtend(tempHorBS)));
|
Bit#(3) horBS = (tempHorBS==3 ? 4 : (interLeftNonZeroTransCoeff[blockVer] ? 2 : zeroExtend(tempHorBS)));
|
Bit#(3) verBS = (tempVerBS==3 ? 4 : (interTopNonZeroTransCoeff[blockHor]&&blockVer!=0 ? 2 : zeroExtend(tempVerBS)));
|
Bit#(3) verBS = (tempVerBS==3 ? 4 : (interTopNonZeroTransCoeff[blockHor]&&blockVer!=0 ? 2 : zeroExtend(tempVerBS)));
|
outfifoluma.enq(tagged PBbS {bShor:horBS,bSver:verBS,blockNum: outBlockNum});
|
outfifoluma.enq(tagged PBbS {bShor:horBS,bSver:verBS,blockNum: outBlockNum});
|
outfifochroma.enq(tagged PBbS {bShor:horBS,bSver:verBS,blockNum: outBlockNum});
|
outfifochroma.enq(tagged PBbS {bShor:horBS,bSver:verBS,blockNum: outBlockNum});
|
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
|
|
|
if(outputFlag == 1)
|
if(outputFlag == 1)
|
begin
|
begin
|
$display("ccl4PBoutput %0d", outputVector[0]);
|
$display("ccl4PBoutput %0d", outputVector[0]);
|
$display("ccl4PBoutput %0d", outputVector[1]);
|
$display("ccl4PBoutput %0d", outputVector[1]);
|
$display("ccl4PBoutput %0d", outputVector[2]);
|
$display("ccl4PBoutput %0d", outputVector[2]);
|
$display("ccl4PBoutput %0d", outputVector[3]);
|
$display("ccl4PBoutput %0d", outputVector[3]);
|
|
|
if(outBlockNum==0 && pixelVer==0 && outChromaFlag==Luma && currMb!=firstMb && picWidth>1)
|
if(outBlockNum==0 && pixelVer==0 && outChromaFlag==Luma && currMb!=firstMb && picWidth>1)
|
begin
|
begin
|
intraMemReqQ.enq(intraMemReqQdelay);
|
intraMemReqQ.enq(intraMemReqQdelay);
|
interMemReqQ.enq(interMemReqQdelay);
|
interMemReqQ.enq(interMemReqQdelay);
|
//$display( "TRACE Prediction: passing storing addr data");//////////////////
|
//$display( "TRACE Prediction: passing storing addr data");//////////////////
|
end
|
end
|
|
|
if(blockHor==3 || (blockHor[0]==1 && outChromaFlag==Chroma) || (outstatefifo.first()==Intra4x4 && outChromaFlag==Luma))
|
if(blockHor==3 || (blockHor[0]==1 && outChromaFlag==Chroma) || (outstatefifo.first()==Intra4x4 && outChromaFlag==Luma))
|
begin
|
begin
|
if(outChromaFlag==Luma)
|
if(outChromaFlag==Luma)
|
begin
|
begin
|
Bit#(32) intraLeftValNextTemp = intraLeftValNext;
|
Bit#(32) intraLeftValNextTemp = intraLeftValNext;
|
if(totalVer==0 || (outstatefifo.first()==Intra4x4 && pixelVer==0))
|
if(totalVer==0 || (outstatefifo.first()==Intra4x4 && pixelVer==0))
|
begin
|
begin
|
Bit#(32) tempValSet = select(intraTopVal,zeroExtend(blockHor));
|
Bit#(32) tempValSet = select(intraTopVal,zeroExtend(blockHor));
|
intraLeftValNextTemp = zeroExtend(tempValSet[31:24]);
|
intraLeftValNextTemp = zeroExtend(tempValSet[31:24]);
|
end
|
end
|
case(pixelVer)
|
case(pixelVer)
|
0:intraLeftValNext <= {intraLeftValNextTemp[31:16],outputVector[3],intraLeftValNextTemp[7:0]};
|
0:intraLeftValNext <= {intraLeftValNextTemp[31:16],outputVector[3],intraLeftValNextTemp[7:0]};
|
1:intraLeftValNext <= {intraLeftValNextTemp[31:24],outputVector[3],intraLeftValNextTemp[15:0]};
|
1:intraLeftValNext <= {intraLeftValNextTemp[31:24],outputVector[3],intraLeftValNextTemp[15:0]};
|
2:intraLeftValNext <= {outputVector[3],intraLeftValNextTemp[23:0]};
|
2:intraLeftValNext <= {outputVector[3],intraLeftValNextTemp[23:0]};
|
3:
|
3:
|
begin
|
begin
|
intraLeftVal <= update(intraLeftVal,blockVer,{outputVector[3],intraLeftValNextTemp});
|
intraLeftVal <= update(intraLeftVal,blockVer,{outputVector[3],intraLeftValNextTemp});
|
intraLeftValNext <= zeroExtend(outputVector[3]);
|
intraLeftValNext <= zeroExtend(outputVector[3]);
|
if(outstatefifo.first()==Intra4x4)
|
if(outstatefifo.first()==Intra4x4)
|
intra4x4typeLeft <= update(intra4x4typeLeft,blockVer,cur_intra4x4_pred_mode);
|
intra4x4typeLeft <= update(intra4x4typeLeft,blockVer,cur_intra4x4_pred_mode);
|
else if(outstatefifo.first()==Intra)
|
else if(outstatefifo.first()==Intra)
|
intra4x4typeLeft <= update(intra4x4typeLeft,blockVer,13);
|
intra4x4typeLeft <= update(intra4x4typeLeft,blockVer,13);
|
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]);
|
end
|
end
|
end
|
end
|
|
|
if(pixelVer==3 && (blockVer==3 || (blockVer[0]==1 && outChromaFlag==Chroma) || (outstatefifo.first()==Intra4x4 && outChromaFlag==Luma)))
|
if(pixelVer==3 && (blockVer==3 || (blockVer[0]==1 && outChromaFlag==Chroma) || (outstatefifo.first()==Intra4x4 && outChromaFlag==Luma)))
|
begin
|
begin
|
if(outChromaFlag==Luma)
|
if(outChromaFlag==Luma)
|
begin
|
begin
|
intraTopVal <= update(intraTopVal,zeroExtend(blockHor),{outputVector[3],outputVector[2],outputVector[1],outputVector[0]});
|
intraTopVal <= update(intraTopVal,zeroExtend(blockHor),{outputVector[3],outputVector[2],outputVector[1],outputVector[0]});
|
if(outstatefifo.first()==Intra4x4)
|
if(outstatefifo.first()==Intra4x4)
|
intra4x4typeTop <= update(intra4x4typeTop,blockHor,cur_intra4x4_pred_mode);
|
intra4x4typeTop <= update(intra4x4typeTop,blockHor,cur_intra4x4_pred_mode);
|
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]};
|
intraTopValChroma0Next[{blockHor[0],1'b1}] = {outputVector[3],outputVector[2]};
|
intraTopValChroma0Next[{blockHor[0],1'b1}] = {outputVector[3],outputVector[2]};
|
intraTopValChroma0 <= intraTopValChroma0Next;
|
intraTopValChroma0 <= intraTopValChroma0Next;
|
end
|
end
|
else
|
else
|
begin
|
begin
|
Vector#(4,Bit#(16)) intraTopValChroma1Next = intraTopValChroma1;
|
Vector#(4,Bit#(16)) intraTopValChroma1Next = intraTopValChroma1;
|
intraTopValChroma1Next[{blockHor[0],1'b0}] = {outputVector[1],outputVector[0]};
|
intraTopValChroma1Next[{blockHor[0],1'b0}] = {outputVector[1],outputVector[0]};
|
intraTopValChroma1Next[{blockHor[0],1'b1}] = {outputVector[3],outputVector[2]};
|
intraTopValChroma1Next[{blockHor[0],1'b1}] = {outputVector[3],outputVector[2]};
|
intraTopValChroma1 <= intraTopValChroma1Next;
|
intraTopValChroma1 <= intraTopValChroma1Next;
|
end
|
end
|
end
|
end
|
end
|
end
|
|
|
if(outChromaFlag==Chroma && outBlockNum==7)
|
if(outChromaFlag==Chroma && outBlockNum==7)
|
begin
|
begin
|
Bit#(PicWidthSz) tempStoreAddr = truncate(currMbHor);
|
Bit#(PicWidthSz) tempStoreAddr = truncate(currMbHor);
|
InterBlockMv outBlockMv = interOutBlockMvfifo.first();
|
InterBlockMv outBlockMv = interOutBlockMvfifo.first();
|
if(outBlockMv matches tagged BlockMv .bdata)
|
if(outBlockMv matches tagged BlockMv .bdata)
|
begin
|
begin
|
outBlockMv = (BlockMv {refIdx:bdata.refIdx,mvhor:bdata.mvhor,mvver:bdata.mvver,nonZeroTransCoeff:(interTopNonZeroTransCoeff[pixelVer]?1:0)});
|
outBlockMv = (BlockMv {refIdx:bdata.refIdx,mvhor:bdata.mvhor,mvver:bdata.mvver,nonZeroTransCoeff:(interTopNonZeroTransCoeff[pixelVer]?1:0)});
|
interOutBlockMvfifo.deq();
|
interOutBlockMvfifo.deq();
|
end
|
end
|
else if(pixelVer==3)
|
else if(pixelVer==3)
|
interOutBlockMvfifo.deq();
|
interOutBlockMvfifo.deq();
|
if(pixelVer==3 && picWidth>1)
|
if(pixelVer==3 && picWidth>1)
|
interMemReqQdelay <= StoreReq {addr:{tempStoreAddr,pixelVer},data:pack(outBlockMv)};
|
interMemReqQdelay <= StoreReq {addr:{tempStoreAddr,pixelVer},data:pack(outBlockMv)};
|
else
|
else
|
interMemReqQ.enq(tagged StoreReq {addr:{tempStoreAddr,pixelVer},data:pack(outBlockMv)});
|
interMemReqQ.enq(tagged StoreReq {addr:{tempStoreAddr,pixelVer},data:pack(outBlockMv)});
|
if(pixelVer>0)
|
if(pixelVer>0)
|
begin
|
begin
|
Bit#(4) intra4x4typeTopStore = ((outstatefifo.first()==Inter) ? 14 : ((outstatefifo.first()!=Intra4x4) ? 13: intra4x4typeTop[(pixelVer-1)]));
|
Bit#(4) intra4x4typeTopStore = ((outstatefifo.first()==Inter) ? 14 : ((outstatefifo.first()!=Intra4x4) ? 13: intra4x4typeTop[(pixelVer-1)]));
|
Bit#(32) intraTopValStore = intraTopVal[(pixelVer-1)];
|
Bit#(32) intraTopValStore = intraTopVal[(pixelVer-1)];
|
Bit#(16) intraTopValChroma0Store = intraTopValChroma0[(pixelVer-1)];
|
Bit#(16) intraTopValChroma0Store = intraTopValChroma0[(pixelVer-1)];
|
Bit#(16) intraTopValChroma1Store = (pixelVer<3 ? intraTopValChroma1[(pixelVer-1)] : {outputVector[1],outputVector[0]});
|
Bit#(16) intraTopValChroma1Store = (pixelVer<3 ? intraTopValChroma1[(pixelVer-1)] : {outputVector[1],outputVector[0]});
|
Bit#(68) intraStore = {intra4x4typeTopStore,intraTopValChroma1Store,intraTopValChroma0Store,intraTopValStore};
|
Bit#(68) intraStore = {intra4x4typeTopStore,intraTopValChroma1Store,intraTopValChroma0Store,intraTopValStore};
|
intraMemReqQ.enq(tagged StoreReq {addr:{tempStoreAddr,(pixelVer-1)},data:intraStore});
|
intraMemReqQ.enq(tagged StoreReq {addr:{tempStoreAddr,(pixelVer-1)},data:intraStore});
|
if(pixelVer==3)
|
if(pixelVer==3)
|
begin
|
begin
|
intra4x4typeTopStore = ((outstatefifo.first()==Inter) ? 14 : ((outstatefifo.first()!=Intra4x4) ? 13: intra4x4typeTop[3]));
|
intra4x4typeTopStore = ((outstatefifo.first()==Inter) ? 14 : ((outstatefifo.first()!=Intra4x4) ? 13: intra4x4typeTop[3]));
|
intraTopValStore = intraTopVal[3];
|
intraTopValStore = intraTopVal[3];
|
intraTopValChroma0Store = intraTopValChroma0[3];
|
intraTopValChroma0Store = intraTopValChroma0[3];
|
intraTopValChroma1Store = {outputVector[3],outputVector[2]};
|
intraTopValChroma1Store = {outputVector[3],outputVector[2]};
|
intraStore = {intra4x4typeTopStore,intraTopValChroma1Store,intraTopValChroma0Store,intraTopValStore};
|
intraStore = {intra4x4typeTopStore,intraTopValChroma1Store,intraTopValChroma0Store,intraTopValStore};
|
intraMemReqQdelay <= StoreReq {addr:{tempStoreAddr,2'b11},data:intraStore};
|
intraMemReqQdelay <= StoreReq {addr:{tempStoreAddr,2'b11},data:intraStore};
|
end
|
end
|
end
|
end
|
end
|
end
|
outPixelNum <= outPixelNum+4;
|
outPixelNum <= outPixelNum+4;
|
if(outPixelNum == 12)
|
if(outPixelNum == 12)
|
begin
|
begin
|
if(outChromaFlag==Luma)
|
if(outChromaFlag==Luma)
|
begin
|
begin
|
outBlockNum <= outBlockNum+1;
|
outBlockNum <= outBlockNum+1;
|
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;
|
currMb <= currMb+1;
|
currMb <= currMb+1;
|
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);
|
currMbVer <= currMbVer + 8;
|
currMbVer <= currMbVer + 8;
|
end
|
end
|
else
|
else
|
begin
|
begin
|
currMbHor <= currMbHor - temp;
|
currMbHor <= currMbHor - temp;
|
currMbVer <= currMbVer + 1;
|
currMbVer <= currMbVer + 1;
|
end
|
end
|
//$display( "Trace Prediction: currMbHorUpdate %h %h", currMbHor, currMbVer);
|
//$display( "Trace Prediction: currMbHorUpdate %h %h", currMbHor, currMbVer);
|
endrule
|
endrule
|
|
|
|
|
// inter prediction rules
|
// inter prediction rules
|
|
|
rule interSendReq ( interReqCount>0 && currMbHor
|
rule interSendReq ( interReqCount>0 && currMbHor
|
Bit#(PicAreaSz) currMbHorTemp = currMbHor+zeroExtend(interCurrMbDiff)-1;
|
Bit#(PicAreaSz) currMbHorTemp = currMbHor+zeroExtend(interCurrMbDiff)-1;
|
Bit#(PicAreaSz) currMbTemp = currMb+zeroExtend(interCurrMbDiff)-1;
|
Bit#(PicAreaSz) currMbTemp = currMb+zeroExtend(interCurrMbDiff)-1;
|
if( currMbHorTemp >= zeroExtend(picWidth) )
|
if( currMbHorTemp >= zeroExtend(picWidth) )
|
currMbHorTemp = currMbHorTemp-zeroExtend(picWidth);
|
currMbHorTemp = currMbHorTemp-zeroExtend(picWidth);
|
Bit#(PicWidthSz) temp2 = truncate(currMbHorTemp);
|
Bit#(PicWidthSz) temp2 = truncate(currMbHorTemp);
|
Bit#(TAdd#(PicWidthSz,2)) temp = 0;
|
Bit#(TAdd#(PicWidthSz,2)) temp = 0;
|
Bool noMoreReq = False;
|
Bool noMoreReq = False;
|
if( currMbTemp < zeroExtend(picWidth) )
|
if( currMbTemp < zeroExtend(picWidth) )
|
noMoreReq = True;
|
noMoreReq = True;
|
else
|
else
|
begin
|
begin
|
if(interReqCount<5)
|
if(interReqCount<5)
|
begin
|
begin
|
Bit#(2) temp3 = truncate(interReqCount-1);
|
Bit#(2) temp3 = truncate(interReqCount-1);
|
temp = {temp2,temp3};
|
temp = {temp2,temp3};
|
end
|
end
|
else if(interReqCount==5)
|
else if(interReqCount==5)
|
begin
|
begin
|
if((currMbHorTemp+1)
|
if((currMbHorTemp+1)
|
temp = {(temp2+1),2'b00};
|
temp = {(temp2+1),2'b00};
|
else if(currMbHorTemp>0 && currMbTemp-firstMb>zeroExtend(picWidth))
|
else if(currMbHorTemp>0 && currMbTemp-firstMb>zeroExtend(picWidth))
|
temp = {(temp2-1),2'b11};
|
temp = {(temp2-1),2'b11};
|
else
|
else
|
noMoreReq = True;
|
noMoreReq = True;
|
end
|
end
|
else if(interReqCount==6)
|
else if(interReqCount==6)
|
begin
|
begin
|
if((currMbHorTemp+1)0 && currMbTemp-firstMb>zeroExtend(picWidth))
|
if((currMbHorTemp+1)0 && currMbTemp-firstMb>zeroExtend(picWidth))
|
temp = {(temp2-1),2'b11};
|
temp = {(temp2-1),2'b11};
|
else
|
else
|
noMoreReq = True;
|
noMoreReq = True;
|
end
|
end
|
else
|
else
|
noMoreReq = True;
|
noMoreReq = True;
|
end
|
end
|
if(!noMoreReq)
|
if(!noMoreReq)
|
begin
|
begin
|
interMemReqQ.enq(tagged LoadReq temp);
|
interMemReqQ.enq(tagged LoadReq temp);
|
interReqCount <= interReqCount+1;
|
interReqCount <= interReqCount+1;
|
//$display( "TRACE Prediction: interSendReq addr %0d",temp);///////////////////////
|
//$display( "TRACE Prediction: interSendReq addr %0d",temp);///////////////////////
|
end
|
end
|
else
|
else
|
interReqCount <= 0;
|
interReqCount <= 0;
|
$display( "Trace Prediction: interSendReq %h %h %h", interstate, interReqCount, temp);
|
$display( "Trace Prediction: interSendReq %h %h %h", interstate, interReqCount, temp);
|
endrule
|
endrule
|
|
|
|
|
rule interReceiveNoResp ( interRespCount>0 && currMbHor
|
rule interReceiveNoResp ( interRespCount>0 && currMbHor
|
Bit#(PicAreaSz) currMbHorTemp = currMbHor+zeroExtend(interCurrMbDiff)-1;
|
Bit#(PicAreaSz) currMbHorTemp = currMbHor+zeroExtend(interCurrMbDiff)-1;
|
if( currMbHorTemp >= zeroExtend(picWidth) )
|
if( currMbHorTemp >= zeroExtend(picWidth) )
|
currMbHorTemp = currMbHorTemp-zeroExtend(picWidth);
|
currMbHorTemp = currMbHorTemp-zeroExtend(picWidth);
|
interRespCount <= 0;
|
interRespCount <= 0;
|
interStepCount <= 1;
|
interStepCount <= 1;
|
interIPStepCount <= 1;
|
interIPStepCount <= 1;
|
if(currMbHorTemp == 0)
|
if(currMbHorTemp == 0)
|
begin
|
begin
|
interLeftVal <= replicate(tagged NotInter 0);
|
interLeftVal <= replicate(tagged NotInter 0);
|
interTopLeftVal <= replicate(tagged NotInter 0);
|
interTopLeftVal <= replicate(tagged NotInter 0);
|
end
|
end
|
$display( "Trace Prediction: interReceiveNoResp %h %h", interstate, interRespCount);
|
$display( "Trace Prediction: interReceiveNoResp %h %h", interstate, interRespCount);
|
endrule
|
endrule
|
|
|
|
|
rule interReceiveResp ( interRespCount>0 && interRespCount<7 && currMbHor
|
rule interReceiveResp ( interRespCount>0 && interRespCount<7 && currMbHor
|
Bit#(PicAreaSz) currMbHorTemp = currMbHor+zeroExtend(interCurrMbDiff)-1;
|
Bit#(PicAreaSz) currMbHorTemp = currMbHor+zeroExtend(interCurrMbDiff)-1;
|
Bit#(PicAreaSz) currMbTemp = currMb+zeroExtend(interCurrMbDiff)-1;
|
Bit#(PicAreaSz) currMbTemp = currMb+zeroExtend(interCurrMbDiff)-1;
|
if( currMbHorTemp >= zeroExtend(picWidth) )
|
if( currMbHorTemp >= zeroExtend(picWidth) )
|
currMbHorTemp = currMbHorTemp-zeroExtend(picWidth);
|
currMbHorTemp = currMbHorTemp-zeroExtend(picWidth);
|
Bool noMoreResp = False;
|
Bool noMoreResp = False;
|
Bit#(2) temp2bit = 0;
|
Bit#(2) temp2bit = 0;
|
InterBlockMv unpackedData = unpack(data);
|
InterBlockMv unpackedData = unpack(data);
|
Vector#(5,InterBlockMv) interTopValNext = interTopVal;
|
Vector#(5,InterBlockMv) interTopValNext = interTopVal;
|
Vector#(4,InterBlockMv) interTopLeftValNext = interTopLeftVal;
|
Vector#(4,InterBlockMv) interTopLeftValNext = interTopLeftVal;
|
if(interRespCount<5)
|
if(interRespCount<5)
|
begin
|
begin
|
temp2bit = truncate(interRespCount-1);
|
temp2bit = truncate(interRespCount-1);
|
interTopValNext[temp2bit] = unpackedData;
|
interTopValNext[temp2bit] = unpackedData;
|
if((interRespCount==4 || (interRespCount==1 && (interstate==InterPskip || interstate==InterP16x16 || interstate==InterP16x8)))
|
if((interRespCount==4 || (interRespCount==1 && (interstate==InterPskip || interstate==InterP16x16 || interstate==InterP16x8)))
|
&& (!((currMbHorTemp+1)0 && currMbTemp-firstMb>zeroExtend(picWidth))))
|
&& (!((currMbHorTemp+1)0 && currMbTemp-firstMb>zeroExtend(picWidth))))
|
noMoreResp = True;
|
noMoreResp = True;
|
end
|
end
|
else if(interRespCount==5)
|
else if(interRespCount==5)
|
begin
|
begin
|
if((currMbHorTemp+1)
|
if((currMbHorTemp+1)
|
begin
|
begin
|
interTopValNext[4] = unpackedData;
|
interTopValNext[4] = unpackedData;
|
if(!(currMbHorTemp>0 && currMbTemp-firstMb>zeroExtend(picWidth)))
|
if(!(currMbHorTemp>0 && currMbTemp-firstMb>zeroExtend(picWidth)))
|
noMoreResp = True;
|
noMoreResp = True;
|
end
|
end
|
else
|
else
|
begin
|
begin
|
interTopLeftValNext[0] = unpackedData;
|
interTopLeftValNext[0] = unpackedData;
|
noMoreResp = True;
|
noMoreResp = True;
|
end
|
end
|
end
|
end
|
else
|
else
|
begin
|
begin
|
interTopLeftValNext[0] = unpackedData;
|
interTopLeftValNext[0] = unpackedData;
|
noMoreResp = True;
|
noMoreResp = True;
|
end
|
end
|
interMemRespQ.deq();
|
interMemRespQ.deq();
|
//$display( "TRACE Prediction: interReceiveResp data %h",data);///////////////////////
|
//$display( "TRACE Prediction: interReceiveResp data %h",data);///////////////////////
|
if(!noMoreResp)
|
if(!noMoreResp)
|
interRespCount <= interRespCount+1;
|
interRespCount <= interRespCount+1;
|
else
|
else
|
begin
|
begin
|
interRespCount <= 0;
|
interRespCount <= 0;
|
interStepCount <= 1;
|
interStepCount <= 1;
|
interIPStepCount <= 1;
|
interIPStepCount <= 1;
|
if(currMbHorTemp == 0)
|
if(currMbHorTemp == 0)
|
begin
|
begin
|
interLeftVal <= replicate(tagged NotInter 0);
|
interLeftVal <= replicate(tagged NotInter 0);
|
interTopLeftValNext = replicate(tagged NotInter 0);
|
interTopLeftValNext = replicate(tagged NotInter 0);
|
end
|
end
|
end
|
end
|
interTopVal <= interTopValNext;
|
interTopVal <= interTopValNext;
|
interTopLeftVal <= interTopLeftValNext;
|
interTopLeftVal <= interTopLeftValNext;
|
$display( "Trace Prediction: interReceiveResp %h %h %h", interstate, interRespCount, data);
|
$display( "Trace Prediction: interReceiveResp %h %h %h", interstate, interRespCount, data);
|
endrule
|
endrule
|
|
|
|
|
rule interProcessStep ( interStepCount>0 && currMbHor
|
rule interProcessStep ( interStepCount>0 && currMbHor
|
Bit#(PicAreaSz) currMbTemp = currMb+zeroExtend(interCurrMbDiff)-1;
|
Bit#(PicAreaSz) currMbTemp = currMb+zeroExtend(interCurrMbDiff)-1;
|
Bit#(2) blockHor = {interMbPartNum[0],interSubMbPartNum[0]};
|
Bit#(2) blockHor = {interMbPartNum[0],interSubMbPartNum[0]};
|
Bit#(2) blockVer = {interMbPartNum[1],interSubMbPartNum[1]};
|
Bit#(2) blockVer = {interMbPartNum[1],interSubMbPartNum[1]};
|
|
|
if(interStepCount == 1)
|
if(interStepCount == 1)
|
begin
|
begin
|
Bit#(3) partWidth = 0;
|
Bit#(3) partWidth = 0;
|
Bit#(3) partHeight = 0;
|
Bit#(3) partHeight = 0;
|
Bit#(3) numPart = 1;
|
Bit#(3) numPart = 1;
|
Bit#(3) numSubPart = 1;
|
Bit#(3) numSubPart = 1;
|
Bit#(2) subMbType = 0;
|
Bit#(2) subMbType = 0;
|
Bool noBlockC = False;
|
Bool noBlockC = False;
|
Bool calcmv = False;
|
Bool calcmv = False;
|
Bool leftmv = False;
|
Bool leftmv = False;
|
if(interstate==InterPskip || interstate==InterP16x16)
|
if(interstate==InterPskip || interstate==InterP16x16)
|
begin
|
begin
|
partWidth = 4;
|
partWidth = 4;
|
partHeight = 4;
|
partHeight = 4;
|
numPart = 1;
|
numPart = 1;
|
calcmv = (interMbPartNum==0 && interSubMbPartNum==0);
|
calcmv = (interMbPartNum==0 && interSubMbPartNum==0);
|
leftmv = (blockHor>0);
|
leftmv = (blockHor>0);
|
end
|
end
|
else if(interstate==InterP16x8)
|
else if(interstate==InterP16x8)
|
begin
|
begin
|
partWidth = 4;
|
partWidth = 4;
|
partHeight = 2;
|
partHeight = 2;
|
numPart = 2;
|
numPart = 2;
|
if(interMbPartNum==2)
|
if(interMbPartNum==2)
|
noBlockC = True;
|
noBlockC = True;
|
calcmv = (interMbPartNum[0]==0 && interSubMbPartNum==0);
|
calcmv = (interMbPartNum[0]==0 && interSubMbPartNum==0);
|
leftmv = (blockHor>0);
|
leftmv = (blockHor>0);
|
end
|
end
|
else if(interstate==InterP8x16)
|
else if(interstate==InterP8x16)
|
begin
|
begin
|
partWidth = 2;
|
partWidth = 2;
|
partHeight = 4;
|
partHeight = 4;
|
numPart = 2;
|
numPart = 2;
|
calcmv = (interMbPartNum[1]==0 && interSubMbPartNum==0);
|
calcmv = (interMbPartNum[1]==0 && interSubMbPartNum==0);
|
leftmv = !(blockVer>0);
|
leftmv = !(blockVer>0);
|
end
|
end
|
else if(interstate==InterP8x8 || interstate==InterP8x8ref0)
|
else if(interstate==InterP8x8 || interstate==InterP8x8ref0)
|
begin
|
begin
|
numPart = 4;
|
numPart = 4;
|
subMbType = interSubMbTypeVector[interMbPartNum];
|
subMbType = interSubMbTypeVector[interMbPartNum];
|
numSubPart = numSubMbPart(subMbType);
|
numSubPart = numSubMbPart(subMbType);
|
case(subMbType)
|
case(subMbType)
|
0:
|
0:
|
begin
|
begin
|
partWidth = 2;
|
partWidth = 2;
|
partHeight = 2;
|
partHeight = 2;
|
if(interMbPartNum==3)
|
if(interMbPartNum==3)
|
noBlockC = True;
|
noBlockC = True;
|
calcmv = (interSubMbPartNum==0);
|
calcmv = (interSubMbPartNum==0);
|
leftmv = (blockHor[0]>0);
|
leftmv = (blockHor[0]>0);
|
end
|
end
|
1:
|
1:
|
begin
|
begin
|
partWidth = 2;
|
partWidth = 2;
|
partHeight = 1;
|
partHeight = 1;
|
if(interSubMbPartNum==2)
|
if(interSubMbPartNum==2)
|
noBlockC = True;
|
noBlockC = True;
|
calcmv = (interSubMbPartNum[0]==0);
|
calcmv = (interSubMbPartNum[0]==0);
|
leftmv = True;
|
leftmv = True;
|
end
|
end
|
2:
|
2:
|
begin
|
begin
|
partWidth = 1;
|
partWidth = 1;
|
partHeight = 2;
|
partHeight = 2;
|
calcmv = (interSubMbPartNum[1]==0);
|
calcmv = (interSubMbPartNum[1]==0);
|
leftmv = False;
|
leftmv = False;
|
end
|
end
|
3:
|
3:
|
begin
|
begin
|
partWidth = 1;
|
partWidth = 1;
|
partHeight = 1;
|
partHeight = 1;
|
if(interSubMbPartNum==3)
|
if(interSubMbPartNum==3)
|
noBlockC = True;
|
noBlockC = True;
|
calcmv = True;
|
calcmv = True;
|
end
|
end
|
endcase
|
endcase
|
end
|
end
|
else
|
else
|
$display( "ERROR Prediction: interProcessStep unexpected interstate");
|
$display( "ERROR Prediction: interProcessStep unexpected interstate");
|
|
|
Bit#(4) refIndex = ((interstate==InterPskip||interstate==InterP8x8ref0) ? 0 : interRefIdxVector[interMbPartNum]);
|
Bit#(4) refIndex = ((interstate==InterPskip||interstate==InterP8x8ref0) ? 0 : interRefIdxVector[interMbPartNum]);
|
Vector#(3,InterBlockMv) blockABC = replicate(tagged NotInter 0);
|
Vector#(3,InterBlockMv) blockABC = replicate(tagged NotInter 0);
|
if( currMbTemp-firstMb==0 && blockHor==0 )
|
if( currMbTemp-firstMb==0 && blockHor==0 )
|
blockABC[0] = (tagged NotInter 0);
|
blockABC[0] = (tagged NotInter 0);
|
else
|
else
|
blockABC[0] = interLeftVal[blockVer];
|
blockABC[0] = interLeftVal[blockVer];
|
if( currMbTemp-firstMb
|
if( currMbTemp-firstMb
|
blockABC[1] = (tagged NotInter 0);
|
blockABC[1] = (tagged NotInter 0);
|
else
|
else
|
blockABC[1] = interTopVal[blockHor];
|
blockABC[1] = interTopVal[blockHor];
|
blockABC[2] = interTopVal[{1'b0,blockHor}+partWidth];
|
blockABC[2] = interTopVal[{1'b0,blockHor}+partWidth];
|
if(noBlockC || blockABC[2]==(tagged NotInter 0))
|
if(noBlockC || blockABC[2]==(tagged NotInter 0))
|
blockABC[2] = interTopLeftVal[blockVer];
|
blockABC[2] = interTopLeftVal[blockVer];
|
partWidthR <= partWidth;
|
partWidthR <= partWidth;
|
partHeightR <= partHeight;
|
partHeightR <= partHeight;
|
numPartR <= numPart;
|
numPartR <= numPart;
|
numSubPartR <= numSubPart;
|
numSubPartR <= numSubPart;
|
subMbTypeR <= subMbType;
|
subMbTypeR <= subMbType;
|
calcmvR <= calcmv;
|
calcmvR <= calcmv;
|
leftmvR <= leftmv;
|
leftmvR <= leftmv;
|
refIndexR <= refIndex;
|
refIndexR <= refIndex;
|
blockABCR <= blockABC;
|
blockABCR <= blockABC;
|
interStepCount <= 2;
|
interStepCount <= 2;
|
end
|
end
|
else if(interStepCount==2)
|
else if(interStepCount==2)
|
begin
|
begin
|
Bit#(3) partWidth = partWidthR;
|
Bit#(3) partWidth = partWidthR;
|
Bit#(3) partHeight = partHeightR;
|
Bit#(3) partHeight = partHeightR;
|
Bit#(3) numPart = numPartR;
|
Bit#(3) numPart = numPartR;
|
Bit#(3) numSubPart = numSubPartR;
|
Bit#(3) numSubPart = numSubPartR;
|
Bit#(2) subMbType = subMbTypeR;
|
Bit#(2) subMbType = subMbTypeR;
|
Bool calcmv = calcmvR;
|
Bool calcmv = calcmvR;
|
Bool leftmv = leftmvR;
|
Bool leftmv = leftmvR;
|
Bit#(4) refIndex = refIndexR;
|
Bit#(4) refIndex = refIndexR;
|
Vector#(3,InterBlockMv) blockABC = blockABCR;
|
Vector#(3,InterBlockMv) blockABC = blockABCR;
|
Bit#(14) mvhorfinal = 0;
|
Bit#(14) mvhorfinal = 0;
|
Bit#(12) mvverfinal = 0;
|
Bit#(12) mvverfinal = 0;
|
Bit#(5) interNewestMvNext = 0;
|
Bit#(5) interNewestMvNext = 0;
|
if(calcmv)//motion vector caculation
|
if(calcmv)//motion vector caculation
|
begin
|
begin
|
Vector#(3,Int#(14)) mvhorABC = replicate(0);
|
Vector#(3,Int#(14)) mvhorABC = replicate(0);
|
Vector#(3,Int#(12)) mvverABC = replicate(0);
|
Vector#(3,Int#(12)) mvverABC = replicate(0);
|
Bit#(2) validCount = 0;
|
Bit#(2) validCount = 0;
|
Bit#(14) mvhorPred = 0;
|
Bit#(14) mvhorPred = 0;
|
Bit#(12) mvverPred = 0;
|
Bit#(12) mvverPred = 0;
|
for(Integer ii=0; ii<3; ii=ii+1)
|
for(Integer ii=0; ii<3; ii=ii+1)
|
begin
|
begin
|
if(blockABC[ii] matches tagged BlockMv .xdata)
|
if(blockABC[ii] matches tagged BlockMv .xdata)
|
begin
|
begin
|
mvhorABC[ii] = unpack(xdata.mvhor);
|
mvhorABC[ii] = unpack(xdata.mvhor);
|
mvverABC[ii] = unpack(xdata.mvver);
|
mvverABC[ii] = unpack(xdata.mvver);
|
if(xdata.refIdx == refIndex)
|
if(xdata.refIdx == refIndex)
|
begin
|
begin
|
validCount = validCount+1;
|
validCount = validCount+1;
|
mvhorPred = xdata.mvhor;
|
mvhorPred = xdata.mvhor;
|
mvverPred = xdata.mvver;
|
mvverPred = xdata.mvver;
|
end
|
end
|
end
|
end
|
else
|
else
|
begin
|
begin
|
mvhorABC[ii] = 0;
|
mvhorABC[ii] = 0;
|
mvverABC[ii] = 0;
|
mvverABC[ii] = 0;
|
end
|
end
|
end
|
end
|
if(validCount != 1)//median
|
if(validCount != 1)//median
|
begin
|
begin
|
if(mvhorABC[0]>mvhorABC[1] && mvhorABC[0]>mvhorABC[2])
|
if(mvhorABC[0]>mvhorABC[1] && mvhorABC[0]>mvhorABC[2])
|
mvhorPred = pack((mvhorABC[1]>mvhorABC[2]) ? mvhorABC[1] : mvhorABC[2]);
|
mvhorPred = pack((mvhorABC[1]>mvhorABC[2]) ? mvhorABC[1] : mvhorABC[2]);
|
else if(mvhorABC[0]
|
else if(mvhorABC[0]
|
mvhorPred = pack((mvhorABC[1]
|
mvhorPred = pack((mvhorABC[1]
|
else
|
else
|
mvhorPred = pack(mvhorABC[0]);
|
mvhorPred = pack(mvhorABC[0]);
|
if(mvverABC[0]>mvverABC[1] && mvverABC[0]>mvverABC[2])
|
if(mvverABC[0]>mvverABC[1] && mvverABC[0]>mvverABC[2])
|
mvverPred = pack((mvverABC[1]>mvverABC[2]) ? mvverABC[1] : mvverABC[2]);
|
mvverPred = pack((mvverABC[1]>mvverABC[2]) ? mvverABC[1] : mvverABC[2]);
|
else if(mvverABC[0]
|
else if(mvverABC[0]
|
mvverPred = pack((mvverABC[1]
|
mvverPred = pack((mvverABC[1]
|
else
|
else
|
mvverPred = pack(mvverABC[0]);
|
mvverPred = pack(mvverABC[0]);
|
end
|
end
|
if(interstate==InterPskip)
|
if(interstate==InterPskip)
|
begin
|
begin
|
for(Integer ii=0; ii<2; ii=ii+1)
|
for(Integer ii=0; ii<2; ii=ii+1)
|
begin
|
begin
|
if(blockABC[ii] matches tagged BlockMv .xdata)
|
if(blockABC[ii] matches tagged BlockMv .xdata)
|
begin
|
begin
|
if(xdata.refIdx==0 && xdata.mvhor==0 && xdata.mvver==0)
|
if(xdata.refIdx==0 && xdata.mvhor==0 && xdata.mvver==0)
|
begin
|
begin
|
mvhorPred = 0;
|
mvhorPred = 0;
|
mvverPred = 0;
|
mvverPred = 0;
|
end
|
end
|
end
|
end
|
else if(blockABC[ii] matches tagged NotInter 0)
|
else if(blockABC[ii] matches tagged NotInter 0)
|
begin
|
begin
|
mvhorPred = 0;
|
mvhorPred = 0;
|
mvverPred = 0;
|
mvverPred = 0;
|
end
|
end
|
end
|
end
|
end
|
end
|
else if(interstate==InterP16x8 || interstate==InterP8x16)
|
else if(interstate==InterP16x8 || interstate==InterP8x16)
|
begin
|
begin
|
InterBlockMv blockCheck;
|
InterBlockMv blockCheck;
|
if(interstate==InterP16x8)
|
if(interstate==InterP16x8)
|
begin
|
begin
|
if(interMbPartNum==0)
|
if(interMbPartNum==0)
|
blockCheck = blockABC[1];
|
blockCheck = blockABC[1];
|
else
|
else
|
blockCheck = blockABC[0];
|
blockCheck = blockABC[0];
|
end
|
end
|
else
|
else
|
begin
|
begin
|
if(interMbPartNum==0)
|
if(interMbPartNum==0)
|
blockCheck = blockABC[0];
|
blockCheck = blockABC[0];
|
else
|
else
|
blockCheck = blockABC[2];
|
blockCheck = blockABC[2];
|
end
|
end
|
if(blockCheck matches tagged BlockMv .xdata &&& xdata.refIdx==refIndex)
|
if(blockCheck matches tagged BlockMv .xdata &&& xdata.refIdx==refIndex)
|
begin
|
begin
|
mvhorPred = xdata.mvhor;
|
mvhorPred = xdata.mvhor;
|
mvverPred = xdata.mvver;
|
mvverPred = xdata.mvver;
|
end
|
end
|
end
|
end
|
mvhorfinal = mvhorPred;
|
mvhorfinal = mvhorPred;
|
mvverfinal = mvverPred;
|
mvverfinal = mvverPred;
|
if(interstate!=InterPskip)
|
if(interstate!=InterPskip)
|
begin
|
begin
|
mvhorfinal = truncate(tpl_1(interMvDiff.first()) + signExtend(mvhorPred));
|
mvhorfinal = truncate(tpl_1(interMvDiff.first()) + signExtend(mvhorPred));
|
mvverfinal = truncate(tpl_2(interMvDiff.first()) + signExtend(mvverPred));
|
mvverfinal = truncate(tpl_2(interMvDiff.first()) + signExtend(mvverPred));
|
interMvDiff.deq();
|
interMvDiff.deq();
|
end
|
end
|
interMvFile.upd({interMbPartNum,interSubMbPartNum},tuple2(mvhorfinal,mvverfinal));
|
interMvFile.upd({interMbPartNum,interSubMbPartNum},tuple2(mvhorfinal,mvverfinal));
|
interNewestMvNext = zeroExtend({interMbPartNum,interSubMbPartNum})+1;
|
interNewestMvNext = zeroExtend({interMbPartNum,interSubMbPartNum})+1;
|
$display( "Trace Prediction: interProcessStep %h %h %h %h %h %h %h %h %h", interstate, interStepCount, interMbPartNum, interSubMbPartNum, pack(blockABC[0]), pack(blockABC[1]), pack(blockABC[2]), mvhorPred, mvverPred);
|
$display( "Trace Prediction: interProcessStep %h %h %h %h %h %h %h %h %h", interstate, interStepCount, interMbPartNum, interSubMbPartNum, pack(blockABC[0]), pack(blockABC[1]), pack(blockABC[2]), mvhorPred, mvverPred);
|
end
|
end
|
else
|
else
|
begin
|
begin
|
if(leftmv)
|
if(leftmv)
|
begin
|
begin
|
if(blockABC[0] matches tagged BlockMv .xdata)
|
if(blockABC[0] matches tagged BlockMv .xdata)
|
begin
|
begin
|
mvhorfinal = unpack(xdata.mvhor);
|
mvhorfinal = unpack(xdata.mvhor);
|
mvverfinal = unpack(xdata.mvver);
|
mvverfinal = unpack(xdata.mvver);
|
end
|
end
|
else
|
else
|
$display( "ERROR Prediction: interProcessStep unexpected blockABC[0]");
|
$display( "ERROR Prediction: interProcessStep unexpected blockABC[0]");
|
end
|
end
|
else
|
else
|
begin
|
begin
|
if(blockABC[1] matches tagged BlockMv .xdata)
|
if(blockABC[1] matches tagged BlockMv .xdata)
|
begin
|
begin
|
mvhorfinal = unpack(xdata.mvhor);
|
mvhorfinal = unpack(xdata.mvhor);
|
mvverfinal = unpack(xdata.mvver);
|
mvverfinal = unpack(xdata.mvver);
|
end
|
end
|
else
|
else
|
$display( "ERROR Prediction: interProcessStep unexpected blockABC[1]");
|
$display( "ERROR Prediction: interProcessStep unexpected blockABC[1]");
|
end
|
end
|
end
|
end
|
|
|
mvhorfinalR <= mvhorfinal;
|
mvhorfinalR <= mvhorfinal;
|
mvverfinalR <= mvverfinal;
|
mvverfinalR <= mvverfinal;
|
interNewestMvNextR <= interNewestMvNext;
|
interNewestMvNextR <= interNewestMvNext;
|
interStepCount <= 3;
|
interStepCount <= 3;
|
|
|
end
|
end
|
else // stepCount == 3
|
else // stepCount == 3
|
begin
|
begin
|
Bit#(2) tempBShor = 0;//bS calculation
|
Bit#(2) tempBShor = 0;//bS calculation
|
Bit#(2) tempBSver = 0;
|
Bit#(2) tempBSver = 0;
|
Bool allDone = False;
|
Bool allDone = False;
|
Bit#(4) refIndex = refIndexR;
|
Bit#(4) refIndex = refIndexR;
|
Bit#(14) mvhorfinal = mvhorfinalR;
|
Bit#(14) mvhorfinal = mvhorfinalR;
|
Bit#(12) mvverfinal = mvverfinalR;
|
Bit#(12) mvverfinal = mvverfinalR;
|
Bit#(5) interNewestMvNext = interNewestMvNextR;
|
Bit#(5) interNewestMvNext = interNewestMvNextR;
|
|
|
if(interLeftVal[blockVer] matches tagged BlockMv .xdata)
|
if(interLeftVal[blockVer] matches tagged BlockMv .xdata)
|
begin
|
begin
|
if(xdata.nonZeroTransCoeff == 1)
|
if(xdata.nonZeroTransCoeff == 1)
|
tempBShor = 2;
|
tempBShor = 2;
|
else
|
else
|
begin
|
begin
|
if(xdata.refIdx!=refIndex || absDiffGEFour14(mvhorfinal,xdata.mvhor) || absDiffGEFour12(mvverfinal,xdata.mvver))
|
if(xdata.refIdx!=refIndex || absDiffGEFour14(mvhorfinal,xdata.mvhor) || absDiffGEFour12(mvverfinal,xdata.mvver))
|
tempBShor = 1;
|
tempBShor = 1;
|
else
|
else
|
tempBShor = 0;
|
tempBShor = 0;
|
end
|
end
|
end
|
end
|
else
|
else
|
tempBShor = 3;
|
tempBShor = 3;
|
if(interTopVal[blockHor] matches tagged BlockMv .xdata)
|
if(interTopVal[blockHor] matches tagged BlockMv .xdata)
|
begin
|
begin
|
if(xdata.nonZeroTransCoeff == 1)
|
if(xdata.nonZeroTransCoeff == 1)
|
tempBSver = 2;
|
tempBSver = 2;
|
else
|
else
|
begin
|
begin
|
if(xdata.refIdx!=refIndex || absDiffGEFour14(mvhorfinal,xdata.mvhor) || absDiffGEFour12(mvverfinal,xdata.mvver))
|
if(xdata.refIdx!=refIndex || absDiffGEFour14(mvhorfinal,xdata.mvhor) || absDiffGEFour12(mvverfinal,xdata.mvver))
|
tempBSver = 1;
|
tempBSver = 1;
|
else
|
else
|
tempBSver = 0;
|
tempBSver = 0;
|
end
|
end
|
end
|
end
|
else
|
else
|
tempBSver = 3;
|
tempBSver = 3;
|
interBSfifo.enq(tuple2(tempBShor,tempBSver));
|
interBSfifo.enq(tuple2(tempBShor,tempBSver));
|
Vector#(5,InterBlockMv) interTopValNext = interTopVal;//update inter*Val
|
Vector#(5,InterBlockMv) interTopValNext = interTopVal;//update inter*Val
|
Vector#(4,InterBlockMv) interLeftValNext = interLeftVal;
|
Vector#(4,InterBlockMv) interLeftValNext = interLeftVal;
|
Vector#(4,InterBlockMv) interTopLeftValNext = interTopLeftVal;
|
Vector#(4,InterBlockMv) interTopLeftValNext = interTopLeftVal;
|
interLeftValNext[blockVer] = (BlockMv {refIdx:refIndex,mvhor:mvhorfinal,mvver:mvverfinal,nonZeroTransCoeff:0});
|
interLeftValNext[blockVer] = (BlockMv {refIdx:refIndex,mvhor:mvhorfinal,mvver:mvverfinal,nonZeroTransCoeff:0});
|
interTopValNext[blockHor] = (BlockMv {refIdx:refIndex,mvhor:mvhorfinal,mvver:mvverfinal,nonZeroTransCoeff:0});
|
interTopValNext[blockHor] = (BlockMv {refIdx:refIndex,mvhor:mvhorfinal,mvver:mvverfinal,nonZeroTransCoeff:0});
|
interTopLeftValNext[blockVer] = interTopVal[blockHor];
|
interTopLeftValNext[blockVer] = interTopVal[blockHor];
|
interTopVal <= interTopValNext;
|
interTopVal <= interTopValNext;
|
interLeftVal <= interLeftValNext;
|
interLeftVal <= interLeftValNext;
|
interTopLeftVal <= interTopLeftValNext;
|
interTopLeftVal <= interTopLeftValNext;
|
if(blockVer == 3)
|
if(blockVer == 3)
|
interOutBlockMvfifo.enq(tagged BlockMv {refIdx:refIndex,mvhor:mvhorfinal,mvver:mvverfinal,nonZeroTransCoeff:0});
|
interOutBlockMvfifo.enq(tagged BlockMv {refIdx:refIndex,mvhor:mvhorfinal,mvver:mvverfinal,nonZeroTransCoeff:0});
|
if(interSubMbPartNum == 3)//next step
|
if(interSubMbPartNum == 3)//next step
|
begin
|
begin
|
interSubMbPartNum <= 0;
|
interSubMbPartNum <= 0;
|
if(interMbPartNum == 3)
|
if(interMbPartNum == 3)
|
begin
|
begin
|
interMbPartNum <= 0;
|
interMbPartNum <= 0;
|
allDone = True;
|
allDone = True;
|
interNewestMvNext = 16;
|
interNewestMvNext = 16;
|
end
|
end
|
else
|
else
|
interMbPartNum <= interMbPartNum+1;
|
interMbPartNum <= interMbPartNum+1;
|
end
|
end
|
else
|
else
|
interSubMbPartNum <= interSubMbPartNum+1;
|
interSubMbPartNum <= interSubMbPartNum+1;
|
if(interNewestMvNext > 0)
|
if(interNewestMvNext > 0)
|
interNewestMv <= interNewestMvNext;
|
interNewestMv <= interNewestMvNext;
|
|
|
// Check to see if we are done.
|
// Check to see if we are done.
|
|
|
if(allDone)
|
if(allDone)
|
interStepCount <= 0;
|
interStepCount <= 0;
|
else
|
else
|
interStepCount <= 1;
|
interStepCount <= 1;
|
|
|
$display( "Trace Prediction: interProcessStep final %h %h %h %h %h %h %h",interstate,interStepCount,interMbPartNum,interSubMbPartNum,mvhorfinal,mvverfinal,interNewestMvNext);
|
$display( "Trace Prediction: interProcessStep final %h %h %h %h %h %h %h",interstate,interStepCount,interMbPartNum,interSubMbPartNum,mvhorfinal,mvverfinal,interNewestMvNext);
|
|
|
end
|
end
|
endrule
|
endrule
|
|
|
|
|
rule interIPProcessStep ( interIPStepCount>0 && currMbHorzeroExtend({interIPMbPartNum,interIPSubMbPartNum}) );
|
rule interIPProcessStep ( interIPStepCount>0 && currMbHorzeroExtend({interIPMbPartNum,interIPSubMbPartNum}) );
|
Bit#(PicAreaSz) currMbHorTemp = currMbHor+zeroExtend(interCurrMbDiff)-1;
|
Bit#(PicAreaSz) currMbHorTemp = currMbHor+zeroExtend(interCurrMbDiff)-1;
|
Bit#(PicHeightSz) currMbVerTemp = currMbVer;
|
Bit#(PicHeightSz) currMbVerTemp = currMbVer;
|
if( currMbHorTemp >= zeroExtend(picWidth) )
|
if( currMbHorTemp >= zeroExtend(picWidth) )
|
begin
|
begin
|
currMbHorTemp = currMbHorTemp-zeroExtend(picWidth);
|
currMbHorTemp = currMbHorTemp-zeroExtend(picWidth);
|
currMbVerTemp = currMbVerTemp+1;
|
currMbVerTemp = currMbVerTemp+1;
|
end
|
end
|
Bit#(2) blockHor = {interIPMbPartNum[0],interIPSubMbPartNum[0]};
|
Bit#(2) blockHor = {interIPMbPartNum[0],interIPSubMbPartNum[0]};
|
Bit#(2) blockVer = {interIPMbPartNum[1],interIPSubMbPartNum[1]};
|
Bit#(2) blockVer = {interIPMbPartNum[1],interIPSubMbPartNum[1]};
|
Bit#(3) numPart = 1;
|
Bit#(3) numPart = 1;
|
Bit#(3) numSubPart = 1;
|
Bit#(3) numSubPart = 1;
|
Bit#(2) subMbType = 0;
|
Bit#(2) subMbType = 0;
|
if(interstate==InterPskip || interstate==InterP16x16)
|
if(interstate==InterPskip || interstate==InterP16x16)
|
numPart = 1;
|
numPart = 1;
|
else if(interstate==InterP16x8)
|
else if(interstate==InterP16x8)
|
numPart = 2;
|
numPart = 2;
|
else if(interstate==InterP8x16)
|
else if(interstate==InterP8x16)
|
numPart = 2;
|
numPart = 2;
|
else if(interstate==InterP8x8 || interstate==InterP8x8ref0)
|
else if(interstate==InterP8x8 || interstate==InterP8x8ref0)
|
begin
|
begin
|
numPart = 4;
|
numPart = 4;
|
subMbType = interSubMbTypeVector[interIPMbPartNum];
|
subMbType = interSubMbTypeVector[interIPMbPartNum];
|
numSubPart = numSubMbPart(subMbType);
|
numSubPart = numSubMbPart(subMbType);
|
end
|
end
|
else
|
else
|
$display( "ERROR Prediction: interIPProcessStep unexpected interstate");
|
$display( "ERROR Prediction: interIPProcessStep unexpected interstate");
|
Bit#(4) refIndex = ((interstate==InterPskip||interstate==InterP8x8ref0) ? 0 : interRefIdxVector[interIPMbPartNum]);
|
Bit#(4) refIndex = ((interstate==InterPskip||interstate==InterP8x8ref0) ? 0 : interRefIdxVector[interIPMbPartNum]);
|
Bit#(PicWidthSz) currMbHorT = truncate(currMbHorTemp);
|
Bit#(PicWidthSz) currMbHorT = truncate(currMbHorTemp);
|
Bit#(TAdd#(PicWidthSz,2)) horTemp = {currMbHorT,blockHor};
|
Bit#(TAdd#(PicWidthSz,2)) horTemp = {currMbHorT,blockHor};
|
Bit#(TAdd#(PicHeightSz,4)) verTemp = {currMbVerTemp,blockVer,2'b00};
|
Bit#(TAdd#(PicHeightSz,4)) verTemp = {currMbVerTemp,blockVer,2'b00};
|
IPBlockType btTemp = IP16x16;
|
IPBlockType btTemp = IP16x16;
|
if(interstate==InterPskip || interstate==InterP16x16)
|
if(interstate==InterPskip || interstate==InterP16x16)
|
btTemp = IP16x16;
|
btTemp = IP16x16;
|
else if(interstate==InterP16x8)
|
else if(interstate==InterP16x8)
|
btTemp = IP16x8;
|
btTemp = IP16x8;
|
else if(interstate==InterP8x16)
|
else if(interstate==InterP8x16)
|
btTemp = IP8x16;
|
btTemp = IP8x16;
|
else
|
else
|
begin
|
begin
|
case(subMbType)
|
case(subMbType)
|
0: btTemp = IP8x8;
|
0: btTemp = IP8x8;
|
1: btTemp = IP8x4;
|
1: btTemp = IP8x4;
|
2: btTemp = IP4x8;
|
2: btTemp = IP4x8;
|
3: btTemp = IP4x4;
|
3: btTemp = IP4x4;
|
endcase
|
endcase
|
end
|
end
|
Bit#(14) mvhorTemp = tpl_1(interMvFile.sub({interIPMbPartNum,interIPSubMbPartNum}));
|
Bit#(14) mvhorTemp = tpl_1(interMvFile.sub({interIPMbPartNum,interIPSubMbPartNum}));
|
Bit#(12) mvverTemp = tpl_2(interMvFile.sub({interIPMbPartNum,interIPSubMbPartNum}));
|
Bit#(12) mvverTemp = tpl_2(interMvFile.sub({interIPMbPartNum,interIPSubMbPartNum}));
|
if(interIPStepCount == 1)
|
if(interIPStepCount == 1)
|
begin
|
begin
|
if(!(interstate==InterP8x8 || interstate==InterP8x8ref0))
|
if(!(interstate==InterP8x8 || interstate==InterP8x8ref0))
|
begin
|
begin
|
numPart = 4;
|
numPart = 4;
|
Bit#(2) interIPMbPartNumTemp = interIPMbPartNum;
|
Bit#(2) interIPMbPartNumTemp = interIPMbPartNum;
|
if(btTemp==IP16x16)
|
if(btTemp==IP16x16)
|
interIPMbPartNumTemp = 0;
|
interIPMbPartNumTemp = 0;
|
else if(btTemp==IP16x8 && interIPMbPartNumTemp[0]==1)
|
else if(btTemp==IP16x8 && interIPMbPartNumTemp[0]==1)
|
interIPMbPartNumTemp = interIPMbPartNumTemp-1;
|
interIPMbPartNumTemp = interIPMbPartNumTemp-1;
|
else if(btTemp==IP8x16 && interIPMbPartNumTemp[1]==1)
|
else if(btTemp==IP8x16 && interIPMbPartNumTemp[1]==1)
|
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))
|
begin
|
begin
|
interIPMbPartNum <= 0;
|
interIPMbPartNum <= 0;
|
interIPStepCount <= interIPStepCount+1;
|
interIPStepCount <= interIPStepCount+1;
|
end
|
end
|
else
|
else
|
begin
|
begin
|
if(btTemp == IP16x8)
|
if(btTemp == IP16x8)
|
interIPMbPartNum <= 2;
|
interIPMbPartNum <= 2;
|
else
|
else
|
interIPMbPartNum <= interIPMbPartNum+1;
|
interIPMbPartNum <= interIPMbPartNum+1;
|
end
|
end
|
end
|
end
|
else
|
else
|
begin
|
begin
|
if(subMbType == 1)
|
if(subMbType == 1)
|
interIPSubMbPartNum <= 2;
|
interIPSubMbPartNum <= 2;
|
else
|
else
|
interIPSubMbPartNum <= interIPSubMbPartNum+1;
|
interIPSubMbPartNum <= interIPSubMbPartNum+1;
|
end
|
end
|
$display( "PARDEBLOCKTrace Prediction: interIPProcessStep %h %h %h %h %h %h %h %h %h %h", interstate, interIPStepCount, interIPMbPartNum, interIPSubMbPartNum, refIndex, horTemp, verTemp, mvhorTemp, mvverTemp, pack(btTemp));
|
$display( "PARDEBLOCKTrace Prediction: interIPProcessStep %h %h %h %h %h %h %h %h %h %h", interstate, interIPStepCount, interIPMbPartNum, interIPSubMbPartNum, refIndex, horTemp, verTemp, mvhorTemp, mvverTemp, pack(btTemp));
|
endrule
|
endrule
|
|
|
|
|
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) )
|
noMoreReq = 1;
|
noMoreReq = 1;
|
else
|
else
|
begin
|
begin
|
if(intraReqCount<5)
|
if(intraReqCount<5)
|
begin
|
begin
|
Bit#(2) temp3 = truncate(intraReqCount-1);
|
Bit#(2) temp3 = truncate(intraReqCount-1);
|
temp = {temp2,temp3};
|
temp = {temp2,temp3};
|
end
|
end
|
else if(intraReqCount==5)
|
else if(intraReqCount==5)
|
begin
|
begin
|
if((currMbHor+1)
|
if((currMbHor+1)
|
temp = {(temp2+1),2'b00};
|
temp = {(temp2+1),2'b00};
|
else if(currMbHor>0 && currMb-firstMb>zeroExtend(picWidth))
|
else if(currMbHor>0 && currMb-firstMb>zeroExtend(picWidth))
|
temp = {(temp2-1),2'b11};
|
temp = {(temp2-1),2'b11};
|
else
|
else
|
noMoreReq = 1;
|
noMoreReq = 1;
|
end
|
end
|
else if(intraReqCount==6)
|
else if(intraReqCount==6)
|
begin
|
begin
|
if((currMbHor+1)0 && currMb-firstMb>zeroExtend(picWidth))
|
if((currMbHor+1)0 && currMb-firstMb>zeroExtend(picWidth))
|
temp = {(temp2-1),2'b11};
|
temp = {(temp2-1),2'b11};
|
else
|
else
|
noMoreReq = 1;
|
noMoreReq = 1;
|
end
|
end
|
else
|
else
|
noMoreReq = 1;
|
noMoreReq = 1;
|
end
|
end
|
if(noMoreReq == 0)
|
if(noMoreReq == 0)
|
begin
|
begin
|
intraMemReqQ.enq(tagged LoadReq temp);
|
intraMemReqQ.enq(tagged LoadReq temp);
|
intraReqCount <= intraReqCount+1;
|
intraReqCount <= intraReqCount+1;
|
//$display( "TRACE Prediction: intraSendReq addr %0d",temp);///////////////////////
|
//$display( "TRACE Prediction: intraSendReq addr %0d",temp);///////////////////////
|
end
|
end
|
else
|
else
|
intraReqCount <= 0;
|
intraReqCount <= 0;
|
$display( "Trace Prediction: intraSendReq");
|
$display( "Trace Prediction: intraSendReq");
|
endrule
|
endrule
|
|
|
|
|
rule intraReceiveNoResp ( intraRespCount>0 && currMbHor
|
rule intraReceiveNoResp ( intraRespCount>0 && currMbHor
|
intra4x4typeTop <= replicate(15);
|
intra4x4typeTop <= replicate(15);
|
intraRespCount <= 0;
|
intraRespCount <= 0;
|
intraStepCount <= 1;
|
intraStepCount <= 1;
|
blockNum <= 0;
|
blockNum <= 0;
|
pixelNum <= 0;
|
pixelNum <= 0;
|
interOutBlockMvfifo.enq(tagged NotInter 1);
|
interOutBlockMvfifo.enq(tagged NotInter 1);
|
$display( "Trace Prediction: intraReceiveNoResp");
|
$display( "Trace Prediction: intraReceiveNoResp");
|
endrule
|
endrule
|
|
|
|
|
rule intraReceiveResp ( intraRespCount>0 && intraRespCount<7 && currMbHor
|
rule intraReceiveResp ( intraRespCount>0 && intraRespCount<7 && currMbHor
|
Bit#(1) noMoreResp = 0;
|
Bit#(1) noMoreResp = 0;
|
Bit#(2) temp2bit = 0;
|
Bit#(2) temp2bit = 0;
|
if(intraRespCount<5)
|
if(intraRespCount<5)
|
begin
|
begin
|
temp2bit = truncate(intraRespCount-1);
|
temp2bit = truncate(intraRespCount-1);
|
intra4x4typeTop <= update(intra4x4typeTop, temp2bit, data[67:64]);
|
intra4x4typeTop <= update(intra4x4typeTop, temp2bit, data[67:64]);
|
if(intraRespCount==4)
|
if(intraRespCount==4)
|
begin
|
begin
|
Vector#(5,Bit#(32)) intraTopValTemp = intraTopVal;
|
Vector#(5,Bit#(32)) intraTopValTemp = intraTopVal;
|
intraTopValTemp[3] = data[31:0];
|
intraTopValTemp[3] = data[31:0];
|
intraTopValTemp[4] = {data[31:24],data[31:24],data[31:24],data[31:24]};
|
intraTopValTemp[4] = {data[31:24],data[31:24],data[31:24],data[31:24]};
|
intraTopVal <= intraTopValTemp;
|
intraTopVal <= intraTopValTemp;
|
if(!((currMbHor+1)0 && currMb-firstMb>zeroExtend(picWidth)))
|
if(!((currMbHor+1)0 && currMb-firstMb>zeroExtend(picWidth)))
|
noMoreResp = 1;
|
noMoreResp = 1;
|
end
|
end
|
else
|
else
|
intraTopVal <= update(intraTopVal, intraRespCount-1, data[31:0]);
|
intraTopVal <= update(intraTopVal, intraRespCount-1, data[31:0]);
|
intraTopValChroma0 <= update(intraTopValChroma0, temp2bit, data[47:32]);
|
intraTopValChroma0 <= update(intraTopValChroma0, temp2bit, data[47:32]);
|
intraTopValChroma1 <= update(intraTopValChroma1, temp2bit, data[63:48]);
|
intraTopValChroma1 <= update(intraTopValChroma1, temp2bit, data[63:48]);
|
end
|
end
|
else if(intraRespCount==5)
|
else if(intraRespCount==5)
|
begin
|
begin
|
if((currMbHor+1)
|
if((currMbHor+1)
|
begin
|
begin
|
if(!(data[67:64]==15 || (data[67:64]==14 && ppsconstrained_intra_pred_flag==1)))
|
if(!(data[67:64]==15 || (data[67:64]==14 && ppsconstrained_intra_pred_flag==1)))
|
intraTopVal <= update(intraTopVal, 4, data[31:0]);
|
intraTopVal <= update(intraTopVal, 4, data[31:0]);
|
if(!(currMbHor>0 && currMb-firstMb>zeroExtend(picWidth)))
|
if(!(currMbHor>0 && currMb-firstMb>zeroExtend(picWidth)))
|
noMoreResp = 1;
|
noMoreResp = 1;
|
end
|
end
|
else
|
else
|
begin
|
begin
|
Bit#(40) temp2 = intraLeftVal[0];
|
Bit#(40) temp2 = intraLeftVal[0];
|
intraLeftVal <= update(intraLeftVal, 0, {temp2[39:8],data[31:24]});
|
intraLeftVal <= update(intraLeftVal, 0, {temp2[39:8],data[31:24]});
|
intraLeftValChroma0 <= update(intraLeftValChroma0, 0, data[47:40]);
|
intraLeftValChroma0 <= update(intraLeftValChroma0, 0, data[47:40]);
|
intraLeftValChroma1 <= update(intraLeftValChroma1, 0, data[63:56]);
|
intraLeftValChroma1 <= update(intraLeftValChroma1, 0, data[63:56]);
|
noMoreResp = 1;
|
noMoreResp = 1;
|
end
|
end
|
end
|
end
|
else
|
else
|
begin
|
begin
|
Bit#(40) temp2 = intraLeftVal[0];
|
Bit#(40) temp2 = intraLeftVal[0];
|
intraLeftVal <= update(intraLeftVal, 0, {temp2[39:8],data[31:24]});
|
intraLeftVal <= update(intraLeftVal, 0, {temp2[39:8],data[31:24]});
|
intraLeftValChroma0 <= update(intraLeftValChroma0, 0, data[47:40]);
|
intraLeftValChroma0 <= update(intraLeftValChroma0, 0, data[47:40]);
|
intraLeftValChroma1 <= update(intraLeftValChroma1, 0, data[63:56]);
|
intraLeftValChroma1 <= update(intraLeftValChroma1, 0, data[63:56]);
|
noMoreResp = 1;
|
noMoreResp = 1;
|
end
|
end
|
intraMemRespQ.deq();
|
intraMemRespQ.deq();
|
//$display( "TRACE Prediction: intraReceiveResp data %h",data);///////////////////////
|
//$display( "TRACE Prediction: intraReceiveResp data %h",data);///////////////////////
|
if(noMoreResp == 0)
|
if(noMoreResp == 0)
|
intraRespCount <= intraRespCount+1;
|
intraRespCount <= intraRespCount+1;
|
else
|
else
|
begin
|
begin
|
intraRespCount <= 0;
|
intraRespCount <= 0;
|
intraStepCount <= 1;
|
intraStepCount <= 1;
|
blockNum <= 0;
|
blockNum <= 0;
|
pixelNum <= 0;
|
pixelNum <= 0;
|
interOutBlockMvfifo.enq(tagged NotInter 1);
|
interOutBlockMvfifo.enq(tagged NotInter 1);
|
end
|
end
|
$display( "Trace Prediction: intraReceiveResp");
|
$display( "Trace Prediction: intraReceiveResp");
|
endrule
|
endrule
|
|
|
|
|
rule intraPredTypeStep ( intraStepCount==1 && !nextoutputfifo.notEmpty());
|
rule intraPredTypeStep ( intraStepCount==1 && !nextoutputfifo.notEmpty());
|
Bit#(2) blockHor = {blockNum[2],blockNum[0]};
|
Bit#(2) blockHor = {blockNum[2],blockNum[0]};
|
Bit#(2) blockVer = {blockNum[3],blockNum[1]};
|
Bit#(2) blockVer = {blockNum[3],blockNum[1]};
|
Bit#(4) topType = select(intra4x4typeTop, blockHor);
|
Bit#(4) topType = select(intra4x4typeTop, blockHor);
|
Bit#(4) leftType;
|
Bit#(4) leftType;
|
if(currMbHor!=0 || blockNum!=0)
|
if(currMbHor!=0 || blockNum!=0)
|
leftType = select(intra4x4typeLeft, blockVer);
|
leftType = select(intra4x4typeLeft, blockVer);
|
else
|
else
|
begin
|
begin
|
leftType = 15;
|
leftType = 15;
|
intra4x4typeLeft <= replicate(15);
|
intra4x4typeLeft <= replicate(15);
|
end
|
end
|
if(intrastate!=Intra4x4)
|
if(intrastate!=Intra4x4)
|
begin
|
begin
|
intraStepCount <= intraStepCount+1;
|
intraStepCount <= intraStepCount+1;
|
nextoutputfifo.enq(NonSkipMB);
|
nextoutputfifo.enq(NonSkipMB);
|
end
|
end
|
else
|
else
|
begin
|
begin
|
Bit#(1) topAvailable;
|
Bit#(1) topAvailable;
|
Bit#(1) leftAvailable;
|
Bit#(1) leftAvailable;
|
if(topType==15 || (topType==14 && ppsconstrained_intra_pred_flag==1))
|
if(topType==15 || (topType==14 && ppsconstrained_intra_pred_flag==1))
|
topAvailable = 0;
|
topAvailable = 0;
|
else
|
else
|
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;
|
Bit#(4) predType = 0;
|
Bit#(4) predType = 0;
|
Bit#(4) remType = rem_intra4x4_pred_mode.first();
|
Bit#(4) remType = rem_intra4x4_pred_mode.first();
|
Bit#(4) curType = 0;
|
Bit#(4) curType = 0;
|
rem_intra4x4_pred_mode.deq();
|
rem_intra4x4_pred_mode.deq();
|
if(topAvailable==0 || leftAvailable==0)
|
if(topAvailable==0 || leftAvailable==0)
|
predType = 2;
|
predType = 2;
|
else
|
else
|
begin
|
begin
|
Bit#(4) topType2 = topType;
|
Bit#(4) topType2 = topType;
|
Bit#(4) leftType2 = leftType;
|
Bit#(4) leftType2 = leftType;
|
if(topType>8)
|
if(topType>8)
|
topType2 = 2;
|
topType2 = 2;
|
if(leftType>8)
|
if(leftType>8)
|
leftType2 = 2;
|
leftType2 = 2;
|
if(topType2 > leftType2)
|
if(topType2 > leftType2)
|
predType = leftType2;
|
predType = leftType2;
|
else
|
else
|
predType = topType2;
|
predType = topType2;
|
end
|
end
|
if(remType[3] == 1)
|
if(remType[3] == 1)
|
curType = predType;
|
curType = predType;
|
else if(remType < predType)
|
else if(remType < predType)
|
curType = remType;
|
curType = remType;
|
else
|
else
|
curType = remType+1;
|
curType = remType+1;
|
cur_intra4x4_pred_mode <= curType;
|
cur_intra4x4_pred_mode <= curType;
|
intraStepCount <= intraStepCount+1;
|
intraStepCount <= intraStepCount+1;
|
if(blockNum == 15)
|
if(blockNum == 15)
|
nextoutputfifo.enq(tagged Intra4x4PlusChroma);
|
nextoutputfifo.enq(tagged Intra4x4PlusChroma);
|
else
|
else
|
nextoutputfifo.enq(tagged Intra4x4);
|
nextoutputfifo.enq(tagged Intra4x4);
|
$display( "TRACE Prediction: intraPredTypeStep currMbHor currMbVer blockNum topType leftType predType remType curType %0d %0d %0d %0d %0d %0d %0d %0d",currMbHor,currMbVer,blockNum,topType,leftType,predType,remType,curType);//////////////////
|
$display( "TRACE Prediction: intraPredTypeStep currMbHor currMbVer blockNum topType leftType predType remType curType %0d %0d %0d %0d %0d %0d %0d %0d",currMbHor,currMbVer,blockNum,topType,leftType,predType,remType,curType);//////////////////
|
end
|
end
|
//$display( "Trace Prediction: intraPredTypeStep");
|
//$display( "Trace Prediction: intraPredTypeStep");
|
endrule
|
endrule
|
|
|
|
|
rule intraProcessStep ( intraStepCount>1 );
|
rule intraProcessStep ( intraStepCount>1 );
|
$display( "TRACE Prediction: intraProcessStep %0d %0d", blockNum, pixelNum);////////////////////
|
$display( "TRACE Prediction: intraProcessStep %0d %0d", blockNum, pixelNum);////////////////////
|
//$display( "TRACE Prediction: intraProcessStep intraTopVal %h %h %h %h %h",intraTopVal[4],intraTopVal[3],intraTopVal[2],intraTopVal[1],intraTopVal[0]);/////////////////
|
//$display( "TRACE Prediction: intraProcessStep intraTopVal %h %h %h %h %h",intraTopVal[4],intraTopVal[3],intraTopVal[2],intraTopVal[1],intraTopVal[0]);/////////////////
|
Bit#(1) outFlag = 0;
|
Bit#(1) outFlag = 0;
|
Bit#(4) nextIntraStepCount = intraStepCount+1;
|
Bit#(4) nextIntraStepCount = intraStepCount+1;
|
Bit#(2) blockHor = {blockNum[2],blockNum[0]};
|
Bit#(2) blockHor = {blockNum[2],blockNum[0]};
|
Bit#(2) blockVer = {blockNum[3],blockNum[1]};
|
Bit#(2) blockVer = {blockNum[3],blockNum[1]};
|
Bit#(2) pixelVer = {pixelNum[3],pixelNum[2]};
|
Bit#(2) pixelVer = {pixelNum[3],pixelNum[2]};
|
Vector#(4,Bit#(8)) predVector = replicate(0);
|
Vector#(4,Bit#(8)) predVector = replicate(0);
|
|
|
Bit#(4) topType = select(intra4x4typeTop, blockHor);
|
Bit#(4) topType = select(intra4x4typeTop, blockHor);
|
Bit#(4) leftType = select(intra4x4typeLeft, blockVer);
|
Bit#(4) leftType = select(intra4x4typeLeft, blockVer);
|
Bit#(1) topAvailable;
|
Bit#(1) topAvailable;
|
Bit#(1) leftAvailable;
|
Bit#(1) leftAvailable;
|
if(topType==15 || (topType==14 && ppsconstrained_intra_pred_flag==1))
|
if(topType==15 || (topType==14 && ppsconstrained_intra_pred_flag==1))
|
topAvailable = 0;
|
topAvailable = 0;
|
else
|
else
|
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);
|
Bit#(32) topMidValSet = select(intraTopVal,zeroExtend(blockHor));
|
Bit#(32) topMidValSet = select(intraTopVal,zeroExtend(blockHor));
|
Bit#(32) topRightValSet = select(intraTopVal,{1'b0,blockHor}+1);
|
Bit#(32) topRightValSet = select(intraTopVal,{1'b0,blockHor}+1);
|
Bit#(72) topValSet;
|
Bit#(72) topValSet;
|
if((blockNum[3:2]==3 && blockNum[0]==1) || blockNum[1:0]==3)
|
if((blockNum[3:2]==3 && blockNum[0]==1) || blockNum[1:0]==3)
|
topValSet = {topMidValSet[31:24],topMidValSet[31:24],topMidValSet[31:24],topMidValSet[31:24],topMidValSet,leftValSet[7:0]};
|
topValSet = {topMidValSet[31:24],topMidValSet[31:24],topMidValSet[31:24],topMidValSet[31:24],topMidValSet,leftValSet[7:0]};
|
else
|
else
|
topValSet = {topRightValSet,topMidValSet,leftValSet[7:0]};
|
topValSet = {topRightValSet,topMidValSet,leftValSet[7:0]};
|
$display( "TRACE Prediction: intraProcessStep intra4x4 %0d %0d %h %h", cur_intra4x4_pred_mode, blockNum, leftValSet, topValSet);////////////////////
|
$display( "TRACE Prediction: intraProcessStep intra4x4 %0d %0d %h %h", cur_intra4x4_pred_mode, blockNum, leftValSet, topValSet);////////////////////
|
Bit#(4) topSelect1 = 0;
|
Bit#(4) topSelect1 = 0;
|
Bit#(4) topSelect2 = 0;
|
Bit#(4) topSelect2 = 0;
|
Bit#(4) topSelect3 = 0;
|
Bit#(4) topSelect3 = 0;
|
Bit#(3) leftSelect1 = 0;
|
Bit#(3) leftSelect1 = 0;
|
Bit#(3) leftSelect2 = 0;
|
Bit#(3) leftSelect2 = 0;
|
Bit#(3) leftSelect3 = 0;
|
Bit#(3) leftSelect3 = 0;
|
Bit#(10) tempVal1 = 0;
|
Bit#(10) tempVal1 = 0;
|
Bit#(10) tempVal2 = 0;
|
Bit#(10) tempVal2 = 0;
|
Bit#(10) tempVal3 = 0;
|
Bit#(10) tempVal3 = 0;
|
case(cur_intra4x4_pred_mode)
|
case(cur_intra4x4_pred_mode)
|
0://vertical
|
0://vertical
|
begin
|
begin
|
for(Integer pixelHor=0; pixelHor<4; pixelHor=pixelHor+1)
|
for(Integer pixelHor=0; pixelHor<4; pixelHor=pixelHor+1)
|
begin
|
begin
|
topSelect1 = fromInteger(pixelHor);
|
topSelect1 = fromInteger(pixelHor);
|
Bit#(8) topVal = intra4x4SelectTop(topValSet,topSelect1);
|
Bit#(8) topVal = intra4x4SelectTop(topValSet,topSelect1);
|
predVector[pixelHor] = topVal;
|
predVector[pixelHor] = topVal;
|
end
|
end
|
end
|
end
|
1://horizontal
|
1://horizontal
|
begin
|
begin
|
leftSelect1 = zeroExtend(pixelVer);
|
leftSelect1 = zeroExtend(pixelVer);
|
Bit#(8) leftVal = intra4x4SelectLeft(leftValSet,leftSelect1);
|
Bit#(8) leftVal = intra4x4SelectLeft(leftValSet,leftSelect1);
|
for(Integer pixelHor=0; pixelHor<4; pixelHor=pixelHor+1)
|
for(Integer pixelHor=0; pixelHor<4; pixelHor=pixelHor+1)
|
predVector[pixelHor] = leftVal;
|
predVector[pixelHor] = leftVal;
|
end
|
end
|
2://dc
|
2://dc
|
begin
|
begin
|
for(Integer pixelHor=0; pixelHor<4; pixelHor=pixelHor+1)
|
for(Integer pixelHor=0; pixelHor<4; pixelHor=pixelHor+1)
|
begin
|
begin
|
Bit#(10) tempTopSum = zeroExtend(topValSet[15:8])+zeroExtend(topValSet[23:16])+zeroExtend(topValSet[31:24])+zeroExtend(topValSet[39:32]) + 2;
|
Bit#(10) tempTopSum = zeroExtend(topValSet[15:8])+zeroExtend(topValSet[23:16])+zeroExtend(topValSet[31:24])+zeroExtend(topValSet[39:32]) + 2;
|
Bit#(10) tempLeftSum = zeroExtend(leftValSet[15:8])+zeroExtend(leftValSet[23:16])+zeroExtend(leftValSet[31:24])+zeroExtend(leftValSet[39:32]) + 2;
|
Bit#(10) tempLeftSum = zeroExtend(leftValSet[15:8])+zeroExtend(leftValSet[23:16])+zeroExtend(leftValSet[31:24])+zeroExtend(leftValSet[39:32]) + 2;
|
Bit#(11) tempTotalSum = zeroExtend(tempTopSum)+zeroExtend(tempLeftSum);
|
Bit#(11) tempTotalSum = zeroExtend(tempTopSum)+zeroExtend(tempLeftSum);
|
Bit#(8) topSum = tempTopSum[9:2];
|
Bit#(8) topSum = tempTopSum[9:2];
|
Bit#(8) leftSum = tempLeftSum[9:2];
|
Bit#(8) leftSum = tempLeftSum[9:2];
|
Bit#(8) totalSum = tempTotalSum[10:3];
|
Bit#(8) totalSum = tempTotalSum[10:3];
|
if(topAvailable==1 && leftAvailable==1)
|
if(topAvailable==1 && leftAvailable==1)
|
predVector[pixelHor] = totalSum;
|
predVector[pixelHor] = totalSum;
|
else if(topAvailable==1)
|
else if(topAvailable==1)
|
predVector[pixelHor] = topSum;
|
predVector[pixelHor] = topSum;
|
else if(leftAvailable==1)
|
else if(leftAvailable==1)
|
predVector[pixelHor] = leftSum;
|
predVector[pixelHor] = leftSum;
|
else
|
else
|
predVector[pixelHor] = 8'b10000000;
|
predVector[pixelHor] = 8'b10000000;
|
end
|
end
|
end
|
end
|
3://diagonal down left
|
3://diagonal down left
|
begin
|
begin
|
for(Integer pixelHor=0; pixelHor<4; pixelHor=pixelHor+1)
|
for(Integer pixelHor=0; pixelHor<4; pixelHor=pixelHor+1)
|
begin
|
begin
|
Bit#(4) selectNum = fromInteger(pixelHor)+zeroExtend(pixelVer);
|
Bit#(4) selectNum = fromInteger(pixelHor)+zeroExtend(pixelVer);
|
if(pixelHor==3 && pixelVer==3)
|
if(pixelHor==3 && pixelVer==3)
|
begin
|
begin
|
topSelect1 = 6;
|
topSelect1 = 6;
|
topSelect2 = 7;
|
topSelect2 = 7;
|
topSelect3 = 7;
|
topSelect3 = 7;
|
end
|
end
|
else
|
else
|
begin
|
begin
|
topSelect1 = selectNum;
|
topSelect1 = selectNum;
|
topSelect2 = selectNum+1;
|
topSelect2 = selectNum+1;
|
topSelect3 = selectNum+2;
|
topSelect3 = selectNum+2;
|
end
|
end
|
tempVal1 = zeroExtend(intra4x4SelectTop(topValSet,topSelect1));
|
tempVal1 = zeroExtend(intra4x4SelectTop(topValSet,topSelect1));
|
tempVal2 = zeroExtend(intra4x4SelectTop(topValSet,topSelect2));
|
tempVal2 = zeroExtend(intra4x4SelectTop(topValSet,topSelect2));
|
tempVal3 = zeroExtend(intra4x4SelectTop(topValSet,topSelect3));
|
tempVal3 = zeroExtend(intra4x4SelectTop(topValSet,topSelect3));
|
Bit#(10) predVal = tempVal1 + (tempVal2<<1) + tempVal3 + 2;
|
Bit#(10) predVal = tempVal1 + (tempVal2<<1) + tempVal3 + 2;
|
predVector[pixelHor] = predVal[9:2];
|
predVector[pixelHor] = predVal[9:2];
|
end
|
end
|
end
|
end
|
4://diagonal down right
|
4://diagonal down right
|
begin
|
begin
|
for(Integer pixelHor=0; pixelHor<4; pixelHor=pixelHor+1)
|
for(Integer pixelHor=0; pixelHor<4; pixelHor=pixelHor+1)
|
begin
|
begin
|
if(fromInteger(pixelHor) > pixelVer)
|
if(fromInteger(pixelHor) > pixelVer)
|
begin
|
begin
|
topSelect3 = fromInteger(pixelHor)-zeroExtend(pixelVer);
|
topSelect3 = fromInteger(pixelHor)-zeroExtend(pixelVer);
|
topSelect2 = topSelect3-1;
|
topSelect2 = topSelect3-1;
|
topSelect1 = topSelect3-2;
|
topSelect1 = topSelect3-2;
|
tempVal1 = zeroExtend(intra4x4SelectTop(topValSet,topSelect1));
|
tempVal1 = zeroExtend(intra4x4SelectTop(topValSet,topSelect1));
|
tempVal2 = zeroExtend(intra4x4SelectTop(topValSet,topSelect2));
|
tempVal2 = zeroExtend(intra4x4SelectTop(topValSet,topSelect2));
|
tempVal3 = zeroExtend(intra4x4SelectTop(topValSet,topSelect3));
|
tempVal3 = zeroExtend(intra4x4SelectTop(topValSet,topSelect3));
|
end
|
end
|
else if(fromInteger(pixelHor) < pixelVer)
|
else if(fromInteger(pixelHor) < pixelVer)
|
begin
|
begin
|
leftSelect3 = zeroExtend(pixelVer)-fromInteger(pixelHor);
|
leftSelect3 = zeroExtend(pixelVer)-fromInteger(pixelHor);
|
leftSelect2 = leftSelect3-1;
|
leftSelect2 = leftSelect3-1;
|
leftSelect1 = leftSelect3-2;
|
leftSelect1 = leftSelect3-2;
|
tempVal1 = zeroExtend(intra4x4SelectLeft(leftValSet,leftSelect1));
|
tempVal1 = zeroExtend(intra4x4SelectLeft(leftValSet,leftSelect1));
|
tempVal2 = zeroExtend(intra4x4SelectLeft(leftValSet,leftSelect2));
|
tempVal2 = zeroExtend(intra4x4SelectLeft(leftValSet,leftSelect2));
|
tempVal3 = zeroExtend(intra4x4SelectLeft(leftValSet,leftSelect3));
|
tempVal3 = zeroExtend(intra4x4SelectLeft(leftValSet,leftSelect3));
|
end
|
end
|
else
|
else
|
begin
|
begin
|
leftSelect1 = 0;
|
leftSelect1 = 0;
|
leftSelect2 = -1;
|
leftSelect2 = -1;
|
topSelect1 = 0;
|
topSelect1 = 0;
|
tempVal1 = zeroExtend(intra4x4SelectLeft(leftValSet,leftSelect1));
|
tempVal1 = zeroExtend(intra4x4SelectLeft(leftValSet,leftSelect1));
|
tempVal2 = zeroExtend(intra4x4SelectLeft(leftValSet,leftSelect2));
|
tempVal2 = zeroExtend(intra4x4SelectLeft(leftValSet,leftSelect2));
|
tempVal3 = zeroExtend(intra4x4SelectTop(topValSet,topSelect1));
|
tempVal3 = zeroExtend(intra4x4SelectTop(topValSet,topSelect1));
|
end
|
end
|
Bit#(10) predVal = tempVal1 + (tempVal2<<1) + tempVal3 + 2;
|
Bit#(10) predVal = tempVal1 + (tempVal2<<1) + tempVal3 + 2;
|
predVector[pixelHor] = predVal[9:2];
|
predVector[pixelHor] = predVal[9:2];
|
end
|
end
|
end
|
end
|
5://vertical right
|
5://vertical right
|
begin
|
begin
|
for(Integer pixelHor=0; pixelHor<4; pixelHor=pixelHor+1)
|
for(Integer pixelHor=0; pixelHor<4; pixelHor=pixelHor+1)
|
begin
|
begin
|
Bit#(4) tempPixelHor = fromInteger(pixelHor);
|
Bit#(4) tempPixelHor = fromInteger(pixelHor);
|
Bit#(4) zVR = (tempPixelHor<<1)-zeroExtend(pixelVer);
|
Bit#(4) zVR = (tempPixelHor<<1)-zeroExtend(pixelVer);
|
if(zVR<=6 && zVR>=0)
|
if(zVR<=6 && zVR>=0)
|
begin
|
begin
|
topSelect3 = fromInteger(pixelHor)-zeroExtend(pixelVer>>1);
|
topSelect3 = fromInteger(pixelHor)-zeroExtend(pixelVer>>1);
|
topSelect2 = topSelect3-1;
|
topSelect2 = topSelect3-1;
|
if(zVR==1 || zVR==3 || zVR==5)
|
if(zVR==1 || zVR==3 || zVR==5)
|
topSelect1 = topSelect3-2;
|
topSelect1 = topSelect3-2;
|
else
|
else
|
topSelect1 = topSelect3;
|
topSelect1 = topSelect3;
|
tempVal1 = zeroExtend(intra4x4SelectTop(topValSet,topSelect1));
|
tempVal1 = zeroExtend(intra4x4SelectTop(topValSet,topSelect1));
|
tempVal2 = zeroExtend(intra4x4SelectTop(topValSet,topSelect2));
|
tempVal2 = zeroExtend(intra4x4SelectTop(topValSet,topSelect2));
|
tempVal3 = zeroExtend(intra4x4SelectTop(topValSet,topSelect3));
|
tempVal3 = zeroExtend(intra4x4SelectTop(topValSet,topSelect3));
|
end
|
end
|
else if(zVR==-1)
|
else if(zVR==-1)
|
begin
|
begin
|
leftSelect1 = 0;
|
leftSelect1 = 0;
|
leftSelect2 = -1;
|
leftSelect2 = -1;
|
topSelect1 = 0;
|
topSelect1 = 0;
|
tempVal1 = zeroExtend(intra4x4SelectLeft(leftValSet,leftSelect1));
|
tempVal1 = zeroExtend(intra4x4SelectLeft(leftValSet,leftSelect1));
|
tempVal2 = zeroExtend(intra4x4SelectLeft(leftValSet,leftSelect2));
|
tempVal2 = zeroExtend(intra4x4SelectLeft(leftValSet,leftSelect2));
|
tempVal3 = zeroExtend(intra4x4SelectTop(topValSet,topSelect1));
|
tempVal3 = zeroExtend(intra4x4SelectTop(topValSet,topSelect1));
|
end
|
end
|
else
|
else
|
begin
|
begin
|
leftSelect1 = zeroExtend(pixelVer)-1;
|
leftSelect1 = zeroExtend(pixelVer)-1;
|
leftSelect2 = leftSelect1-1;
|
leftSelect2 = leftSelect1-1;
|
leftSelect3 = leftSelect1-2;
|
leftSelect3 = leftSelect1-2;
|
tempVal1 = zeroExtend(intra4x4SelectLeft(leftValSet,leftSelect1));
|
tempVal1 = zeroExtend(intra4x4SelectLeft(leftValSet,leftSelect1));
|
tempVal2 = zeroExtend(intra4x4SelectLeft(leftValSet,leftSelect2));
|
tempVal2 = zeroExtend(intra4x4SelectLeft(leftValSet,leftSelect2));
|
tempVal3 = zeroExtend(intra4x4SelectLeft(leftValSet,leftSelect3));
|
tempVal3 = zeroExtend(intra4x4SelectLeft(leftValSet,leftSelect3));
|
end
|
end
|
Bit#(10) predVal = tempVal1 + (tempVal2<<1) + tempVal3 + 2;
|
Bit#(10) predVal = tempVal1 + (tempVal2<<1) + tempVal3 + 2;
|
predVector[pixelHor] = predVal[9:2];
|
predVector[pixelHor] = predVal[9:2];
|
end
|
end
|
end
|
end
|
6://horizontal down
|
6://horizontal down
|
begin
|
begin
|
for(Integer pixelHor=0; pixelHor<4; pixelHor=pixelHor+1)
|
for(Integer pixelHor=0; pixelHor<4; pixelHor=pixelHor+1)
|
begin
|
begin
|
Bit#(4) tempPixelVer = zeroExtend(pixelVer);
|
Bit#(4) tempPixelVer = zeroExtend(pixelVer);
|
Bit#(4) zHD = (tempPixelVer<<1)-fromInteger(pixelHor);
|
Bit#(4) zHD = (tempPixelVer<<1)-fromInteger(pixelHor);
|
if(zHD<=6 && zHD>=0)
|
if(zHD<=6 && zHD>=0)
|
begin
|
begin
|
leftSelect3 = zeroExtend(pixelVer)-fromInteger(pixelHor/2);
|
leftSelect3 = zeroExtend(pixelVer)-fromInteger(pixelHor/2);
|
leftSelect2 = leftSelect3-1;
|
leftSelect2 = leftSelect3-1;
|
if(zHD==1 || zHD==3 || zHD==5)
|
if(zHD==1 || zHD==3 || zHD==5)
|
leftSelect1 = leftSelect3-2;
|
leftSelect1 = leftSelect3-2;
|
else
|
else
|
leftSelect1 = leftSelect3;
|
leftSelect1 = leftSelect3;
|
tempVal1 = zeroExtend(intra4x4SelectLeft(leftValSet,leftSelect1));
|
tempVal1 = zeroExtend(intra4x4SelectLeft(leftValSet,leftSelect1));
|
tempVal2 = zeroExtend(intra4x4SelectLeft(leftValSet,leftSelect2));
|
tempVal2 = zeroExtend(intra4x4SelectLeft(leftValSet,leftSelect2));
|
tempVal3 = zeroExtend(intra4x4SelectLeft(leftValSet,leftSelect3));
|
tempVal3 = zeroExtend(intra4x4SelectLeft(leftValSet,leftSelect3));
|
end
|
end
|
else if(zHD==-1)
|
else if(zHD==-1)
|
begin
|
begin
|
leftSelect1 = 0;
|
leftSelect1 = 0;
|
leftSelect2 = -1;
|
leftSelect2 = -1;
|
topSelect1 = 0;
|
topSelect1 = 0;
|
tempVal1 = zeroExtend(intra4x4SelectLeft(leftValSet,leftSelect1));
|
tempVal1 = zeroExtend(intra4x4SelectLeft(leftValSet,leftSelect1));
|
tempVal2 = zeroExtend(intra4x4SelectLeft(leftValSet,leftSelect2));
|
tempVal2 = zeroExtend(intra4x4SelectLeft(leftValSet,leftSelect2));
|
tempVal3 = zeroExtend(intra4x4SelectTop(topValSet,topSelect1));
|
tempVal3 = zeroExtend(intra4x4SelectTop(topValSet,topSelect1));
|
end
|
end
|
else
|
else
|
begin
|
begin
|
topSelect1 = fromInteger(pixelHor)-1;
|
topSelect1 = fromInteger(pixelHor)-1;
|
topSelect2 = topSelect1-1;
|
topSelect2 = topSelect1-1;
|
topSelect3 = topSelect1-2;
|
topSelect3 = topSelect1-2;
|
tempVal1 = zeroExtend(intra4x4SelectTop(topValSet,topSelect1));
|
tempVal1 = zeroExtend(intra4x4SelectTop(topValSet,topSelect1));
|
tempVal2 = zeroExtend(intra4x4SelectTop(topValSet,topSelect2));
|
tempVal2 = zeroExtend(intra4x4SelectTop(topValSet,topSelect2));
|
tempVal3 = zeroExtend(intra4x4SelectTop(topValSet,topSelect3));
|
tempVal3 = zeroExtend(intra4x4SelectTop(topValSet,topSelect3));
|
end
|
end
|
Bit#(10) predVal = tempVal1 + (tempVal2<<1) + tempVal3 + 2;
|
Bit#(10) predVal = tempVal1 + (tempVal2<<1) + tempVal3 + 2;
|
predVector[pixelHor] = predVal[9:2];
|
predVector[pixelHor] = predVal[9:2];
|
end
|
end
|
end
|
end
|
7://vertical left
|
7://vertical left
|
begin
|
begin
|
for(Integer pixelHor=0; pixelHor<4; pixelHor=pixelHor+1)
|
for(Integer pixelHor=0; pixelHor<4; pixelHor=pixelHor+1)
|
begin
|
begin
|
topSelect1 = fromInteger(pixelHor)+zeroExtend(pixelVer>>1);
|
topSelect1 = fromInteger(pixelHor)+zeroExtend(pixelVer>>1);
|
topSelect2 = topSelect1+1;
|
topSelect2 = topSelect1+1;
|
if(pixelVer==1 || pixelVer==3)
|
if(pixelVer==1 || pixelVer==3)
|
topSelect3 = topSelect1+2;
|
topSelect3 = topSelect1+2;
|
else
|
else
|
topSelect3 = topSelect1;
|
topSelect3 = topSelect1;
|
tempVal1 = zeroExtend(intra4x4SelectTop(topValSet,topSelect1));
|
tempVal1 = zeroExtend(intra4x4SelectTop(topValSet,topSelect1));
|
tempVal2 = zeroExtend(intra4x4SelectTop(topValSet,topSelect2));
|
tempVal2 = zeroExtend(intra4x4SelectTop(topValSet,topSelect2));
|
tempVal3 = zeroExtend(intra4x4SelectTop(topValSet,topSelect3));
|
tempVal3 = zeroExtend(intra4x4SelectTop(topValSet,topSelect3));
|
Bit#(10) predVal = tempVal1 + (tempVal2<<1) + tempVal3 + 2;
|
Bit#(10) predVal = tempVal1 + (tempVal2<<1) + tempVal3 + 2;
|
predVector[pixelHor] = predVal[9:2];
|
predVector[pixelHor] = predVal[9:2];
|
end
|
end
|
end
|
end
|
8://horizontal up
|
8://horizontal up
|
begin
|
begin
|
for(Integer pixelHor=0; pixelHor<4; pixelHor=pixelHor+1)
|
for(Integer pixelHor=0; pixelHor<4; pixelHor=pixelHor+1)
|
begin
|
begin
|
Bit#(4) tempPixelVer = zeroExtend(pixelVer);
|
Bit#(4) tempPixelVer = zeroExtend(pixelVer);
|
Bit#(4) zHU = (tempPixelVer<<1)+fromInteger(pixelHor);
|
Bit#(4) zHU = (tempPixelVer<<1)+fromInteger(pixelHor);
|
if(zHU<=4)
|
if(zHU<=4)
|
begin
|
begin
|
leftSelect1 = zeroExtend(pixelVer)+fromInteger(pixelHor/2);
|
leftSelect1 = zeroExtend(pixelVer)+fromInteger(pixelHor/2);
|
leftSelect2 = leftSelect1+1;
|
leftSelect2 = leftSelect1+1;
|
if(zHU==1 || zHU==3)
|
if(zHU==1 || zHU==3)
|
leftSelect3 = leftSelect1+2;
|
leftSelect3 = leftSelect1+2;
|
else
|
else
|
leftSelect3 = leftSelect1;
|
leftSelect3 = leftSelect1;
|
end
|
end
|
else
|
else
|
begin
|
begin
|
if(zHU==5)
|
if(zHU==5)
|
leftSelect1 = 2;
|
leftSelect1 = 2;
|
else
|
else
|
leftSelect1 = 3;
|
leftSelect1 = 3;
|
leftSelect2 = 3;
|
leftSelect2 = 3;
|
leftSelect3 = 3;
|
leftSelect3 = 3;
|
end
|
end
|
tempVal1 = zeroExtend(intra4x4SelectLeft(leftValSet,leftSelect1));
|
tempVal1 = zeroExtend(intra4x4SelectLeft(leftValSet,leftSelect1));
|
tempVal2 = zeroExtend(intra4x4SelectLeft(leftValSet,leftSelect2));
|
tempVal2 = zeroExtend(intra4x4SelectLeft(leftValSet,leftSelect2));
|
tempVal3 = zeroExtend(intra4x4SelectLeft(leftValSet,leftSelect3));
|
tempVal3 = zeroExtend(intra4x4SelectLeft(leftValSet,leftSelect3));
|
Bit#(10) predVal = tempVal1 + (tempVal2<<1) + tempVal3 + 2;
|
Bit#(10) predVal = tempVal1 + (tempVal2<<1) + tempVal3 + 2;
|
predVector[pixelHor] = predVal[9:2];
|
predVector[pixelHor] = predVal[9:2];
|
end
|
end
|
end
|
end
|
default: $display( "ERROR Prediction: intraProcessStep intra4x4 unknown cur_intra4x4_pred_mode");
|
default: $display( "ERROR Prediction: intraProcessStep intra4x4 unknown cur_intra4x4_pred_mode");
|
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
|
for(Integer pixelHor=0; pixelHor<4; pixelHor=pixelHor+1)
|
for(Integer pixelHor=0; pixelHor<4; pixelHor=pixelHor+1)
|
begin
|
begin
|
Bit#(32) topValSet = select(intraTopVal,blockHor);
|
Bit#(32) topValSet = select(intraTopVal,blockHor);
|
Bit#(8) topVal = select32to8(topValSet,fromInteger(pixelHor));
|
Bit#(8) topVal = select32to8(topValSet,fromInteger(pixelHor));
|
predVector[pixelHor] = topVal;
|
predVector[pixelHor] = topVal;
|
end
|
end
|
outFlag = 1;
|
outFlag = 1;
|
end
|
end
|
1://horizontal
|
1://horizontal
|
begin
|
begin
|
Bit#(40) leftValSet = select(intraLeftVal,blockVer);
|
Bit#(40) leftValSet = select(intraLeftVal,blockVer);
|
Bit#(8) leftVal = intra4x4SelectLeft(leftValSet,zeroExtend(pixelVer));
|
Bit#(8) leftVal = intra4x4SelectLeft(leftValSet,zeroExtend(pixelVer));
|
for(Integer pixelHor=0; pixelHor<4; pixelHor=pixelHor+1)
|
for(Integer pixelHor=0; pixelHor<4; pixelHor=pixelHor+1)
|
predVector[pixelHor] = leftVal;
|
predVector[pixelHor] = leftVal;
|
outFlag = 1;
|
outFlag = 1;
|
end
|
end
|
2://dc
|
2://dc
|
begin
|
begin
|
case(intraStepCount)
|
case(intraStepCount)
|
2:
|
2:
|
begin
|
begin
|
if(topAvailable == 1)
|
if(topAvailable == 1)
|
begin
|
begin
|
Bit#(32) topValSet = select(intraTopVal,0);
|
Bit#(32) topValSet = select(intraTopVal,0);
|
intraSumA <= zeroExtend(topValSet[7:0])+zeroExtend(topValSet[15:8])+zeroExtend(topValSet[23:16])+zeroExtend(topValSet[31:24]);
|
intraSumA <= zeroExtend(topValSet[7:0])+zeroExtend(topValSet[15:8])+zeroExtend(topValSet[23:16])+zeroExtend(topValSet[31:24]);
|
end
|
end
|
else
|
else
|
begin
|
begin
|
intraSumA <= 0;
|
intraSumA <= 0;
|
nextIntraStepCount = 6;
|
nextIntraStepCount = 6;
|
end
|
end
|
end
|
end
|
3:
|
3:
|
begin
|
begin
|
Bit#(32) topValSet = select(intraTopVal,1);
|
Bit#(32) topValSet = select(intraTopVal,1);
|
intraSumA <= intraSumA+zeroExtend(topValSet[7:0])+zeroExtend(topValSet[15:8])+zeroExtend(topValSet[23:16])+zeroExtend(topValSet[31:24]);
|
intraSumA <= intraSumA+zeroExtend(topValSet[7:0])+zeroExtend(topValSet[15:8])+zeroExtend(topValSet[23:16])+zeroExtend(topValSet[31:24]);
|
end
|
end
|
4:
|
4:
|
begin
|
begin
|
Bit#(32) topValSet = select(intraTopVal,2);
|
Bit#(32) topValSet = select(intraTopVal,2);
|
intraSumA <= intraSumA+zeroExtend(topValSet[7:0])+zeroExtend(topValSet[15:8])+zeroExtend(topValSet[23:16])+zeroExtend(topValSet[31:24]);
|
intraSumA <= intraSumA+zeroExtend(topValSet[7:0])+zeroExtend(topValSet[15:8])+zeroExtend(topValSet[23:16])+zeroExtend(topValSet[31:24]);
|
end
|
end
|
5:
|
5:
|
begin
|
begin
|
Bit#(32) topValSet = select(intraTopVal,3);
|
Bit#(32) topValSet = select(intraTopVal,3);
|
intraSumA <= intraSumA+zeroExtend(topValSet[7:0])+zeroExtend(topValSet[15:8])+zeroExtend(topValSet[23:16])+zeroExtend(topValSet[31:24])+8;
|
intraSumA <= intraSumA+zeroExtend(topValSet[7:0])+zeroExtend(topValSet[15:8])+zeroExtend(topValSet[23:16])+zeroExtend(topValSet[31:24])+8;
|
end
|
end
|
6:
|
6:
|
begin
|
begin
|
if(leftAvailable == 1)
|
if(leftAvailable == 1)
|
begin
|
begin
|
Bit#(40) leftValSet = select(intraLeftVal,0);
|
Bit#(40) leftValSet = select(intraLeftVal,0);
|
intraSumA <= intraSumA+zeroExtend(leftValSet[15:8])+zeroExtend(leftValSet[23:16])+zeroExtend(leftValSet[31:24])+zeroExtend(leftValSet[39:32]);
|
intraSumA <= intraSumA+zeroExtend(leftValSet[15:8])+zeroExtend(leftValSet[23:16])+zeroExtend(leftValSet[31:24])+zeroExtend(leftValSet[39:32]);
|
end
|
end
|
else
|
else
|
nextIntraStepCount = 10;
|
nextIntraStepCount = 10;
|
end
|
end
|
7:
|
7:
|
begin
|
begin
|
Bit#(40) leftValSet = select(intraLeftVal,1);
|
Bit#(40) leftValSet = select(intraLeftVal,1);
|
intraSumA <= intraSumA+zeroExtend(leftValSet[15:8])+zeroExtend(leftValSet[23:16])+zeroExtend(leftValSet[31:24])+zeroExtend(leftValSet[39:32]);
|
intraSumA <= intraSumA+zeroExtend(leftValSet[15:8])+zeroExtend(leftValSet[23:16])+zeroExtend(leftValSet[31:24])+zeroExtend(leftValSet[39:32]);
|
end
|
end
|
8:
|
8:
|
begin
|
begin
|
Bit#(40) leftValSet = select(intraLeftVal,2);
|
Bit#(40) leftValSet = select(intraLeftVal,2);
|
intraSumA <= intraSumA+zeroExtend(leftValSet[15:8])+zeroExtend(leftValSet[23:16])+zeroExtend(leftValSet[31:24])+zeroExtend(leftValSet[39:32]);
|
intraSumA <= intraSumA+zeroExtend(leftValSet[15:8])+zeroExtend(leftValSet[23:16])+zeroExtend(leftValSet[31:24])+zeroExtend(leftValSet[39:32]);
|
end
|
end
|
9:
|
9:
|
begin
|
begin
|
Bit#(40) leftValSet = select(intraLeftVal,3);
|
Bit#(40) leftValSet = select(intraLeftVal,3);
|
intraSumA <= intraSumA+zeroExtend(leftValSet[15:8])+zeroExtend(leftValSet[23:16])+zeroExtend(leftValSet[31:24])+zeroExtend(leftValSet[39:32])+8;
|
intraSumA <= intraSumA+zeroExtend(leftValSet[15:8])+zeroExtend(leftValSet[23:16])+zeroExtend(leftValSet[31:24])+zeroExtend(leftValSet[39:32])+8;
|
end
|
end
|
10:
|
10:
|
begin
|
begin
|
if(leftAvailable == 1 && topAvailable == 1)
|
if(leftAvailable == 1 && topAvailable == 1)
|
intraSumA <= intraSumA >> 5;
|
intraSumA <= intraSumA >> 5;
|
else if(leftAvailable == 1 || topAvailable == 1)
|
else if(leftAvailable == 1 || topAvailable == 1)
|
intraSumA <= intraSumA >> 4;
|
intraSumA <= intraSumA >> 4;
|
else
|
else
|
intraSumA <= 128;
|
intraSumA <= 128;
|
end
|
end
|
11:
|
11:
|
begin
|
begin
|
for(Integer pixelHor=0; pixelHor<4; pixelHor=pixelHor+1)
|
for(Integer pixelHor=0; pixelHor<4; pixelHor=pixelHor+1)
|
predVector[pixelHor] = intraSumA[7:0];
|
predVector[pixelHor] = intraSumA[7:0];
|
outFlag = 1;
|
outFlag = 1;
|
end
|
end
|
default: $display( "ERROR Prediction: intraProcessStep intra16x16 DC unknown intraStepCount");
|
default: $display( "ERROR Prediction: intraProcessStep intra16x16 DC unknown intraStepCount");
|
endcase
|
endcase
|
end
|
end
|
3://plane
|
3://plane
|
begin
|
begin
|
if(intraStepCount == 2)
|
if(intraStepCount == 2)
|
begin
|
begin
|
Bit#(32) topValSet = select(intraTopVal,3);
|
Bit#(32) topValSet = select(intraTopVal,3);
|
Bit#(8) topVal = select32to8(topValSet,3);
|
Bit#(8) topVal = select32to8(topValSet,3);
|
Bit#(40) leftValSet = select(intraLeftVal,3);
|
Bit#(40) leftValSet = select(intraLeftVal,3);
|
Bit#(8) leftVal = intra4x4SelectLeft(leftValSet,3);
|
Bit#(8) leftVal = intra4x4SelectLeft(leftValSet,3);
|
Bit#(13) tempVal = zeroExtend(topVal) + zeroExtend(leftVal);
|
Bit#(13) tempVal = zeroExtend(topVal) + zeroExtend(leftVal);
|
intraSumA <= tempVal << 4;
|
intraSumA <= tempVal << 4;
|
intraSumB <= 0;
|
intraSumB <= 0;
|
intraSumC <= 0;
|
intraSumC <= 0;
|
end
|
end
|
else if(intraStepCount < 11)
|
else if(intraStepCount < 11)
|
begin
|
begin
|
Bit#(4) xyPlusOne = intraStepCount-2;
|
Bit#(4) xyPlusOne = intraStepCount-2;
|
Bit#(4) xyPlusEight = intraStepCount+5;
|
Bit#(4) xyPlusEight = intraStepCount+5;
|
Bit#(4) sixMinusXY = 9-intraStepCount;
|
Bit#(4) sixMinusXY = 9-intraStepCount;
|
Bit#(32) topValSet1 = select(intraTopVal,xyPlusEight[3:2]);
|
Bit#(32) topValSet1 = select(intraTopVal,xyPlusEight[3:2]);
|
Bit#(8) topVal1 = select32to8(topValSet1,xyPlusEight[1:0]);
|
Bit#(8) topVal1 = select32to8(topValSet1,xyPlusEight[1:0]);
|
Bit#(40) leftValSet1 = select(intraLeftVal,xyPlusEight[3:2]);
|
Bit#(40) leftValSet1 = select(intraLeftVal,xyPlusEight[3:2]);
|
Bit#(8) leftVal1 = intra4x4SelectLeft(leftValSet1,zeroExtend(xyPlusEight[1:0]));
|
Bit#(8) leftVal1 = intra4x4SelectLeft(leftValSet1,zeroExtend(xyPlusEight[1:0]));
|
Bit#(32) topValSet2=0;
|
Bit#(32) topValSet2=0;
|
Bit#(8) topVal2;
|
Bit#(8) topVal2;
|
Bit#(40) leftValSet2;
|
Bit#(40) leftValSet2;
|
Bit#(8) leftVal2;
|
Bit#(8) leftVal2;
|
if(intraStepCount==10)
|
if(intraStepCount==10)
|
begin
|
begin
|
leftValSet2 = select(intraLeftVal,0);
|
leftValSet2 = select(intraLeftVal,0);
|
leftVal2 = intra4x4SelectLeft(leftValSet2,-1);
|
leftVal2 = intra4x4SelectLeft(leftValSet2,-1);
|
topVal2 = leftVal2;
|
topVal2 = leftVal2;
|
end
|
end
|
else
|
else
|
begin
|
begin
|
topValSet2 = select(intraTopVal,sixMinusXY[3:2]);
|
topValSet2 = select(intraTopVal,sixMinusXY[3:2]);
|
topVal2 = select32to8(topValSet2,sixMinusXY[1:0]);
|
topVal2 = select32to8(topValSet2,sixMinusXY[1:0]);
|
leftValSet2 = select(intraLeftVal,sixMinusXY[3:2]);
|
leftValSet2 = select(intraLeftVal,sixMinusXY[3:2]);
|
leftVal2 = intra4x4SelectLeft(leftValSet2,zeroExtend(sixMinusXY[1:0]));
|
leftVal2 = intra4x4SelectLeft(leftValSet2,zeroExtend(sixMinusXY[1:0]));
|
end
|
end
|
Bit#(15) diffH = zeroExtend(topVal1) - zeroExtend(topVal2);
|
Bit#(15) diffH = zeroExtend(topVal1) - zeroExtend(topVal2);
|
Bit#(15) diffV = zeroExtend(leftVal1) - zeroExtend(leftVal2);
|
Bit#(15) diffV = zeroExtend(leftVal1) - zeroExtend(leftVal2);
|
intraSumB <= intraSumB + (zeroExtend(xyPlusOne) * diffH);
|
intraSumB <= intraSumB + (zeroExtend(xyPlusOne) * diffH);
|
intraSumC <= intraSumC + (zeroExtend(xyPlusOne) * diffV);
|
intraSumC <= intraSumC + (zeroExtend(xyPlusOne) * diffV);
|
end
|
end
|
else if(intraStepCount == 11)
|
else if(intraStepCount == 11)
|
begin
|
begin
|
Bit#(18) tempSumB = (5*signExtend(intraSumB)) + 32;
|
Bit#(18) tempSumB = (5*signExtend(intraSumB)) + 32;
|
Bit#(18) tempSumC = (5*signExtend(intraSumC)) + 32;
|
Bit#(18) tempSumC = (5*signExtend(intraSumC)) + 32;
|
intraSumB <= signExtend(tempSumB[17:6]);
|
intraSumB <= signExtend(tempSumB[17:6]);
|
intraSumC <= signExtend(tempSumC[17:6]);
|
intraSumC <= signExtend(tempSumC[17:6]);
|
end
|
end
|
else if(intraStepCount == 12)
|
else if(intraStepCount == 12)
|
begin
|
begin
|
for(Integer pixelHor=0; pixelHor<4; pixelHor=pixelHor+1)
|
for(Integer pixelHor=0; pixelHor<4; pixelHor=pixelHor+1)
|
begin
|
begin
|
Bit#(5) positionHor = {1'b0,blockHor,fromInteger(pixelHor)};
|
Bit#(5) positionHor = {1'b0,blockHor,fromInteger(pixelHor)};
|
Bit#(5) positionVer = {1'b0,blockVer,pixelVer};
|
Bit#(5) positionVer = {1'b0,blockVer,pixelVer};
|
Bit#(16) tempProductB = signExtend(intraSumB) * signExtend(positionHor-7);
|
Bit#(16) tempProductB = signExtend(intraSumB) * signExtend(positionHor-7);
|
Bit#(16) tempProductC = signExtend(intraSumC) * signExtend(positionVer-7);
|
Bit#(16) tempProductC = signExtend(intraSumC) * signExtend(positionVer-7);
|
Bit#(16) tempTotal = tempProductB + tempProductC + zeroExtend(intraSumA) + 16;
|
Bit#(16) tempTotal = tempProductB + tempProductC + zeroExtend(intraSumA) + 16;
|
if(tempTotal[15]==1)
|
if(tempTotal[15]==1)
|
predVector[pixelHor] = 0;
|
predVector[pixelHor] = 0;
|
else if(tempTotal[14:5] > 255)
|
else if(tempTotal[14:5] > 255)
|
predVector[pixelHor] = 255;
|
predVector[pixelHor] = 255;
|
else
|
else
|
predVector[pixelHor] = tempTotal[12:5];
|
predVector[pixelHor] = tempTotal[12:5];
|
end
|
end
|
outFlag = 1;
|
outFlag = 1;
|
end
|
end
|
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)
|
begin
|
begin
|
tempLeftVec = intraLeftValChroma0;
|
tempLeftVec = intraLeftValChroma0;
|
tempTopVec = intraTopValChroma0;
|
tempTopVec = intraTopValChroma0;
|
end
|
end
|
else
|
else
|
begin
|
begin
|
tempLeftVec = intraLeftValChroma1;
|
tempLeftVec = intraLeftValChroma1;
|
tempTopVec = intraTopValChroma1;
|
tempTopVec = intraTopValChroma1;
|
end
|
end
|
case(intra_chroma_pred_mode.first())
|
case(intra_chroma_pred_mode.first())
|
0://dc
|
0://dc
|
begin
|
begin
|
if(intraStepCount == 2)
|
if(intraStepCount == 2)
|
begin
|
begin
|
Bit#(1) useTop=0;
|
Bit#(1) useTop=0;
|
Bit#(1) useLeft=0;
|
Bit#(1) useLeft=0;
|
if(blockNum[1:0] == 0 || blockNum[1:0] == 3)
|
if(blockNum[1:0] == 0 || blockNum[1:0] == 3)
|
begin
|
begin
|
useTop = intraChromaTopAvailable;
|
useTop = intraChromaTopAvailable;
|
useLeft = intraChromaLeftAvailable;
|
useLeft = intraChromaLeftAvailable;
|
end
|
end
|
else if(blockNum[1:0] == 1)
|
else if(blockNum[1:0] == 1)
|
begin
|
begin
|
if(intraChromaTopAvailable == 1)
|
if(intraChromaTopAvailable == 1)
|
useTop = 1;
|
useTop = 1;
|
else if(intraChromaLeftAvailable == 1)
|
else if(intraChromaLeftAvailable == 1)
|
useLeft = 1;
|
useLeft = 1;
|
end
|
end
|
else if(blockNum[1:0] == 2)
|
else if(blockNum[1:0] == 2)
|
begin
|
begin
|
if(intraChromaLeftAvailable == 1)
|
if(intraChromaLeftAvailable == 1)
|
useLeft = 1;
|
useLeft = 1;
|
else if(intraChromaTopAvailable == 1)
|
else if(intraChromaTopAvailable == 1)
|
useTop = 1;
|
useTop = 1;
|
end
|
end
|
else
|
else
|
$display( "ERROR Prediction: intraProcessStep intraChroma dc unknown blockNum");
|
$display( "ERROR Prediction: intraProcessStep intraChroma dc unknown blockNum");
|
Bit#(10) topSum;
|
Bit#(10) topSum;
|
Bit#(10) leftSum;
|
Bit#(10) leftSum;
|
Bit#(11) totalSum;
|
Bit#(11) totalSum;
|
if(blockHor[0] == 0)
|
if(blockHor[0] == 0)
|
topSum = zeroExtend(tempTopVec[0][15:8])+zeroExtend(tempTopVec[0][7:0])+zeroExtend(tempTopVec[1][15:8])+zeroExtend(tempTopVec[1][7:0])+2;
|
topSum = zeroExtend(tempTopVec[0][15:8])+zeroExtend(tempTopVec[0][7:0])+zeroExtend(tempTopVec[1][15:8])+zeroExtend(tempTopVec[1][7:0])+2;
|
else
|
else
|
topSum = zeroExtend(tempTopVec[2][15:8])+zeroExtend(tempTopVec[2][7:0])+zeroExtend(tempTopVec[3][15:8])+zeroExtend(tempTopVec[3][7:0])+2;
|
topSum = zeroExtend(tempTopVec[2][15:8])+zeroExtend(tempTopVec[2][7:0])+zeroExtend(tempTopVec[3][15:8])+zeroExtend(tempTopVec[3][7:0])+2;
|
if(blockVer[0] == 0)
|
if(blockVer[0] == 0)
|
leftSum = zeroExtend(tempLeftVec[1])+zeroExtend(tempLeftVec[2])+zeroExtend(tempLeftVec[3])+zeroExtend(tempLeftVec[4])+2;
|
leftSum = zeroExtend(tempLeftVec[1])+zeroExtend(tempLeftVec[2])+zeroExtend(tempLeftVec[3])+zeroExtend(tempLeftVec[4])+2;
|
else
|
else
|
leftSum = zeroExtend(tempLeftVec[5])+zeroExtend(tempLeftVec[6])+zeroExtend(tempLeftVec[7])+zeroExtend(tempLeftVec[8])+2;
|
leftSum = zeroExtend(tempLeftVec[5])+zeroExtend(tempLeftVec[6])+zeroExtend(tempLeftVec[7])+zeroExtend(tempLeftVec[8])+2;
|
totalSum = zeroExtend(topSum) + zeroExtend(leftSum);
|
totalSum = zeroExtend(topSum) + zeroExtend(leftSum);
|
if(useTop==1 && useLeft==1)
|
if(useTop==1 && useLeft==1)
|
intraSumA <= zeroExtend(totalSum[10:3]);
|
intraSumA <= zeroExtend(totalSum[10:3]);
|
else if(useTop==1)
|
else if(useTop==1)
|
intraSumA <= zeroExtend(topSum[9:2]);
|
intraSumA <= zeroExtend(topSum[9:2]);
|
else if(useLeft==1)
|
else if(useLeft==1)
|
intraSumA <= zeroExtend(leftSum[9:2]);
|
intraSumA <= zeroExtend(leftSum[9:2]);
|
else
|
else
|
intraSumA <= zeroExtend(8'b10000000);
|
intraSumA <= zeroExtend(8'b10000000);
|
end
|
end
|
else if(intraStepCount == 3)
|
else if(intraStepCount == 3)
|
begin
|
begin
|
for(Integer pixelHor=0; pixelHor<4; pixelHor=pixelHor+1)
|
for(Integer pixelHor=0; pixelHor<4; pixelHor=pixelHor+1)
|
predVector[pixelHor] = intraSumA[7:0];
|
predVector[pixelHor] = intraSumA[7:0];
|
outFlag = 1;
|
outFlag = 1;
|
end
|
end
|
else
|
else
|
$display( "ERROR Prediction: intraProcessStep intraChroma dc unknown intraStepCount");
|
$display( "ERROR Prediction: intraProcessStep intraChroma dc unknown intraStepCount");
|
end
|
end
|
1://horizontal
|
1://horizontal
|
begin
|
begin
|
for(Integer pixelHor=0; pixelHor<4; pixelHor=pixelHor+1)
|
for(Integer pixelHor=0; pixelHor<4; pixelHor=pixelHor+1)
|
begin
|
begin
|
Bit#(4) tempLeftIdx = {1'b0,blockVer[0],pixelVer} + 1;
|
Bit#(4) tempLeftIdx = {1'b0,blockVer[0],pixelVer} + 1;
|
predVector[pixelHor] = select(tempLeftVec,tempLeftIdx);
|
predVector[pixelHor] = select(tempLeftVec,tempLeftIdx);
|
end
|
end
|
outFlag = 1;
|
outFlag = 1;
|
end
|
end
|
2://vertical
|
2://vertical
|
begin
|
begin
|
for(Integer pixelHor=0; pixelHor<4; pixelHor=pixelHor+1)
|
for(Integer pixelHor=0; pixelHor<4; pixelHor=pixelHor+1)
|
begin
|
begin
|
Bit#(2) pixelHorTemp = fromInteger(pixelHor);
|
Bit#(2) pixelHorTemp = fromInteger(pixelHor);
|
Bit#(16) tempTopVal = select(tempTopVec,{blockHor[0],pixelHorTemp[1]});
|
Bit#(16) tempTopVal = select(tempTopVec,{blockHor[0],pixelHorTemp[1]});
|
if(pixelHorTemp[0] == 0)
|
if(pixelHorTemp[0] == 0)
|
predVector[pixelHor] = tempTopVal[7:0];
|
predVector[pixelHor] = tempTopVal[7:0];
|
else
|
else
|
predVector[pixelHor] = tempTopVal[15:8];
|
predVector[pixelHor] = tempTopVal[15:8];
|
end
|
end
|
outFlag = 1;
|
outFlag = 1;
|
end
|
end
|
3://plane
|
3://plane
|
begin
|
begin
|
if(intraStepCount == 2)
|
if(intraStepCount == 2)
|
begin
|
begin
|
Bit#(16) topValSet = tempTopVec[3];
|
Bit#(16) topValSet = tempTopVec[3];
|
Bit#(8) topVal = topValSet[15:8];
|
Bit#(8) topVal = topValSet[15:8];
|
Bit#(8) leftVal = tempLeftVec[8];
|
Bit#(8) leftVal = tempLeftVec[8];
|
Bit#(13) tempVal = zeroExtend(topVal) + zeroExtend(leftVal);
|
Bit#(13) tempVal = zeroExtend(topVal) + zeroExtend(leftVal);
|
intraSumA <= tempVal << 4;
|
intraSumA <= tempVal << 4;
|
intraSumB <= 0;
|
intraSumB <= 0;
|
intraSumC <= 0;
|
intraSumC <= 0;
|
end
|
end
|
else if(intraStepCount < 7)
|
else if(intraStepCount < 7)
|
begin
|
begin
|
Bit#(3) xyPlusOne = truncate(intraStepCount)-2;
|
Bit#(3) xyPlusOne = truncate(intraStepCount)-2;
|
Bit#(3) xyPlusFour = truncate(intraStepCount)+1;
|
Bit#(3) xyPlusFour = truncate(intraStepCount)+1;
|
Bit#(4) twoMinusXY = 5-intraStepCount;
|
Bit#(4) twoMinusXY = 5-intraStepCount;
|
Bit#(16) topValSet1 = select(tempTopVec,xyPlusFour[2:1]);
|
Bit#(16) topValSet1 = select(tempTopVec,xyPlusFour[2:1]);
|
Bit#(8) topVal1 = select16to8(topValSet1,xyPlusFour[0]);
|
Bit#(8) topVal1 = select16to8(topValSet1,xyPlusFour[0]);
|
Bit#(4) tempLeftIdx1 = {1'b0,xyPlusFour} + 1;
|
Bit#(4) tempLeftIdx1 = {1'b0,xyPlusFour} + 1;
|
Bit#(8) leftVal1 = select(tempLeftVec,tempLeftIdx1);
|
Bit#(8) leftVal1 = select(tempLeftVec,tempLeftIdx1);
|
|
|
Bit#(16) topValSet2 = select(tempTopVec,twoMinusXY[2:1]);
|
Bit#(16) topValSet2 = select(tempTopVec,twoMinusXY[2:1]);
|
Bit#(8) topVal2;
|
Bit#(8) topVal2;
|
Bit#(8) leftVal2 = select(tempLeftVec,twoMinusXY+1);
|
Bit#(8) leftVal2 = select(tempLeftVec,twoMinusXY+1);
|
if(intraStepCount==6)
|
if(intraStepCount==6)
|
topVal2 = leftVal2;
|
topVal2 = leftVal2;
|
else
|
else
|
topVal2 = select16to8(topValSet2,twoMinusXY[0]);
|
topVal2 = select16to8(topValSet2,twoMinusXY[0]);
|
Bit#(15) diffH = zeroExtend(topVal1) - zeroExtend(topVal2);
|
Bit#(15) diffH = zeroExtend(topVal1) - zeroExtend(topVal2);
|
Bit#(15) diffV = zeroExtend(leftVal1) - zeroExtend(leftVal2);
|
Bit#(15) diffV = zeroExtend(leftVal1) - zeroExtend(leftVal2);
|
intraSumB <= intraSumB + (zeroExtend(xyPlusOne) * diffH);
|
intraSumB <= intraSumB + (zeroExtend(xyPlusOne) * diffH);
|
intraSumC <= intraSumC + (zeroExtend(xyPlusOne) * diffV);
|
intraSumC <= intraSumC + (zeroExtend(xyPlusOne) * diffV);
|
Int#(15) tempDisplayH = unpack(zeroExtend(xyPlusOne) * diffH);
|
Int#(15) tempDisplayH = unpack(zeroExtend(xyPlusOne) * diffH);
|
Int#(15) tempDisplayV = unpack(zeroExtend(xyPlusOne) * diffV);
|
Int#(15) tempDisplayV = unpack(zeroExtend(xyPlusOne) * diffV);
|
//$display( "TRACE Prediction: intraProcessStep intraChroma plane partH partV %0d %0d",tempDisplayH,tempDisplayV);////////////////////
|
//$display( "TRACE Prediction: intraProcessStep intraChroma plane partH partV %0d %0d",tempDisplayH,tempDisplayV);////////////////////
|
end
|
end
|
else if(intraStepCount == 7)
|
else if(intraStepCount == 7)
|
begin
|
begin
|
Int#(15) tempDisplayH = unpack(intraSumB);
|
Int#(15) tempDisplayH = unpack(intraSumB);
|
Int#(15) tempDisplayV = unpack(intraSumC);
|
Int#(15) tempDisplayV = unpack(intraSumC);
|
//$display( "TRACE Prediction: intraProcessStep intraChroma plane H V %0d %0d",tempDisplayH,tempDisplayV);////////////////////
|
//$display( "TRACE Prediction: intraProcessStep intraChroma plane H V %0d %0d",tempDisplayH,tempDisplayV);////////////////////
|
Bit#(19) tempSumB = (34*signExtend(intraSumB)) + 32;
|
Bit#(19) tempSumB = (34*signExtend(intraSumB)) + 32;
|
Bit#(19) tempSumC = (34*signExtend(intraSumC)) + 32;
|
Bit#(19) tempSumC = (34*signExtend(intraSumC)) + 32;
|
intraSumB <= signExtend(tempSumB[18:6]);
|
intraSumB <= signExtend(tempSumB[18:6]);
|
intraSumC <= signExtend(tempSumC[18:6]);
|
intraSumC <= signExtend(tempSumC[18:6]);
|
end
|
end
|
else if(intraStepCount == 8)
|
else if(intraStepCount == 8)
|
begin
|
begin
|
for(Integer pixelHor=0; pixelHor<4; pixelHor=pixelHor+1)
|
for(Integer pixelHor=0; pixelHor<4; pixelHor=pixelHor+1)
|
begin
|
begin
|
Bit#(4) positionHor = {1'b0,blockHor[0],fromInteger(pixelHor)};
|
Bit#(4) positionHor = {1'b0,blockHor[0],fromInteger(pixelHor)};
|
Bit#(4) positionVer = {1'b0,blockVer[0],pixelVer};
|
Bit#(4) positionVer = {1'b0,blockVer[0],pixelVer};
|
Bit#(17) tempProductB = signExtend(intraSumB) * signExtend(positionHor-3);
|
Bit#(17) tempProductB = signExtend(intraSumB) * signExtend(positionHor-3);
|
Bit#(17) tempProductC = signExtend(intraSumC) * signExtend(positionVer-3);
|
Bit#(17) tempProductC = signExtend(intraSumC) * signExtend(positionVer-3);
|
Bit#(17) tempTotal = tempProductB + tempProductC + zeroExtend(intraSumA) + 16;
|
Bit#(17) tempTotal = tempProductB + tempProductC + zeroExtend(intraSumA) + 16;
|
if(tempTotal[16]==1)
|
if(tempTotal[16]==1)
|
predVector[pixelHor] = 0;
|
predVector[pixelHor] = 0;
|
else if(tempTotal[15:5] > 255)
|
else if(tempTotal[15:5] > 255)
|
predVector[pixelHor] = 255;
|
predVector[pixelHor] = 255;
|
else
|
else
|
predVector[pixelHor] = tempTotal[12:5];
|
predVector[pixelHor] = tempTotal[12:5];
|
end
|
end
|
outFlag = 1;
|
outFlag = 1;
|
end
|
end
|
else
|
else
|
$display( "ERROR Prediction: intraProcessStep intraChroma plane unknown intraStepCount");
|
$display( "ERROR Prediction: intraProcessStep intraChroma plane unknown intraStepCount");
|
end
|
end
|
endcase
|
endcase
|
end
|
end
|
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
|
blockNum <= blockNum+1;
|
blockNum <= blockNum+1;
|
if(intra_chroma_pred_mode.first()==0)
|
if(intra_chroma_pred_mode.first()==0)
|
intraStepCount <= 2;
|
intraStepCount <= 2;
|
else if(blockNum==3)
|
else if(blockNum==3)
|
intraStepCount <= 2;
|
intraStepCount <= 2;
|
end
|
end
|
end
|
end
|
end
|
end
|
end
|
end
|
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
|
|
|