Line 28... |
Line 28... |
package mkInterpolator;
|
package mkInterpolator;
|
|
|
import H264Types::*;
|
import H264Types::*;
|
import IInterpolator::*;
|
import IInterpolator::*;
|
import FIFO::*;
|
import FIFO::*;
|
|
import FIFOF::*;
|
import Vector::*;
|
import Vector::*;
|
|
|
import Connectable::*;
|
import Connectable::*;
|
import GetPut::*;
|
import GetPut::*;
|
import ClientServer::*;
|
import ClientServer::*;
|
Line 119... |
Line 120... |
|
|
Reg#(Bit#(2)) outBlockNum <- mkReg(0);
|
Reg#(Bit#(2)) outBlockNum <- mkReg(0);
|
Reg#(Bit#(2)) outPixelNum <- mkReg(0);
|
Reg#(Bit#(2)) outPixelNum <- mkReg(0);
|
Reg#(Bool) outDone <- mkReg(False);
|
Reg#(Bool) outDone <- mkReg(False);
|
|
|
|
Reg#(Bit#(64)) total_cycles <- mkReg(0);
|
|
|
|
|
|
rule incr;
|
|
total_cycles <= total_cycles + 1;
|
|
endrule
|
|
|
rule sendEndOfFrameReq( endOfFrameFlag );
|
rule sendEndOfFrameReq( endOfFrameFlag );
|
endOfFrameFlag <= False;
|
endOfFrameFlag <= False;
|
|
$display("trace interpolator sending EndOfFrame");
|
memReqQ.enq(IPLoadEndFrame);
|
memReqQ.enq(IPLoadEndFrame);
|
endrule
|
endrule
|
|
|
|
|
rule loadLuma( reqfifoLoad.first() matches tagged IPLuma .reqdata &&& !endOfFrameFlag );
|
rule loadLuma( reqfifoLoad.first() matches tagged IPLuma .reqdata &&& !endOfFrameFlag );
|
Line 167... |
Line 175... |
if(verTemp>=zeroExtend({picHeight,4'b0000}))
|
if(verTemp>=zeroExtend({picHeight,4'b0000}))
|
verAddr = {picHeight-1,4'b1111};
|
verAddr = {picHeight-1,4'b1111};
|
else
|
else
|
verAddr = truncate(verTemp);
|
verAddr = truncate(verTemp);
|
end
|
end
|
|
$display("PARDEBLOCK issuing Luma memory req");
|
memReqQ.enq(IPLoadLuma {refIdx:reqdata.refIdx,horOutOfBounds:horOut,hor:horAddr,ver:verAddr});
|
memReqQ.enq(IPLoadLuma {refIdx:reqdata.refIdx,horOutOfBounds:horOut,hor:horAddr,ver:verAddr});
|
Bool verFirst = twoStage || (yfracl==2&&(xfracl==1||xfracl==3));
|
Bool verFirst = twoStage || (yfracl==2&&(xfracl==1||xfracl==3));
|
Bit#(2) loadHorNumMax = (reqdata.bt==IP8x8||reqdata.bt==IP8x4 ? 1 : 0) + (horInter ? 2 : (offset2==0 ? 0 : 1));
|
Bit#(2) loadHorNumMax = (reqdata.bt==IP8x8||reqdata.bt==IP8x4 ? 1 : 0) + (horInter ? 2 : (offset2==0 ? 0 : 1));
|
Bit#(4) loadVerNumMax = (reqdata.bt==IP8x8||reqdata.bt==IP4x8 ? 7 : 3) + (verInter ? 5 : 0);
|
Bit#(4) loadVerNumMax = (reqdata.bt==IP8x8||reqdata.bt==IP4x8 ? 7 : 3) + (verInter ? 5 : 0);
|
if(verFirst)
|
if(verFirst)
|
Line 233... |
Line 242... |
end
|
end
|
end
|
end
|
end
|
end
|
if(reqdata.bt==IP16x16 || reqdata.bt==IP16x8 || reqdata.bt==IP8x16)
|
if(reqdata.bt==IP16x16 || reqdata.bt==IP16x8 || reqdata.bt==IP8x16)
|
$display( "ERROR Interpolation: loadLuma block sizes > 8x8 not supported");
|
$display( "ERROR Interpolation: loadLuma block sizes > 8x8 not supported");
|
$display( "PARDEBLOCK Trace interpolator: loadLuma %h %h %h %h %h %h %h", xfracl, yfracl, loadHorNum, loadVerNum, reqdata.refIdx, horAddr, verAddr);
|
$display( "PARDEBLOCK Trace interpolator(%0d)): loadLuma %h %h %h %h %h %h %h", total_cycles,xfracl, yfracl, loadHorNum, loadVerNum, reqdata.refIdx, horAddr, verAddr);
|
endrule
|
endrule
|
|
|
|
|
rule loadChroma( reqfifoLoad.first() matches tagged IPChroma .reqdata &&& !endOfFrameFlag );
|
rule loadChroma( reqfifoLoad.first() matches tagged IPChroma .reqdata &&& !endOfFrameFlag );
|
Bit#(3) xfracc = reqdata.mvhor[2:0];
|
Bit#(3) xfracc = reqdata.mvhor[2:0];
|
Line 272... |
Line 281... |
if(verTemp>=zeroExtend({picHeight,3'b000}))
|
if(verTemp>=zeroExtend({picHeight,3'b000}))
|
verAddr = {picHeight-1,3'b111};
|
verAddr = {picHeight-1,3'b111};
|
else
|
else
|
verAddr = truncate(verTemp);
|
verAddr = truncate(verTemp);
|
end
|
end
|
|
$display("PARDEBLOCK issuing Chroma memory req");
|
memReqQ.enq(IPLoadChroma {refIdx:reqdata.refIdx,uv:reqdata.uv,horOutOfBounds:horOut,hor:horAddr,ver:verAddr});
|
memReqQ.enq(IPLoadChroma {refIdx:reqdata.refIdx,uv:reqdata.uv,horOutOfBounds:horOut,hor:horAddr,ver:verAddr});
|
Bit#(2) loadHorNumMax = (reqdata.bt==IP4x8||reqdata.bt==IP4x4 ? (offset[1]==0||(xfracc==0&&offset!=3) ? 0 : 1) : ((reqdata.bt==IP16x16||reqdata.bt==IP16x8 ? 1 : 0) + (xfracc==0&&offset==0 ? 0 : 1)));
|
Bit#(2) loadHorNumMax = (reqdata.bt==IP4x8||reqdata.bt==IP4x4 ? (offset[1]==0||(xfracc==0&&offset!=3) ? 0 : 1) : ((reqdata.bt==IP16x16||reqdata.bt==IP16x8 ? 1 : 0) + (xfracc==0&&offset==0 ? 0 : 1)));
|
Bit#(4) loadVerNumMax = (reqdata.bt==IP16x16||reqdata.bt==IP8x16 ? 7 : (reqdata.bt==IP16x8||reqdata.bt==IP8x8||reqdata.bt==IP4x8 ? 3 : 1)) + (yfracc==0 ? 0 : 1);
|
Bit#(4) loadVerNumMax = (reqdata.bt==IP16x16||reqdata.bt==IP8x16 ? 7 : (reqdata.bt==IP16x8||reqdata.bt==IP8x8||reqdata.bt==IP4x8 ? 3 : 1)) + (yfracc==0 ? 0 : 1);
|
if(loadHorNum < loadHorNumMax)
|
if(loadHorNum < loadHorNumMax)
|
loadHorNum <= loadHorNum+1;
|
loadHorNum <= loadHorNum+1;
|
Line 288... |
Line 298... |
begin
|
begin
|
loadVerNum <= 0;
|
loadVerNum <= 0;
|
reqfifoLoad.deq();
|
reqfifoLoad.deq();
|
end
|
end
|
end
|
end
|
$display( "PARDEB Trace interpolator: loadChroma %h %h %h %h %h %h %h", xfracc, yfracc, loadHorNum, loadVerNum, reqdata.refIdx, horAddr, verAddr);
|
$display( "PARDEB Trace interpolator(%0d): loadChroma %h %h %h %h %h %h %h", total_cycles, xfracc, yfracc, loadHorNum, loadVerNum, reqdata.refIdx, horAddr, verAddr);
|
endrule
|
endrule
|
|
|
|
|
rule work1Luma ( reqfifoWork1.first() matches tagged IPWLuma .reqdata &&& !work1Done );
|
rule work1Luma ( reqfifoWork1.first() matches tagged IPWLuma .reqdata &&& !work1Done );
|
let xfracl = reqdata.xFracL;
|
let xfracl = reqdata.xFracL;
|
Line 452... |
Line 462... |
end
|
end
|
end
|
end
|
end
|
end
|
end
|
end
|
work1Vector8 <= work1Vector8Next;
|
work1Vector8 <= work1Vector8Next;
|
$display( "PARDEBLOCK Trace interpolator: work1Luma %h %h %h %h %h %h", xfracl, yfracl, work1HorNum, work1VerNum, offset, work1Stage);
|
$display( "PARDEBLOCK Trace interpolator(%0d): work1Luma %h %h %h %h %h %h", total_cycles, xfracl, yfracl, work1HorNum, work1VerNum, offset, work1Stage);
|
endrule
|
endrule
|
|
|
|
|
rule work2Luma ( reqregWork2 matches tagged Valid .vdata &&& vdata matches tagged IPWLuma .reqdata &&& !work2Done &&& !work8x8Done );
|
rule work2Luma ( reqregWork2 matches tagged Valid .vdata &&& vdata matches tagged IPWLuma .reqdata &&& !work2Done &&& !work8x8Done );
|
let xfracl = reqdata.xFracL;
|
let xfracl = reqdata.xFracL;
|
Line 635... |
Line 645... |
end
|
end
|
end
|
end
|
work2Vector8 <= work2Vector8Next;
|
work2Vector8 <= work2Vector8Next;
|
work2Vector15 <= work2Vector15Next;
|
work2Vector15 <= work2Vector15Next;
|
resultReady <= resultReadyNext;
|
resultReady <= resultReadyNext;
|
$display( "PARDEBLOCK Trace interpolator: work2Luma %h %h %h %h %h", xfracl, yfracl, work2HorNum, work2VerNum, offset);
|
$display( "PARDEBLOCK Trace interpolator%(0d): work2Luma %h %h %h %h %h",total_cycles, xfracl, yfracl, work2HorNum, work2VerNum, offset);
|
endrule
|
endrule
|
|
|
|
|
rule work1Chroma ( reqfifoWork1.first() matches tagged IPWChroma .reqdata &&& !work1Done );
|
rule work1Chroma ( reqfifoWork1.first() matches tagged IPWChroma .reqdata &&& !work1Done );
|
Bit#(4) xfracc = zeroExtend(reqdata.xFracC);
|
Bit#(4) xfracc = zeroExtend(reqdata.xFracC);
|
Line 760... |
Line 770... |
reqfifoWork1.deq();
|
reqfifoWork1.deq();
|
end
|
end
|
end
|
end
|
end
|
end
|
work1Vector8 <= work1Vector8Next;
|
work1Vector8 <= work1Vector8Next;
|
$display( "PARDEBLOCK Trace interpolator: work1Chroma %h %h %h %h %h", xfracc, yfracc, work1HorNum, work1VerNum, offset);
|
$display( "PARDEBLOCK Trace interpolator(%0d): work1Chroma %h %h %h %h %h", total_cycles, xfracc, yfracc, work1HorNum, work1VerNum, offset);
|
endrule
|
endrule
|
|
|
|
|
rule work2Chroma ( reqregWork2 matches tagged Valid .vdata &&& vdata matches tagged IPWChroma .reqdata &&& !work2Done &&& !work8x8Done );
|
rule work2Chroma ( reqregWork2 matches tagged Valid .vdata &&& vdata matches tagged IPWChroma .reqdata &&& !work2Done &&& !work8x8Done );
|
Vector#(16,Bit#(1)) resultReadyNext = resultReady;
|
Vector#(16,Bit#(1)) resultReadyNext = resultReady;
|
Line 781... |
Line 791... |
end
|
end
|
else
|
else
|
work2VerNum <= work2VerNum+1;
|
work2VerNum <= work2VerNum+1;
|
end
|
end
|
resultReady <= resultReadyNext;
|
resultReady <= resultReadyNext;
|
$display( "PARDEBLOCK Trace interpolator: work2Chroma %h %h", work2HorNum, work2VerNum);
|
$display( "PARDEBLOCK Trace interpolator(%0d): work2Chroma %h %h", total_cycles, work2HorNum, work2VerNum);
|
endrule
|
endrule
|
|
|
|
|
rule outputing( !outDone && resultReady[{outBlockNum[1],outPixelNum,outBlockNum[0]}]==1 );
|
rule outputing( !outDone && resultReady[{outBlockNum[1],outPixelNum,outBlockNum[0]}]==1 );
|
outfifo.enq(resultFile.sub({outBlockNum[1],outPixelNum,outBlockNum[0]}));
|
outfifo.enq(resultFile.sub({outBlockNum[1],outPixelNum,outBlockNum[0]}));
|
Line 794... |
Line 804... |
begin
|
begin
|
outBlockNum <= outBlockNum+1;
|
outBlockNum <= outBlockNum+1;
|
if(outBlockNum == 3)
|
if(outBlockNum == 3)
|
outDone <= True;
|
outDone <= True;
|
end
|
end
|
$display( "Trace interpolator: outputing %h %h", outBlockNum, outPixelNum);
|
$display( "PARDEBLOCK Trace interpolator(%0d): outputing %h %h", total_cycles, outBlockNum, outPixelNum);
|
endrule
|
endrule
|
|
|
|
|
rule switching( work1Done && (work2Done || reqregWork2==Invalid) && !work8x8Done);
|
rule switching( work1Done && (work2Done || reqregWork2==Invalid) && !work8x8Done);
|
work1Done <= False;
|
work1Done <= False;
|
Line 846... |
Line 856... |
|
|
method Action deq();
|
method Action deq();
|
outfifo.deq();
|
outfifo.deq();
|
endmethod
|
endmethod
|
|
|
|
|
method Action endOfFrame();
|
method Action endOfFrame();
|
endOfFrameFlag <= True;
|
endOfFrameFlag <= True;
|
endmethod
|
endmethod
|
|
|
interface Client mem_client;
|
method InterpolatorLoadReq mem_request_first();
|
interface Get request = fifoToGet(memReqQ);
|
return memReqQ.first;
|
interface Put response = fifoToPut(memRespQ);
|
endmethod
|
endinterface
|
|
|
method Action mem_request_deq();
|
|
memReqQ.deq;
|
|
endmethod
|
|
|
|
interface mem_client_resp = fifoToPut(memRespQ);
|
|
|
endmodule
|
endmodule
|
|
|
|
|
endpackage
|
endpackage
|