|
// The MIT License
|
|
|
|
// Copyright (c) 2006-2007 Massachusetts Institute of Technology
|
|
|
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
// of this software and associated documentation files (the "Software"), to deal
|
|
// in the Software without restriction, including without limitation the rights
|
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
// copies of the Software, and to permit persons to whom the Software is
|
|
// furnished to do so, subject to the following conditions:
|
|
|
|
// The above copyright notice and this permission notice shall be included in
|
|
// all copies or substantial portions of the Software.
|
|
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
// 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
|
|
// THE SOFTWARE.
|
//**********************************************************************
|
//**********************************************************************
|
// nC Calculator implementation
|
// nC Calculator implementation
|
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
//
|
//
|
//
|
//
|
|
|
package mkCalc_nC;
|
package mkCalc_nC;
|
|
|
import H264Types::*;
|
import H264Types::*;
|
import ICalc_nC::*;
|
import ICalc_nC::*;
|
import FIFO::*;
|
import FIFO::*;
|
|
|
import Connectable::*;
|
import Connectable::*;
|
import GetPut::*;
|
import GetPut::*;
|
import ClientServer::*;
|
import ClientServer::*;
|
|
|
|
|
(* synthesize *)
|
(* synthesize *)
|
module mkCalc_nC( Calc_nC );
|
module mkCalc_nC( Calc_nC );
|
|
|
Reg#(Bit#(PicWidthSz)) picWidth <- mkReg(maxPicWidthInMB);
|
Reg#(Bit#(PicWidthSz)) picWidth <- mkReg(maxPicWidthInMB);
|
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#(1)) waiting <- mkReg(0);
|
Reg#(Bit#(1)) waiting <- mkReg(0);
|
Reg#(Bit#(1)) reqCount <- mkReg(0);
|
Reg#(Bit#(1)) reqCount <- mkReg(0);
|
Reg#(Bit#(2)) respCount <- mkReg(0);
|
Reg#(Bit#(2)) respCount <- mkReg(0);
|
Reg#(Bit#(1)) ipcmCount <- mkReg(0);
|
Reg#(Bit#(1)) ipcmCount <- mkReg(0);
|
Reg#(Bit#(PicAreaSz)) pskipCount <- mkReg(0);
|
Reg#(Bit#(PicAreaSz)) pskipCount <- mkReg(0);
|
Reg#(Bit#(20)) leftVal <- mkReg(0);
|
Reg#(Bit#(20)) leftVal <- mkReg(0);
|
Reg#(Bit#(20)) topVal <- mkReg(0);
|
Reg#(Bit#(20)) topVal <- mkReg(0);
|
Reg#(Bit#(10)) leftValChroma0 <- mkReg(0);
|
Reg#(Bit#(10)) leftValChroma0 <- mkReg(0);
|
Reg#(Bit#(10)) topValChroma0 <- mkReg(0);
|
Reg#(Bit#(10)) topValChroma0 <- mkReg(0);
|
Reg#(Bit#(10)) leftValChroma1 <- mkReg(0);
|
Reg#(Bit#(10)) leftValChroma1 <- mkReg(0);
|
Reg#(Bit#(10)) topValChroma1 <- mkReg(0);
|
Reg#(Bit#(10)) topValChroma1 <- mkReg(0);
|
FIFO#(MemReq#(TAdd#(PicWidthSz,1),20)) memReqQ <- mkFIFO;
|
FIFO#(MemReq#(TAdd#(PicWidthSz,1),20)) memReqQ <- mkFIFO;
|
FIFO#(MemResp#(20)) memRespQ <- mkFIFO;
|
FIFO#(MemResp#(20)) memRespQ <- mkFIFO;
|
Bit#(1) bit1 = 1;
|
Bit#(1) bit1 = 1;
|
Bit#(1) bit0 = 0;
|
Bit#(1) bit0 = 0;
|
|
|
rule currMbHorUpdate( !(currMbHor
|
rule currMbHorUpdate( !(currMbHor
|
Bit#(PicAreaSz) temp = zeroExtend(picWidth);
|
Bit#(PicAreaSz) temp = zeroExtend(picWidth);
|
if((currMbHor >> 3) >= temp)
|
if((currMbHor >> 3) >= temp)
|
currMbHor <= currMbHor - (temp << 3);
|
currMbHor <= currMbHor - (temp << 3);
|
else
|
else
|
currMbHor <= currMbHor - temp;
|
currMbHor <= currMbHor - temp;
|
endrule
|
endrule
|
|
|
rule sendReq ( waiting == 1 && reqCount > 0 );
|
rule sendReq ( waiting == 1 && reqCount > 0 );
|
Bit#(PicWidthSz) temp2 = truncate(currMbHor);
|
Bit#(PicWidthSz) temp2 = truncate(currMbHor);
|
Bit#(TAdd#(PicWidthSz,1)) temp = {bit1,temp2};
|
Bit#(TAdd#(PicWidthSz,1)) temp = {bit1,temp2};
|
memReqQ.enq(tagged LoadReq temp );
|
memReqQ.enq(tagged LoadReq temp );
|
reqCount <= reqCount-1;
|
reqCount <= reqCount-1;
|
endrule
|
endrule
|
|
|
rule receiveResp ( waiting == 1 &&& respCount > 0 &&& memRespQ.first() matches tagged LoadResp .data );
|
rule receiveResp ( waiting == 1 &&& respCount > 0 &&& memRespQ.first() matches tagged LoadResp .data );
|
if( respCount == 2 )
|
if( respCount == 2 )
|
topVal <= data;
|
topVal <= data;
|
else
|
else
|
begin
|
begin
|
topValChroma0 <= data[9:0];
|
topValChroma0 <= data[9:0];
|
topValChroma1 <= data[19:10];
|
topValChroma1 <= data[19:10];
|
waiting <= 0;
|
waiting <= 0;
|
end
|
end
|
memRespQ.deq();
|
memRespQ.deq();
|
respCount <= respCount - 1;
|
respCount <= respCount - 1;
|
endrule
|
endrule
|
|
|
rule ipcmReq ( waiting == 1 && ipcmCount > 0 );
|
rule ipcmReq ( waiting == 1 && ipcmCount > 0 );
|
currMb <= currMb+1;
|
currMb <= currMb+1;
|
currMbHor <= currMbHor+1;
|
currMbHor <= currMbHor+1;
|
Bit#(PicWidthSz) temp2 = truncate(currMbHor);
|
Bit#(PicWidthSz) temp2 = truncate(currMbHor);
|
Bit#(TAdd#(PicWidthSz,1)) temp = {bit1,temp2};
|
Bit#(TAdd#(PicWidthSz,1)) temp = {bit1,temp2};
|
memReqQ.enq(tagged StoreReq {addr:temp,data:20'b10000100001000010000} );
|
memReqQ.enq(tagged StoreReq {addr:temp,data:20'b10000100001000010000} );
|
ipcmCount <= 0;
|
ipcmCount <= 0;
|
waiting <= 0;
|
waiting <= 0;
|
endrule
|
endrule
|
|
|
rule pskipReq ( waiting == 1 && pskipCount > 0 && currMbHor
|
rule pskipReq ( waiting == 1 && pskipCount > 0 && currMbHor
|
if(pskipCount[0] == 1)
|
if(pskipCount[0] == 1)
|
begin
|
begin
|
currMb <= currMb+1;
|
currMb <= currMb+1;
|
currMbHor <= currMbHor+1;
|
currMbHor <= currMbHor+1;
|
Bit#(PicWidthSz) temp2 = truncate(currMbHor);
|
Bit#(PicWidthSz) temp2 = truncate(currMbHor);
|
Bit#(TAdd#(PicWidthSz,1)) temp = {bit1,temp2};
|
Bit#(TAdd#(PicWidthSz,1)) temp = {bit1,temp2};
|
memReqQ.enq(StoreReq {addr:temp,data:20'b00000000000000000000} );
|
memReqQ.enq(StoreReq {addr:temp,data:20'b00000000000000000000} );
|
if(pskipCount == 1)
|
if(pskipCount == 1)
|
waiting <= 0;
|
waiting <= 0;
|
end
|
end
|
else
|
else
|
begin
|
begin
|
Bit#(PicWidthSz) temp2 = truncate(currMbHor);
|
Bit#(PicWidthSz) temp2 = truncate(currMbHor);
|
Bit#(TAdd#(PicWidthSz,1)) temp = {bit0,temp2};
|
Bit#(TAdd#(PicWidthSz,1)) temp = {bit0,temp2};
|
memReqQ.enq(StoreReq {addr:temp,data:20'b00000000000000000000} );
|
memReqQ.enq(StoreReq {addr:temp,data:20'b00000000000000000000} );
|
end
|
end
|
pskipCount <= pskipCount - 1;
|
pskipCount <= pskipCount - 1;
|
endrule
|
endrule
|
|
|
method Action initialize_picWidth( Bit#(PicWidthSz) picWidthInMb ) if( waiting == 0 && currMbHor
|
method Action initialize_picWidth( Bit#(PicWidthSz) picWidthInMb ) if( waiting == 0 && currMbHor
|
picWidth <= picWidthInMb;
|
picWidth <= picWidthInMb;
|
endmethod
|
endmethod
|
|
|
method Action initialize( Bit#(PicAreaSz) firstMbAddr ) if( waiting == 0 && currMbHor
|
method Action initialize( Bit#(PicAreaSz) firstMbAddr ) if( waiting == 0 && currMbHor
|
firstMb <= firstMbAddr;
|
firstMb <= firstMbAddr;
|
currMb <= firstMbAddr;
|
currMb <= firstMbAddr;
|
currMbHor <= firstMbAddr;
|
currMbHor <= firstMbAddr;
|
leftVal <= 0;
|
leftVal <= 0;
|
leftValChroma0 <= 0;
|
leftValChroma0 <= 0;
|
leftValChroma1 <= 0;
|
leftValChroma1 <= 0;
|
endmethod
|
endmethod
|
|
|
method Action loadMb( Bit#(PicAreaSz) mbAddr ) if( waiting == 0 && currMbHor
|
method Action loadMb( Bit#(PicAreaSz) mbAddr ) if( waiting == 0 && currMbHor
|
if( mbAddr != currMb )
|
if( mbAddr != currMb )
|
$display( "ERROR EntropyDec: mkCalc_nC loadMb wrong mbAddr" );
|
$display( "ERROR EntropyDec: mkCalc_nC loadMb wrong mbAddr" );
|
else
|
else
|
begin
|
begin
|
if( currMbHor == 0 || currMb == firstMb)
|
if( currMbHor == 0 || currMb == firstMb)
|
begin
|
begin
|
leftVal <= 20'b11111111111111111111;
|
leftVal <= 20'b11111111111111111111;
|
leftValChroma0 <= 10'b1111111111;
|
leftValChroma0 <= 10'b1111111111;
|
leftValChroma1 <= 10'b1111111111;
|
leftValChroma1 <= 10'b1111111111;
|
end
|
end
|
if( currMb-firstMb < zeroExtend(picWidth) )
|
if( currMb-firstMb < zeroExtend(picWidth) )
|
begin
|
begin
|
topVal <= 20'b11111111111111111111;
|
topVal <= 20'b11111111111111111111;
|
topValChroma0 <= 10'b1111111111;
|
topValChroma0 <= 10'b1111111111;
|
topValChroma1 <= 10'b1111111111;
|
topValChroma1 <= 10'b1111111111;
|
end
|
end
|
else
|
else
|
begin
|
begin
|
waiting <= 1;
|
waiting <= 1;
|
reqCount <= 1;
|
reqCount <= 1;
|
respCount <= 2;
|
respCount <= 2;
|
Bit#(PicWidthSz) temp2 = truncate(currMbHor);
|
Bit#(PicWidthSz) temp2 = truncate(currMbHor);
|
Bit#(TAdd#(PicWidthSz,1)) temp = {bit0,temp2};
|
Bit#(TAdd#(PicWidthSz,1)) temp = {bit0,temp2};
|
memReqQ.enq(tagged LoadReq temp );
|
memReqQ.enq(tagged LoadReq temp );
|
//$display( "ERROR EntropyDec: mkCalc_nC loadMb incomplete" );
|
//$display( "ERROR EntropyDec: mkCalc_nC loadMb incomplete" );
|
end
|
end
|
end
|
end
|
endmethod
|
endmethod
|
|
|
method Bit#(5) nCcalc_luma( Bit#(4) microBlockNum ) if( waiting == 0 && currMbHor
|
method Bit#(5) nCcalc_luma( Bit#(4) microBlockNum ) if( waiting == 0 && currMbHor
|
Bit#(6) templeft = 0;
|
Bit#(6) templeft = 0;
|
Bit#(6) temptop = 0;
|
Bit#(6) temptop = 0;
|
if(microBlockNum[3]==0 && microBlockNum[1]==0)
|
if(microBlockNum[3]==0 && microBlockNum[1]==0)
|
templeft = zeroExtend(leftVal[4:0]);
|
templeft = zeroExtend(leftVal[4:0]);
|
else if(microBlockNum[3]==0 && microBlockNum[1]==1)
|
else if(microBlockNum[3]==0 && microBlockNum[1]==1)
|
templeft = zeroExtend(leftVal[9:5]);
|
templeft = zeroExtend(leftVal[9:5]);
|
else if(microBlockNum[3]==1 && microBlockNum[1]==0)
|
else if(microBlockNum[3]==1 && microBlockNum[1]==0)
|
templeft = zeroExtend(leftVal[14:10]);
|
templeft = zeroExtend(leftVal[14:10]);
|
else
|
else
|
templeft = zeroExtend(leftVal[19:15]);
|
templeft = zeroExtend(leftVal[19:15]);
|
if(microBlockNum[2]==0 && microBlockNum[0]==0)
|
if(microBlockNum[2]==0 && microBlockNum[0]==0)
|
temptop = zeroExtend(topVal[4:0]);
|
temptop = zeroExtend(topVal[4:0]);
|
else if(microBlockNum[2]==0 && microBlockNum[0]==1)
|
else if(microBlockNum[2]==0 && microBlockNum[0]==1)
|
temptop = zeroExtend(topVal[9:5]);
|
temptop = zeroExtend(topVal[9:5]);
|
else if(microBlockNum[2]==1 && microBlockNum[0]==0)
|
else if(microBlockNum[2]==1 && microBlockNum[0]==0)
|
temptop = zeroExtend(topVal[14:10]);
|
temptop = zeroExtend(topVal[14:10]);
|
else
|
else
|
temptop = zeroExtend(topVal[19:15]);
|
temptop = zeroExtend(topVal[19:15]);
|
if(temptop!=6'b011111 && templeft!=6'b011111)
|
if(temptop!=6'b011111 && templeft!=6'b011111)
|
return truncate((temptop+templeft+1) >> 1);
|
return truncate((temptop+templeft+1) >> 1);
|
else if(templeft!=6'b011111)
|
else if(templeft!=6'b011111)
|
return truncate(templeft);
|
return truncate(templeft);
|
else if(temptop!=6'b011111)
|
else if(temptop!=6'b011111)
|
return truncate(temptop);
|
return truncate(temptop);
|
else
|
else
|
return 0;
|
return 0;
|
endmethod
|
endmethod
|
|
|
method Bit#(5) nCcalc_chroma( Bit#(3) microBlockNum ) if( waiting == 0 && currMbHor
|
method Bit#(5) nCcalc_chroma( Bit#(3) microBlockNum ) if( waiting == 0 && currMbHor
|
Bit#(6) templeft = 0;
|
Bit#(6) templeft = 0;
|
Bit#(6) temptop = 0;
|
Bit#(6) temptop = 0;
|
if(microBlockNum[2]==0)
|
if(microBlockNum[2]==0)
|
begin
|
begin
|
if(microBlockNum[1]==0)
|
if(microBlockNum[1]==0)
|
templeft = zeroExtend(leftValChroma0[4:0]);
|
templeft = zeroExtend(leftValChroma0[4:0]);
|
else
|
else
|
templeft = zeroExtend(leftValChroma0[9:5]);
|
templeft = zeroExtend(leftValChroma0[9:5]);
|
if(microBlockNum[0]==0)
|
if(microBlockNum[0]==0)
|
temptop = zeroExtend(topValChroma0[4:0]);
|
temptop = zeroExtend(topValChroma0[4:0]);
|
else
|
else
|
temptop = zeroExtend(topValChroma0[9:5]);
|
temptop = zeroExtend(topValChroma0[9:5]);
|
end
|
end
|
else
|
else
|
begin
|
begin
|
if(microBlockNum[1]==0)
|
if(microBlockNum[1]==0)
|
templeft = zeroExtend(leftValChroma1[4:0]);
|
templeft = zeroExtend(leftValChroma1[4:0]);
|
else
|
else
|
templeft = zeroExtend(leftValChroma1[9:5]);
|
templeft = zeroExtend(leftValChroma1[9:5]);
|
if(microBlockNum[0]==0)
|
if(microBlockNum[0]==0)
|
temptop = zeroExtend(topValChroma1[4:0]);
|
temptop = zeroExtend(topValChroma1[4:0]);
|
else
|
else
|
temptop = zeroExtend(topValChroma1[9:5]);
|
temptop = zeroExtend(topValChroma1[9:5]);
|
end
|
end
|
if(temptop!=6'b011111 && templeft!=6'b011111)
|
if(temptop!=6'b011111 && templeft!=6'b011111)
|
return truncate((temptop+templeft+1) >> 1);
|
return truncate((temptop+templeft+1) >> 1);
|
else if(templeft!=6'b011111)
|
else if(templeft!=6'b011111)
|
return truncate(templeft);
|
return truncate(templeft);
|
else if(temptop!=6'b011111)
|
else if(temptop!=6'b011111)
|
return truncate(temptop);
|
return truncate(temptop);
|
else
|
else
|
return 0;
|
return 0;
|
endmethod
|
endmethod
|
|
|
method Action nNupdate_luma( Bit#(4) microBlockNum, Bit#(5) totalCoeff ) if( waiting == 0 && currMbHor
|
method Action nNupdate_luma( Bit#(4) microBlockNum, Bit#(5) totalCoeff ) if( waiting == 0 && currMbHor
|
Bit#(20) topValTemp = topVal;
|
Bit#(20) topValTemp = topVal;
|
if(microBlockNum[3]==0 && microBlockNum[1]==0)
|
if(microBlockNum[3]==0 && microBlockNum[1]==0)
|
leftVal <= {leftVal[19:5] , totalCoeff};
|
leftVal <= {leftVal[19:5] , totalCoeff};
|
else if(microBlockNum[3]==0 && microBlockNum[1]==1)
|
else if(microBlockNum[3]==0 && microBlockNum[1]==1)
|
leftVal <= {{leftVal[19:10] , totalCoeff} , leftVal[4:0]};
|
leftVal <= {{leftVal[19:10] , totalCoeff} , leftVal[4:0]};
|
else if(microBlockNum[3]==1 && microBlockNum[1]==0)
|
else if(microBlockNum[3]==1 && microBlockNum[1]==0)
|
leftVal <= {{leftVal[19:15] , totalCoeff} , leftVal[9:0]};
|
leftVal <= {{leftVal[19:15] , totalCoeff} , leftVal[9:0]};
|
else
|
else
|
leftVal <= {totalCoeff , leftVal[14:0]};
|
leftVal <= {totalCoeff , leftVal[14:0]};
|
if(microBlockNum[2]==0 && microBlockNum[0]==0)
|
if(microBlockNum[2]==0 && microBlockNum[0]==0)
|
topValTemp = {topVal[19:5] , totalCoeff};
|
topValTemp = {topVal[19:5] , totalCoeff};
|
else if(microBlockNum[2]==0 && microBlockNum[0]==1)
|
else if(microBlockNum[2]==0 && microBlockNum[0]==1)
|
topValTemp = {{topVal[19:10] , totalCoeff} , topVal[4:0]};
|
topValTemp = {{topVal[19:10] , totalCoeff} , topVal[4:0]};
|
else if(microBlockNum[2]==1 && microBlockNum[0]==0)
|
else if(microBlockNum[2]==1 && microBlockNum[0]==0)
|
topValTemp = {{topVal[19:15] , totalCoeff} , topVal[9:0]};
|
topValTemp = {{topVal[19:15] , totalCoeff} , topVal[9:0]};
|
else
|
else
|
topValTemp = {totalCoeff , topVal[14:0]};
|
topValTemp = {totalCoeff , topVal[14:0]};
|
topVal <= topValTemp;
|
topVal <= topValTemp;
|
if(microBlockNum == 15)
|
if(microBlockNum == 15)
|
begin
|
begin
|
Bit#(PicWidthSz) temp2 = truncate(currMbHor);
|
Bit#(PicWidthSz) temp2 = truncate(currMbHor);
|
Bit#(TAdd#(PicWidthSz,1)) temp = {bit0,temp2};
|
Bit#(TAdd#(PicWidthSz,1)) temp = {bit0,temp2};
|
memReqQ.enq(StoreReq {addr:temp,data:topValTemp} );
|
memReqQ.enq(StoreReq {addr:temp,data:topValTemp} );
|
end
|
end
|
//$display( "TRACE nNupdate_luma old leftVal %b", leftVal );
|
//$display( "TRACE nNupdate_luma old leftVal %b", leftVal );
|
//$display( "TRACE nNupdate_luma old topVal %b", topVal );
|
//$display( "TRACE nNupdate_luma old topVal %b", topVal );
|
//$display( "TRACE nNupdate_luma microBlockNum %0d", microBlockNum );
|
//$display( "TRACE nNupdate_luma microBlockNum %0d", microBlockNum );
|
//$display( "TRACE nNupdate_luma totalCoeff %0d", totalCoeff );
|
//$display( "TRACE nNupdate_luma totalCoeff %0d", totalCoeff );
|
endmethod
|
endmethod
|
|
|
method Action nNupdate_chroma( Bit#(3) microBlockNum, Bit#(5) totalCoeff ) if( waiting == 0 && currMbHor
|
method Action nNupdate_chroma( Bit#(3) microBlockNum, Bit#(5) totalCoeff ) if( waiting == 0 && currMbHor
|
Bit#(10) topValChroma0Temp = topValChroma0;
|
Bit#(10) topValChroma0Temp = topValChroma0;
|
Bit#(10) topValChroma1Temp = topValChroma1;
|
Bit#(10) topValChroma1Temp = topValChroma1;
|
if(microBlockNum[2]==0)
|
if(microBlockNum[2]==0)
|
begin
|
begin
|
if(microBlockNum[1]==0)
|
if(microBlockNum[1]==0)
|
leftValChroma0 <= {leftValChroma0[9:5] , totalCoeff};
|
leftValChroma0 <= {leftValChroma0[9:5] , totalCoeff};
|
else
|
else
|
leftValChroma0 <= {totalCoeff , leftValChroma0[4:0]};
|
leftValChroma0 <= {totalCoeff , leftValChroma0[4:0]};
|
if(microBlockNum[0]==0)
|
if(microBlockNum[0]==0)
|
topValChroma0Temp = {topValChroma0[9:5] , totalCoeff};
|
topValChroma0Temp = {topValChroma0[9:5] , totalCoeff};
|
else
|
else
|
topValChroma0Temp = {totalCoeff , topValChroma0[4:0]};
|
topValChroma0Temp = {totalCoeff , topValChroma0[4:0]};
|
end
|
end
|
else
|
else
|
begin
|
begin
|
if(microBlockNum[1]==0)
|
if(microBlockNum[1]==0)
|
leftValChroma1 <= {leftValChroma1[9:5] , totalCoeff};
|
leftValChroma1 <= {leftValChroma1[9:5] , totalCoeff};
|
else
|
else
|
leftValChroma1 <= {totalCoeff , leftValChroma1[4:0]};
|
leftValChroma1 <= {totalCoeff , leftValChroma1[4:0]};
|
if(microBlockNum[0]==0)
|
if(microBlockNum[0]==0)
|
topValChroma1Temp = {topValChroma1[9:5] , totalCoeff};
|
topValChroma1Temp = {topValChroma1[9:5] , totalCoeff};
|
else
|
else
|
topValChroma1Temp = {totalCoeff , topValChroma1[4:0]};
|
topValChroma1Temp = {totalCoeff , topValChroma1[4:0]};
|
end
|
end
|
topValChroma0 <= topValChroma0Temp;
|
topValChroma0 <= topValChroma0Temp;
|
topValChroma1 <= topValChroma1Temp;
|
topValChroma1 <= topValChroma1Temp;
|
if(microBlockNum == 7)
|
if(microBlockNum == 7)
|
begin
|
begin
|
currMb <= currMb+1;
|
currMb <= currMb+1;
|
currMbHor <= currMbHor+1;
|
currMbHor <= currMbHor+1;
|
Bit#(PicWidthSz) temp2 = truncate(currMbHor);
|
Bit#(PicWidthSz) temp2 = truncate(currMbHor);
|
Bit#(TAdd#(PicWidthSz,1)) temp = {bit1,temp2};
|
Bit#(TAdd#(PicWidthSz,1)) temp = {bit1,temp2};
|
memReqQ.enq(StoreReq {addr:temp,data:{topValChroma1Temp,topValChroma0Temp}} );
|
memReqQ.enq(StoreReq {addr:temp,data:{topValChroma1Temp,topValChroma0Temp}} );
|
end
|
end
|
endmethod
|
endmethod
|
|
|
method Action nNupdate_pskip( Bit#(PicAreaSz) inmb_skip_run ) if( waiting == 0 && currMbHor
|
method Action nNupdate_pskip( Bit#(PicAreaSz) inmb_skip_run ) if( waiting == 0 && currMbHor
|
//$display( "TRACE nNupdate_pskip mb_skip_run = %0d", inmb_skip_run );
|
//$display( "TRACE nNupdate_pskip mb_skip_run = %0d", inmb_skip_run );
|
|
|
if(inmb_skip_run > 0)
|
if(inmb_skip_run > 0)
|
begin
|
begin
|
waiting <= 1;
|
waiting <= 1;
|
pskipCount <= (inmb_skip_run << 1)-1;
|
pskipCount <= (inmb_skip_run << 1)-1;
|
Bit#(PicWidthSz) temp2 = truncate(currMbHor);
|
Bit#(PicWidthSz) temp2 = truncate(currMbHor);
|
Bit#(TAdd#(PicWidthSz,1)) temp = {bit0,temp2};
|
Bit#(TAdd#(PicWidthSz,1)) temp = {bit0,temp2};
|
memReqQ.enq(StoreReq {addr:temp,data:20'b00000000000000000000} );
|
memReqQ.enq(StoreReq {addr:temp,data:20'b00000000000000000000} );
|
leftVal <= 0;
|
leftVal <= 0;
|
leftValChroma0 <= 10'b0000000000;
|
leftValChroma0 <= 10'b0000000000;
|
leftValChroma1 <= 10'b0000000000;
|
leftValChroma1 <= 10'b0000000000;
|
end
|
end
|
endmethod
|
endmethod
|
|
|
method Action nNupdate_ipcm() if( waiting == 0 && currMbHor
|
method Action nNupdate_ipcm() if( waiting == 0 && currMbHor
|
leftVal <= 20'b10000100001000010000;
|
leftVal <= 20'b10000100001000010000;
|
leftValChroma0 <= 10'b1000010000;
|
leftValChroma0 <= 10'b1000010000;
|
leftValChroma1 <= 10'b1000010000;
|
leftValChroma1 <= 10'b1000010000;
|
//$display( "TRACE nNupdate_ipcm");
|
//$display( "TRACE nNupdate_ipcm");
|
|
|
waiting <= 1;
|
waiting <= 1;
|
ipcmCount <= 1;
|
ipcmCount <= 1;
|
Bit#(PicWidthSz) temp2 = truncate(currMbHor);
|
Bit#(PicWidthSz) temp2 = truncate(currMbHor);
|
Bit#(TAdd#(PicWidthSz,1)) temp = {bit0,temp2};
|
Bit#(TAdd#(PicWidthSz,1)) temp = {bit0,temp2};
|
memReqQ.enq(StoreReq {addr:temp,data:20'b10000100001000010000} );
|
memReqQ.enq(StoreReq {addr:temp,data:20'b10000100001000010000} );
|
endmethod
|
endmethod
|
|
|
interface Client mem_client;
|
interface Client mem_client;
|
interface Get request = fifoToGet(memReqQ);
|
interface Get request = fifoToGet(memReqQ);
|
interface Put response = fifoToPut(memRespQ);
|
interface Put response = fifoToPut(memRespQ);
|
endinterface
|
endinterface
|
|
|
|
|
endmodule
|
endmodule
|
|
|
|
|
|
|
endpackage
|
endpackage
|
|
|