// 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.
|
//**********************************************************************
|
//**********************************************************************
|
// Buffer Controller
|
// Buffer Controller
|
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
//
|
//
|
//
|
//
|
|
|
package mkBufferControl;
|
package mkBufferControl;
|
|
|
import H264Types::*;
|
import H264Types::*;
|
|
|
import IBufferControl::*;
|
import IBufferControl::*;
|
import FIFO::*;
|
import FIFO::*;
|
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 Idle; //not working on anything in particular
|
void Idle; //not working on anything in particular
|
void Y;
|
void Y;
|
void U;
|
void U;
|
void V;
|
void V;
|
}
|
}
|
Outprocess deriving(Eq,Bits);
|
Outprocess deriving(Eq,Bits);
|
|
|
|
|
//-----------------------------------------------------------
|
//-----------------------------------------------------------
|
// Short term pic list submodule
|
// Short term pic list submodule
|
//-----------------------------------------------------------
|
//-----------------------------------------------------------
|
|
|
typedef union tagged
|
typedef union tagged
|
{
|
{
|
void Idle; //not working on anything in particular
|
void Idle; //not working on anything in particular
|
void Remove;
|
void Remove;
|
void RemoveOutput;
|
void RemoveOutput;
|
void RemoveFound;
|
void RemoveFound;
|
void InsertGap;
|
void InsertGap;
|
void Search;
|
void Search;
|
void ListAll;
|
void ListAll;
|
}
|
}
|
ShortTermPicListState deriving(Eq,Bits);
|
ShortTermPicListState deriving(Eq,Bits);
|
|
|
interface ShortTermPicList;
|
interface ShortTermPicList;
|
method Action clear();
|
method Action clear();
|
method Action insert( Bit#(16) frameNum, Bit#(5) slot, Bit#(5) maxAllowed );
|
method Action insert( Bit#(16) frameNum, Bit#(5) slot, Bit#(5) maxAllowed );
|
method Action insert_gap( Bit#(16) frameNum, Bit#(5) slot, Bit#(5) maxAllowed, Bit#(16) gap, Bit#(5) log2_max_frame_num );
|
method Action insert_gap( Bit#(16) frameNum, Bit#(5) slot, Bit#(5) maxAllowed, Bit#(16) gap, Bit#(5) log2_max_frame_num );
|
method Action remove( Bit#(16) frameNum, Bool removeOutputFlag );
|
method Action remove( Bit#(16) frameNum, Bool removeOutputFlag );
|
method Action search( Bit#(16) frameNum );
|
method Action search( Bit#(16) frameNum );
|
method Action listAll();
|
method Action listAll();
|
method Action deq();
|
method Action deq();
|
method Maybe#(Bit#(5)) resultSlot();
|
method Maybe#(Bit#(5)) resultSlot();
|
method Bit#(5) numPics();
|
method Bit#(5) numPics();
|
endinterface
|
endinterface
|
|
|
module mkShortTermPicList( ShortTermPicList );
|
module mkShortTermPicList( ShortTermPicList );
|
function Bit#(5) shortTermPicListNext( Bit#(5) addrFunc );
|
function Bit#(5) shortTermPicListNext( Bit#(5) addrFunc );
|
if(addrFunc
|
if(addrFunc
|
return addrFunc+1;
|
return addrFunc+1;
|
else
|
else
|
return 0;
|
return 0;
|
endfunction
|
endfunction
|
function Bit#(5) shortTermPicListPrev( Bit#(5) addrFunc );
|
function Bit#(5) shortTermPicListPrev( Bit#(5) addrFunc );
|
if(addrFunc==0)
|
if(addrFunc==0)
|
return maxRefFrames-1;
|
return maxRefFrames-1;
|
else
|
else
|
return addrFunc-1;
|
return addrFunc-1;
|
endfunction
|
endfunction
|
|
|
RFile1#(Bit#(5),Tuple2#(Bit#(16),Bit#(5))) rfile <- mkRFile1(0,maxRefFrames-1);
|
RFile1#(Bit#(5),Tuple2#(Bit#(16),Bit#(5))) rfile <- mkRFile1(0,maxRefFrames-1);
|
Reg#(ShortTermPicListState) state <- mkReg(Idle);
|
Reg#(ShortTermPicListState) state <- mkReg(Idle);
|
Reg#(Bit#(5)) log2_mfn <- mkReg(0);
|
Reg#(Bit#(5)) log2_mfn <- mkReg(0);
|
Reg#(Bit#(5)) nextPic <- mkReg(0);
|
Reg#(Bit#(5)) nextPic <- mkReg(0);
|
Reg#(Bit#(5)) picCount <- mkReg(0);
|
Reg#(Bit#(5)) picCount <- mkReg(0);
|
Reg#(Bit#(5)) tempPic <- mkReg(0);
|
Reg#(Bit#(5)) tempPic <- mkReg(0);
|
Reg#(Bit#(5)) tempCount <- mkReg(0);
|
Reg#(Bit#(5)) tempCount <- mkReg(0);
|
Reg#(Bit#(16)) tempNum <- mkReg(0);
|
Reg#(Bit#(16)) tempNum <- mkReg(0);
|
FIFO#(Maybe#(Bit#(5))) returnList <- mkFIFO();
|
FIFO#(Maybe#(Bit#(5))) returnList <- mkFIFO();
|
|
|
rule removing ( state==Remove || state==RemoveOutput || state==RemoveFound );
|
rule removing ( state==Remove || state==RemoveOutput || state==RemoveFound );
|
if(state!=RemoveFound)
|
if(state!=RemoveFound)
|
begin
|
begin
|
Tuple2#(Bit#(16),Bit#(5)) temp = rfile.sub(tempPic);
|
Tuple2#(Bit#(16),Bit#(5)) temp = rfile.sub(tempPic);
|
if(tpl_1(temp)==tempNum)
|
if(tpl_1(temp)==tempNum)
|
begin
|
begin
|
state <= RemoveFound;
|
state <= RemoveFound;
|
if(state==RemoveOutput)
|
if(state==RemoveOutput)
|
returnList.enq(tagged Valid tpl_2(temp));
|
returnList.enq(tagged Valid tpl_2(temp));
|
end
|
end
|
if(tempCount>=picCount)
|
if(tempCount>=picCount)
|
$display( "ERROR BufferControl: ShortTermPicList removing not found");
|
$display( "ERROR BufferControl: ShortTermPicList removing not found");
|
end
|
end
|
else
|
else
|
begin
|
begin
|
Bit#(5) tempPrev = shortTermPicListPrev(tempPic);
|
Bit#(5) tempPrev = shortTermPicListPrev(tempPic);
|
rfile.upd(tempPrev,rfile.sub(tempPic));
|
rfile.upd(tempPrev,rfile.sub(tempPic));
|
if(tempCount==picCount)
|
if(tempCount==picCount)
|
begin
|
begin
|
picCount <= picCount-1;
|
picCount <= picCount-1;
|
nextPic <= tempPrev;
|
nextPic <= tempPrev;
|
state <= Idle;
|
state <= Idle;
|
end
|
end
|
end
|
end
|
tempCount <= tempCount+1;
|
tempCount <= tempCount+1;
|
tempPic <= shortTermPicListNext(tempPic);
|
tempPic <= shortTermPicListNext(tempPic);
|
endrule
|
endrule
|
|
|
rule insertingGap ( state matches tagged InsertGap );
|
rule insertingGap ( state matches tagged InsertGap );
|
if(tempCount>0)
|
if(tempCount>0)
|
begin
|
begin
|
if(tempCount>1)
|
if(tempCount>1)
|
rfile.upd(nextPic,tuple2(tempNum,31));
|
rfile.upd(nextPic,tuple2(tempNum,31));
|
else
|
else
|
rfile.upd(nextPic,tuple2(tempNum,tempPic));
|
rfile.upd(nextPic,tuple2(tempNum,tempPic));
|
nextPic <= shortTermPicListNext(nextPic);
|
nextPic <= shortTermPicListNext(nextPic);
|
end
|
end
|
else
|
else
|
state <= Idle;
|
state <= Idle;
|
Bit#(17) tempOne = 1;
|
Bit#(17) tempOne = 1;
|
Bit#(17) maxPicNum = tempOne << log2_mfn;
|
Bit#(17) maxPicNum = tempOne << log2_mfn;
|
if(zeroExtend(tempNum) == maxPicNum-1)
|
if(zeroExtend(tempNum) == maxPicNum-1)
|
tempNum <= 0;
|
tempNum <= 0;
|
else
|
else
|
tempNum <= tempNum+1;
|
tempNum <= tempNum+1;
|
tempCount <= tempCount-1;
|
tempCount <= tempCount-1;
|
endrule
|
endrule
|
|
|
rule searching ( state matches tagged Search );
|
rule searching ( state matches tagged Search );
|
if(tempCount
|
if(tempCount
|
begin
|
begin
|
Tuple2#(Bit#(16),Bit#(5)) temp = rfile.sub(tempPic);
|
Tuple2#(Bit#(16),Bit#(5)) temp = rfile.sub(tempPic);
|
if(tpl_1(temp)==tempNum)
|
if(tpl_1(temp)==tempNum)
|
begin
|
begin
|
returnList.enq(tagged Valid tpl_2(temp));
|
returnList.enq(tagged Valid tpl_2(temp));
|
state <= Idle;
|
state <= Idle;
|
end
|
end
|
tempPic <= shortTermPicListPrev(tempPic);
|
tempPic <= shortTermPicListPrev(tempPic);
|
tempCount <= tempCount+1;
|
tempCount <= tempCount+1;
|
end
|
end
|
else
|
else
|
$display( "ERROR BufferControl: ShortTermPicList searching not found");
|
$display( "ERROR BufferControl: ShortTermPicList searching not found");
|
endrule
|
endrule
|
|
|
rule listingAll ( state matches tagged ListAll );
|
rule listingAll ( state matches tagged ListAll );
|
if(tempCount
|
if(tempCount
|
begin
|
begin
|
Tuple2#(Bit#(16),Bit#(5)) temp = rfile.sub(tempPic);
|
Tuple2#(Bit#(16),Bit#(5)) temp = rfile.sub(tempPic);
|
returnList.enq(tagged Valid tpl_2(temp));
|
returnList.enq(tagged Valid tpl_2(temp));
|
tempPic <= shortTermPicListPrev(tempPic);
|
tempPic <= shortTermPicListPrev(tempPic);
|
tempCount <= tempCount+1;
|
tempCount <= tempCount+1;
|
end
|
end
|
else
|
else
|
begin
|
begin
|
returnList.enq(tagged Invalid);
|
returnList.enq(tagged Invalid);
|
state <= Idle;
|
state <= Idle;
|
end
|
end
|
endrule
|
endrule
|
|
|
method Action clear() if(state matches tagged Idle);
|
method Action clear() if(state matches tagged Idle);
|
picCount <= 0;
|
picCount <= 0;
|
nextPic <= 0;
|
nextPic <= 0;
|
endmethod
|
endmethod
|
|
|
method Action insert( Bit#(16) frameNum, Bit#(5) slot, Bit#(5) maxAllowed ) if(state matches tagged Idle);
|
method Action insert( Bit#(16) frameNum, Bit#(5) slot, Bit#(5) maxAllowed ) if(state matches tagged Idle);
|
rfile.upd(nextPic,tuple2(frameNum,slot));
|
rfile.upd(nextPic,tuple2(frameNum,slot));
|
nextPic <= shortTermPicListNext(nextPic);
|
nextPic <= shortTermPicListNext(nextPic);
|
if(maxAllowed>picCount)
|
if(maxAllowed>picCount)
|
picCount <= picCount+1;
|
picCount <= picCount+1;
|
endmethod
|
endmethod
|
|
|
method Action insert_gap( Bit#(16) frameNum, Bit#(5) slot, Bit#(5) maxAllowed, Bit#(16) gap, Bit#(5) log2_max_frame_num ) if(state matches tagged Idle);
|
method Action insert_gap( Bit#(16) frameNum, Bit#(5) slot, Bit#(5) maxAllowed, Bit#(16) gap, Bit#(5) log2_max_frame_num ) if(state matches tagged Idle);
|
state <= InsertGap;
|
state <= InsertGap;
|
log2_mfn <= log2_max_frame_num;
|
log2_mfn <= log2_max_frame_num;
|
if(zeroExtend(picCount)+gap+1 >= zeroExtend(maxAllowed))
|
if(zeroExtend(picCount)+gap+1 >= zeroExtend(maxAllowed))
|
picCount <= maxAllowed;
|
picCount <= maxAllowed;
|
else
|
else
|
picCount <= truncate(zeroExtend(picCount)+gap+1);
|
picCount <= truncate(zeroExtend(picCount)+gap+1);
|
Bit#(5) temp;
|
Bit#(5) temp;
|
if(gap+1 >= zeroExtend(maxAllowed))
|
if(gap+1 >= zeroExtend(maxAllowed))
|
temp = maxAllowed;
|
temp = maxAllowed;
|
else
|
else
|
temp = truncate(gap+1);
|
temp = truncate(gap+1);
|
tempCount <= temp;
|
tempCount <= temp;
|
Bit#(17) tempOne = 1;
|
Bit#(17) tempOne = 1;
|
Bit#(17) maxPicNum = tempOne << log2_max_frame_num;
|
Bit#(17) maxPicNum = tempOne << log2_max_frame_num;
|
Bit#(17) tempFrameNum = zeroExtend(frameNum);
|
Bit#(17) tempFrameNum = zeroExtend(frameNum);
|
if(tempFrameNum+1 > zeroExtend(temp))
|
if(tempFrameNum+1 > zeroExtend(temp))
|
tempNum <= truncate(tempFrameNum+1-zeroExtend(temp));
|
tempNum <= truncate(tempFrameNum+1-zeroExtend(temp));
|
else
|
else
|
tempNum <= truncate(maxPicNum+tempFrameNum+1-zeroExtend(temp));
|
tempNum <= truncate(maxPicNum+tempFrameNum+1-zeroExtend(temp));
|
tempPic <= slot;
|
tempPic <= slot;
|
endmethod
|
endmethod
|
|
|
method Action remove( Bit#(16) frameNum, Bool removeOutputFlag ) if(state matches tagged Idle);
|
method Action remove( Bit#(16) frameNum, Bool removeOutputFlag ) if(state matches tagged Idle);
|
if(removeOutputFlag)
|
if(removeOutputFlag)
|
state <= RemoveOutput;
|
state <= RemoveOutput;
|
else
|
else
|
state <= Remove;
|
state <= Remove;
|
tempCount <= 0;
|
tempCount <= 0;
|
Bit#(5) temp = (maxRefFrames-picCount)+nextPic;
|
Bit#(5) temp = (maxRefFrames-picCount)+nextPic;
|
if(temp>maxRefFrames-1)
|
if(temp>maxRefFrames-1)
|
tempPic <= temp-maxRefFrames;
|
tempPic <= temp-maxRefFrames;
|
else
|
else
|
tempPic <= temp;
|
tempPic <= temp;
|
tempNum <= frameNum;
|
tempNum <= frameNum;
|
endmethod
|
endmethod
|
|
|
method Action search( Bit#(16) frameNum ) if(state matches tagged Idle);
|
method Action search( Bit#(16) frameNum ) if(state matches tagged Idle);
|
state <= Search;
|
state <= Search;
|
tempCount <= 0;
|
tempCount <= 0;
|
tempPic <= shortTermPicListPrev(nextPic);
|
tempPic <= shortTermPicListPrev(nextPic);
|
tempNum <= frameNum;
|
tempNum <= frameNum;
|
endmethod
|
endmethod
|
|
|
method Action listAll() if(state matches tagged Idle);
|
method Action listAll() if(state matches tagged Idle);
|
state <= ListAll;
|
state <= ListAll;
|
tempCount <= 0;
|
tempCount <= 0;
|
tempPic <= shortTermPicListPrev(nextPic);
|
tempPic <= shortTermPicListPrev(nextPic);
|
endmethod
|
endmethod
|
|
|
method Action deq();
|
method Action deq();
|
returnList.deq();
|
returnList.deq();
|
endmethod
|
endmethod
|
|
|
method Maybe#(Bit#(5)) resultSlot();
|
method Maybe#(Bit#(5)) resultSlot();
|
return returnList.first();
|
return returnList.first();
|
endmethod
|
endmethod
|
|
|
method Bit#(5) numPics() if(state matches tagged Idle);
|
method Bit#(5) numPics() if(state matches tagged Idle);
|
return picCount;
|
return picCount;
|
endmethod
|
endmethod
|
endmodule
|
endmodule
|
|
|
//-----------------------------------------------------------
|
//-----------------------------------------------------------
|
// Long term pic list submodule
|
// Long term pic list submodule
|
//-----------------------------------------------------------
|
//-----------------------------------------------------------
|
|
|
typedef union tagged
|
typedef union tagged
|
{
|
{
|
void Idle; //not working on anything in particular
|
void Idle; //not working on anything in particular
|
void Clear;
|
void Clear;
|
void ListAll;
|
void ListAll;
|
}
|
}
|
LongTermPicListState deriving(Eq,Bits);
|
LongTermPicListState deriving(Eq,Bits);
|
|
|
interface LongTermPicList;
|
interface LongTermPicList;
|
method Action clear();
|
method Action clear();
|
method Action insert( Bit#(5) frameNum, Bit#(5) slot );
|
method Action insert( Bit#(5) frameNum, Bit#(5) slot );
|
method Action remove( Bit#(5) frameNum );
|
method Action remove( Bit#(5) frameNum );
|
method Action maxIndexPlus1( Bit#(5) maxAllowed );
|
method Action maxIndexPlus1( Bit#(5) maxAllowed );
|
method Action search( Bit#(5) frameNum );
|
method Action search( Bit#(5) frameNum );
|
method Action listAll();
|
method Action listAll();
|
method Action deq();
|
method Action deq();
|
method Maybe#(Bit#(5)) resultSlot();
|
method Maybe#(Bit#(5)) resultSlot();
|
method Bit#(5) numPics();
|
method Bit#(5) numPics();
|
endinterface
|
endinterface
|
|
|
module mkLongTermPicList( LongTermPicList );
|
module mkLongTermPicList( LongTermPicList );
|
// RegFile#(Bit#(5),Maybe#(Bit#(5))) rfile <- mkRegFile(0,maxRefFrames-1);
|
// RegFile#(Bit#(5),Maybe#(Bit#(5))) rfile <- mkRegFile(0,maxRefFrames-1);
|
RFile1#(Bit#(5),Maybe#(Bit#(5))) rfile <- mkRFile1Full();
|
RFile1#(Bit#(5),Maybe#(Bit#(5))) rfile <- mkRFile1Full();
|
Reg#(LongTermPicListState) state <- mkReg(Idle);
|
Reg#(LongTermPicListState) state <- mkReg(Idle);
|
Reg#(Bit#(5)) picCount <- mkReg(0);
|
Reg#(Bit#(5)) picCount <- mkReg(0);
|
Reg#(Bit#(5)) tempPic <- mkReg(0);
|
Reg#(Bit#(5)) tempPic <- mkReg(0);
|
FIFO#(Maybe#(Bit#(5))) returnList <- mkFIFO();
|
FIFO#(Maybe#(Bit#(5))) returnList <- mkFIFO();
|
|
|
rule clearing ( state matches tagged Clear );
|
rule clearing ( state matches tagged Clear );
|
if(tempPic
|
if(tempPic
|
begin
|
begin
|
if(rfile.sub(tempPic) matches tagged Valid .data &&& picCount!=0)
|
if(rfile.sub(tempPic) matches tagged Valid .data &&& picCount!=0)
|
picCount <= picCount-1;
|
picCount <= picCount-1;
|
rfile.upd(tempPic,Invalid);
|
rfile.upd(tempPic,Invalid);
|
tempPic <= tempPic+1;
|
tempPic <= tempPic+1;
|
end
|
end
|
else
|
else
|
state <= Idle;
|
state <= Idle;
|
//$display( "TRACE BufferControl: LongTermPicList clearing %h %h", picCount, tempPic);
|
//$display( "TRACE BufferControl: LongTermPicList clearing %h %h", picCount, tempPic);
|
endrule
|
endrule
|
|
|
rule listingAll ( state matches tagged ListAll );
|
rule listingAll ( state matches tagged ListAll );
|
if(tempPic
|
if(tempPic
|
begin
|
begin
|
Maybe#(Bit#(5)) temp = rfile.sub(tempPic);
|
Maybe#(Bit#(5)) temp = rfile.sub(tempPic);
|
if(temp matches tagged Valid .data)
|
if(temp matches tagged Valid .data)
|
returnList.enq(tagged Valid data);
|
returnList.enq(tagged Valid data);
|
tempPic <= tempPic+1;
|
tempPic <= tempPic+1;
|
end
|
end
|
else
|
else
|
begin
|
begin
|
returnList.enq(Invalid);
|
returnList.enq(Invalid);
|
state <= Idle;
|
state <= Idle;
|
end
|
end
|
//$display( "TRACE BufferControl: LongTermPicList listingAll %h %h", picCount, tempPic);
|
//$display( "TRACE BufferControl: LongTermPicList listingAll %h %h", picCount, tempPic);
|
endrule
|
endrule
|
|
|
method Action clear() if(state matches tagged Idle);
|
method Action clear() if(state matches tagged Idle);
|
state <= Clear;
|
state <= Clear;
|
tempPic <= 0;
|
tempPic <= 0;
|
//$display( "TRACE BufferControl: LongTermPicList clear %h", picCount);
|
//$display( "TRACE BufferControl: LongTermPicList clear %h", picCount);
|
endmethod
|
endmethod
|
|
|
method Action insert( Bit#(5) frameNum, Bit#(5) slot ) if(state matches tagged Idle);
|
method Action insert( Bit#(5) frameNum, Bit#(5) slot ) if(state matches tagged Idle);
|
if(rfile.sub(frameNum) matches tagged Invalid)
|
if(rfile.sub(frameNum) matches tagged Invalid)
|
picCount <= picCount+1;
|
picCount <= picCount+1;
|
rfile.upd(frameNum,tagged Valid slot);
|
rfile.upd(frameNum,tagged Valid slot);
|
//$display( "TRACE BufferControl: LongTermPicList insert %h %h %h", picCount, frameNum, slot);
|
//$display( "TRACE BufferControl: LongTermPicList insert %h %h %h", picCount, frameNum, slot);
|
endmethod
|
endmethod
|
|
|
method Action remove( Bit#(5) frameNum ) if(state matches tagged Idle);
|
method Action remove( Bit#(5) frameNum ) if(state matches tagged Idle);
|
if(rfile.sub(frameNum) matches tagged Invalid)
|
if(rfile.sub(frameNum) matches tagged Invalid)
|
$display( "ERROR BufferControl: LongTermPicList removing not found");
|
$display( "ERROR BufferControl: LongTermPicList removing not found");
|
else
|
else
|
picCount <= picCount-1;
|
picCount <= picCount-1;
|
rfile.upd(frameNum,Invalid);
|
rfile.upd(frameNum,Invalid);
|
//$display( "TRACE BufferControl: LongTermPicList remove %h %h", picCount, frameNum);
|
//$display( "TRACE BufferControl: LongTermPicList remove %h %h", picCount, frameNum);
|
endmethod
|
endmethod
|
|
|
method Action maxIndexPlus1( Bit#(5) index ) if(state matches tagged Idle);
|
method Action maxIndexPlus1( Bit#(5) index ) if(state matches tagged Idle);
|
state <= Clear;
|
state <= Clear;
|
tempPic <= index;
|
tempPic <= index;
|
//$display( "TRACE BufferControl: LongTermPicList maxIndexPlus1 %h %h", picCount, index);
|
//$display( "TRACE BufferControl: LongTermPicList maxIndexPlus1 %h %h", picCount, index);
|
endmethod
|
endmethod
|
|
|
method Action search( Bit#(5) frameNum ) if(state matches tagged Idle);
|
method Action search( Bit#(5) frameNum ) if(state matches tagged Idle);
|
returnList.enq(rfile.sub(frameNum));
|
returnList.enq(rfile.sub(frameNum));
|
//$display( "TRACE BufferControl: LongTermPicList search %h %h", picCount, frameNum);
|
//$display( "TRACE BufferControl: LongTermPicList search %h %h", picCount, frameNum);
|
endmethod
|
endmethod
|
|
|
method Action listAll() if(state matches tagged Idle);
|
method Action listAll() if(state matches tagged Idle);
|
state <= ListAll;
|
state <= ListAll;
|
tempPic <= 0;
|
tempPic <= 0;
|
//$display( "TRACE BufferControl: LongTermPicList listAll %h", picCount);
|
//$display( "TRACE BufferControl: LongTermPicList listAll %h", picCount);
|
endmethod
|
endmethod
|
|
|
method Action deq();
|
method Action deq();
|
returnList.deq();
|
returnList.deq();
|
//$display( "TRACE BufferControl: LongTermPicList deq %h", picCount);
|
//$display( "TRACE BufferControl: LongTermPicList deq %h", picCount);
|
endmethod
|
endmethod
|
|
|
method Maybe#(Bit#(5)) resultSlot();
|
method Maybe#(Bit#(5)) resultSlot();
|
return returnList.first();
|
return returnList.first();
|
endmethod
|
endmethod
|
|
|
method Bit#(5) numPics() if(state matches tagged Idle);
|
method Bit#(5) numPics() if(state matches tagged Idle);
|
return picCount;
|
return picCount;
|
endmethod
|
endmethod
|
endmodule
|
endmodule
|
|
|
|
|
//-----------------------------------------------------------
|
//-----------------------------------------------------------
|
// Free slot module
|
// Free slot module
|
//-----------------------------------------------------------
|
//-----------------------------------------------------------
|
|
|
interface FreeSlots;
|
interface FreeSlots;
|
method Action init();
|
method Action init();
|
method Action add( Bit#(5) slot );
|
method Action add( Bit#(5) slot );
|
method Action remove( Bit#(5) slot );
|
method Action remove( Bit#(5) slot );
|
method Bit#(5) first( Bit#(5) exception );
|
method Bit#(5) first( Bit#(5) exception );
|
endinterface
|
endinterface
|
|
|
module mkFreeSlots( FreeSlots );
|
module mkFreeSlots( FreeSlots );
|
Reg#(Vector#(18,Bit#(1))) slots <- mkRegU();
|
Reg#(Vector#(18,Bit#(1))) slots <- mkRegU();
|
|
|
method Action init();
|
method Action init();
|
Vector#(18,Bit#(1)) tempSlots = replicate(0);
|
Vector#(18,Bit#(1)) tempSlots = replicate(0);
|
slots <= tempSlots;
|
slots <= tempSlots;
|
endmethod
|
endmethod
|
|
|
method Action add( Bit#(5) slot );
|
method Action add( Bit#(5) slot );
|
Vector#(18,Bit#(1)) tempSlots = slots;
|
Vector#(18,Bit#(1)) tempSlots = slots;
|
tempSlots[slot] = 0;
|
tempSlots[slot] = 0;
|
slots <= tempSlots;
|
slots <= tempSlots;
|
if(slot >= maxRefFrames+2)
|
if(slot >= maxRefFrames+2)
|
$display( "ERROR BufferControl: FreeSlots add out of bounds");
|
$display( "ERROR BufferControl: FreeSlots add out of bounds");
|
endmethod
|
endmethod
|
|
|
method Action remove( Bit#(5) slot );
|
method Action remove( Bit#(5) slot );
|
Vector#(18,Bit#(1)) tempSlots = slots;
|
Vector#(18,Bit#(1)) tempSlots = slots;
|
if(slot != 31)
|
if(slot != 31)
|
begin
|
begin
|
tempSlots[slot] = 1;
|
tempSlots[slot] = 1;
|
slots <= tempSlots;
|
slots <= tempSlots;
|
if(slot >= maxRefFrames+2)
|
if(slot >= maxRefFrames+2)
|
$display( "ERROR BufferControl: FreeSlots remove out of bounds");
|
$display( "ERROR BufferControl: FreeSlots remove out of bounds");
|
end
|
end
|
endmethod
|
endmethod
|
|
|
method Bit#(5) first( Bit#(5) exception );
|
method Bit#(5) first( Bit#(5) exception );
|
Bit#(5) tempout = 31;
|
Bit#(5) tempout = 31;
|
for(Integer ii=17; ii>=0; ii=ii-1)
|
for(Integer ii=17; ii>=0; ii=ii-1)
|
begin
|
begin
|
if(slots[fromInteger(ii)]==1'b0 && fromInteger(ii)!=exception)
|
if(slots[fromInteger(ii)]==1'b0 && fromInteger(ii)!=exception)
|
tempout = fromInteger(ii);
|
tempout = fromInteger(ii);
|
end
|
end
|
return tempout;
|
return tempout;
|
endmethod
|
endmethod
|
|
|
endmodule
|
endmodule
|
|
|
|
|
//-----------------------------------------------------------
|
//-----------------------------------------------------------
|
// Helper functions
|
// Helper functions
|
|
|
|
|
|
|
//-----------------------------------------------------------
|
//-----------------------------------------------------------
|
// Buffer Controller Module
|
// Buffer Controller Module
|
//-----------------------------------------------------------
|
//-----------------------------------------------------------
|
|
|
|
|
(* synthesize *)
|
(* synthesize *)
|
module mkBufferControl( IBufferControl );
|
module mkBufferControl( IBufferControl );
|
|
|
FIFO#(DeblockFilterOT) infifo <- mkSizedFIFO(bufferControl_infifo_size);
|
FIFO#(DeblockFilterOT) infifo <- mkSizedFIFO(bufferControl_infifo_size);
|
FIFO#(BufferControlOT) outfifo <- mkFIFO();
|
FIFO#(BufferControlOT) outfifo <- mkFIFO();
|
|
|
FIFO#(FrameBufferLoadReq) loadReqQ1 <- mkFIFO();
|
FIFO#(FrameBufferLoadReq) loadReqQ1 <- mkFIFO();
|
FIFO#(FrameBufferLoadResp) loadRespQ1 <- mkFIFO();
|
FIFO#(FrameBufferLoadResp) loadRespQ1 <- mkFIFO();
|
FIFO#(FrameBufferLoadReq) loadReqQ2 <- mkFIFO();
|
FIFO#(FrameBufferLoadReq) loadReqQ2 <- mkFIFO();
|
FIFO#(FrameBufferLoadResp) loadRespQ2 <- mkFIFO();
|
FIFO#(FrameBufferLoadResp) loadRespQ2 <- mkFIFO();
|
FIFO#(FrameBufferStoreReq) storeReqQ <- mkFIFO();
|
FIFO#(FrameBufferStoreReq) storeReqQ <- mkFIFO();
|
|
|
FIFO#(InterpolatorLoadReq) inLoadReqQ <- mkFIFO();
|
FIFO#(InterpolatorLoadReq) inLoadReqQ <- mkFIFO();
|
FIFO#(InterpolatorLoadResp) inLoadRespQ <- mkFIFO();
|
FIFO#(InterpolatorLoadResp) inLoadRespQ <- mkFIFO();
|
FIFO#(Bit#(2)) inLoadOutOfBounds <- mkSizedFIFO(64);
|
FIFO#(Bit#(2)) inLoadOutOfBounds <- mkSizedFIFO(64);
|
|
|
Reg#(Bit#(5)) log2_max_frame_num <- mkReg(0);
|
Reg#(Bit#(5)) log2_max_frame_num <- mkReg(0);
|
Reg#(Bit#(5)) num_ref_frames <- mkReg(0);
|
Reg#(Bit#(5)) num_ref_frames <- mkReg(0);
|
Reg#(Bit#(1)) gaps_in_frame_num_allowed_flag <- mkReg(0);
|
Reg#(Bit#(1)) gaps_in_frame_num_allowed_flag <- 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)) frameinmb <- mkReg(0);
|
Reg#(Bit#(PicAreaSz)) frameinmb <- mkReg(0);
|
|
|
Reg#(Bit#(5)) ppsnum_ref_idx_l0_active <- mkReg(0);
|
Reg#(Bit#(5)) ppsnum_ref_idx_l0_active <- mkReg(0);
|
Reg#(Bit#(16)) frame_num <- mkReg(0);
|
Reg#(Bit#(16)) frame_num <- mkReg(0);
|
Reg#(Bit#(16)) prevRefFrameNum <- mkReg(0);
|
Reg#(Bit#(16)) prevRefFrameNum <- mkReg(0);
|
Reg#(Bit#(5)) num_ref_idx_l0_active <- mkReg(0);
|
Reg#(Bit#(5)) num_ref_idx_l0_active <- mkReg(0);
|
Reg#(Bit#(2)) reordering_of_pic_nums_idc <- mkReg(0);
|
Reg#(Bit#(2)) reordering_of_pic_nums_idc <- mkReg(0);
|
Reg#(Bit#(16)) picNumLXPred <- mkReg(0);
|
Reg#(Bit#(16)) picNumLXPred <- mkReg(0);
|
Reg#(Bit#(3)) memory_management_control_operation <- mkReg(0);
|
Reg#(Bit#(3)) memory_management_control_operation <- mkReg(0);
|
|
|
Reg#(Bool) newInputFrame <- mkReg(True);
|
Reg#(Bool) newInputFrame <- mkReg(True);
|
Reg#(Bool) noMoreInput <- mkReg(False);
|
Reg#(Bool) noMoreInput <- mkReg(False);
|
Reg#(Bool) inputframedone <- mkReg(False);
|
Reg#(Bool) inputframedone <- mkReg(False);
|
Reg#(Outprocess) outprocess <- mkReg(Idle);
|
Reg#(Outprocess) outprocess <- mkReg(Idle);
|
Reg#(Bool) outputframedone <- mkReg(True);
|
Reg#(Bool) outputframedone <- mkReg(True);
|
|
|
Reg#(Bit#(5)) inSlot <- mkReg(0);
|
Reg#(Bit#(5)) inSlot <- mkReg(0);
|
Reg#(Bit#(FrameBufferSz)) inAddrBase <- mkReg(0);
|
Reg#(Bit#(FrameBufferSz)) inAddrBase <- mkReg(0);
|
Reg#(Bit#(5)) outSlot <- mkReg(31);
|
Reg#(Bit#(5)) outSlot <- mkReg(31);
|
Reg#(Bit#(FrameBufferSz)) outAddrBase <- mkReg(0);
|
Reg#(Bit#(FrameBufferSz)) outAddrBase <- mkReg(0);
|
Reg#(Bit#(TAdd#(PicAreaSz,7))) outReqCount <- mkReg(0);
|
Reg#(Bit#(TAdd#(PicAreaSz,7))) outReqCount <- mkReg(0);
|
Reg#(Bit#(TAdd#(PicAreaSz,7))) outRespCount <- mkReg(0);
|
Reg#(Bit#(TAdd#(PicAreaSz,7))) outRespCount <- mkReg(0);
|
|
|
FreeSlots freeSlots <- mkFreeSlots();//may include outSlot (have to make sure it's not used)
|
FreeSlots freeSlots <- mkFreeSlots();//may include outSlot (have to make sure it's not used)
|
ShortTermPicList shortTermPicList <- mkShortTermPicList();
|
ShortTermPicList shortTermPicList <- mkShortTermPicList();
|
LongTermPicList longTermPicList <- mkLongTermPicList();
|
LongTermPicList longTermPicList <- mkLongTermPicList();
|
RFile1#(Bit#(5),Bit#(5)) refPicList <- mkRFile1(0,maxRefFrames-1);
|
RFile1#(Bit#(5),Bit#(5)) refPicList <- mkRFile1(0,maxRefFrames-1);
|
Reg#(Bit#(5)) refPicListCount <- mkReg(0);
|
Reg#(Bit#(5)) refPicListCount <- mkReg(0);
|
Reg#(Bool) initRefPicList <- mkReg(False);
|
Reg#(Bool) initRefPicList <- mkReg(False);
|
Reg#(Bool) reorderRefPicList <- mkReg(False);
|
Reg#(Bool) reorderRefPicList <- mkReg(False);
|
Reg#(Bit#(5)) refIdx <- mkReg(0);
|
Reg#(Bit#(5)) refIdx <- mkReg(0);
|
Reg#(Bit#(5)) tempSlot <- mkReg(0);
|
Reg#(Bit#(5)) tempSlot <- mkReg(0);
|
Reg#(Bit#(5)) tempSlot2 <- mkReg(0);
|
Reg#(Bit#(5)) tempSlot2 <- mkReg(0);
|
Reg#(Bit#(2)) adjustFreeSlots <- mkReg(0);
|
Reg#(Bit#(2)) adjustFreeSlots <- mkReg(0);
|
|
|
Reg#(Bool) refPicListDone <- mkReg(False);
|
Reg#(Bool) refPicListDone <- mkReg(False);
|
Reg#(Bool) lockInterLoads <- mkReg(True);
|
Reg#(Bool) lockInterLoads <- mkReg(True);
|
DoNotFire donotfire <- mkDoNotFire();
|
DoNotFire donotfire <- mkDoNotFire();
|
|
|
|
|
//-----------------------------------------------------------
|
//-----------------------------------------------------------
|
// Rules
|
// Rules
|
|
|
rule inputing ( !noMoreInput && !inputframedone );
|
rule inputing ( !noMoreInput && !inputframedone );
|
//$display( "Trace Buffer Control: passing infifo packed %h", pack(infifo.first()));
|
//$display( "Trace Buffer Control: passing infifo packed %h", pack(infifo.first()));
|
case (infifo.first()) matches
|
case (infifo.first()) matches
|
tagged EDOT .indata :
|
tagged EDOT .indata :
|
begin
|
begin
|
case (indata) matches
|
case (indata) matches
|
tagged SPSlog2_max_frame_num .xdata :
|
tagged SPSlog2_max_frame_num .xdata :
|
begin
|
begin
|
if(adjustFreeSlots == 0)
|
if(adjustFreeSlots == 0)
|
begin
|
begin
|
infifo.deq();
|
infifo.deq();
|
log2_max_frame_num <= xdata;
|
log2_max_frame_num <= xdata;
|
freeSlots.init();
|
freeSlots.init();
|
shortTermPicList.clear();
|
shortTermPicList.clear();
|
longTermPicList.clear();
|
longTermPicList.clear();
|
end
|
end
|
else
|
else
|
donotfire.doNotFire();
|
donotfire.doNotFire();
|
end
|
end
|
tagged SPSnum_ref_frames .xdata :
|
tagged SPSnum_ref_frames .xdata :
|
begin
|
begin
|
infifo.deq();
|
infifo.deq();
|
num_ref_frames <= xdata;
|
num_ref_frames <= xdata;
|
end
|
end
|
tagged SPSgaps_in_frame_num_allowed_flag .xdata :
|
tagged SPSgaps_in_frame_num_allowed_flag .xdata :
|
begin
|
begin
|
infifo.deq();
|
infifo.deq();
|
gaps_in_frame_num_allowed_flag <= xdata;
|
gaps_in_frame_num_allowed_flag <= xdata;
|
end
|
end
|
tagged SPSpic_width_in_mbs .xdata :
|
tagged SPSpic_width_in_mbs .xdata :
|
begin
|
begin
|
infifo.deq();
|
infifo.deq();
|
picWidth <= xdata;
|
picWidth <= xdata;
|
end
|
end
|
tagged SPSpic_height_in_map_units .xdata :
|
tagged SPSpic_height_in_map_units .xdata :
|
begin
|
begin
|
infifo.deq();
|
infifo.deq();
|
picHeight <= xdata;
|
picHeight <= xdata;
|
frameinmb <= zeroExtend(picWidth)*zeroExtend(xdata);
|
frameinmb <= zeroExtend(picWidth)*zeroExtend(xdata);
|
end
|
end
|
tagged PPSnum_ref_idx_l0_active .xdata :
|
tagged PPSnum_ref_idx_l0_active .xdata :
|
begin
|
begin
|
infifo.deq();
|
infifo.deq();
|
ppsnum_ref_idx_l0_active <= xdata;
|
ppsnum_ref_idx_l0_active <= xdata;
|
end
|
end
|
tagged SHfirst_mb_in_slice .xdata :
|
tagged SHfirst_mb_in_slice .xdata :
|
begin
|
begin
|
if(adjustFreeSlots == 0)
|
if(adjustFreeSlots == 0)
|
begin
|
begin
|
infifo.deq();
|
infifo.deq();
|
newInputFrame <= False;
|
newInputFrame <= False;
|
shortTermPicList.listAll();
|
shortTermPicList.listAll();
|
longTermPicList.listAll();
|
longTermPicList.listAll();
|
initRefPicList <= True;
|
initRefPicList <= True;
|
refPicListCount <= 0;
|
refPicListCount <= 0;
|
if(newInputFrame)
|
if(newInputFrame)
|
begin
|
begin
|
inSlot <= freeSlots.first(outSlot);
|
inSlot <= freeSlots.first(outSlot);
|
inAddrBase <= (zeroExtend(freeSlots.first(outSlot))*zeroExtend(frameinmb)*3)<<5;
|
inAddrBase <= (zeroExtend(freeSlots.first(outSlot))*zeroExtend(frameinmb)*3)<<5;
|
end
|
end
|
$display( "Trace BufferControl: passing SHfirst_mb_in_slice %h %h %0d", freeSlots.first(outSlot), outSlot, (newInputFrame ? 1 : 0));
|
$display( "Trace BufferControl: passing SHfirst_mb_in_slice %h %h %0d", freeSlots.first(outSlot), outSlot, (newInputFrame ? 1 : 0));
|
end
|
end
|
else
|
else
|
donotfire.doNotFire();
|
donotfire.doNotFire();
|
end
|
end
|
tagged SHframe_num .xdata :
|
tagged SHframe_num .xdata :
|
begin
|
begin
|
infifo.deq();
|
infifo.deq();
|
frame_num <= xdata;
|
frame_num <= xdata;
|
picNumLXPred <= frame_num;
|
picNumLXPred <= frame_num;
|
end
|
end
|
tagged SHnum_ref_idx_active_override_flag .xdata :
|
tagged SHnum_ref_idx_active_override_flag .xdata :
|
begin
|
begin
|
infifo.deq();
|
infifo.deq();
|
num_ref_idx_l0_active <= ppsnum_ref_idx_l0_active;
|
num_ref_idx_l0_active <= ppsnum_ref_idx_l0_active;
|
end
|
end
|
tagged SHnum_ref_idx_l0_active .xdata :
|
tagged SHnum_ref_idx_l0_active .xdata :
|
begin
|
begin
|
infifo.deq();
|
infifo.deq();
|
num_ref_idx_l0_active <= xdata;
|
num_ref_idx_l0_active <= xdata;
|
end
|
end
|
tagged SHRref_pic_list_reordering_flag_l0 .xdata :
|
tagged SHRref_pic_list_reordering_flag_l0 .xdata :
|
begin
|
begin
|
if(!initRefPicList)
|
if(!initRefPicList)
|
begin
|
begin
|
infifo.deq();
|
infifo.deq();
|
if(xdata==0)
|
if(xdata==0)
|
refPicListDone <= True;
|
refPicListDone <= True;
|
end
|
end
|
else
|
else
|
donotfire.doNotFire();
|
donotfire.doNotFire();
|
refIdx <= 0;
|
refIdx <= 0;
|
end
|
end
|
tagged SHRreordering_of_pic_nums_idc .xdata :
|
tagged SHRreordering_of_pic_nums_idc .xdata :
|
begin
|
begin
|
if(!reorderRefPicList)
|
if(!reorderRefPicList)
|
begin
|
begin
|
infifo.deq();
|
infifo.deq();
|
reordering_of_pic_nums_idc <= xdata;
|
reordering_of_pic_nums_idc <= xdata;
|
if(xdata==3)
|
if(xdata==3)
|
refPicListDone <= True;
|
refPicListDone <= True;
|
end
|
end
|
else
|
else
|
donotfire.doNotFire();
|
donotfire.doNotFire();
|
end
|
end
|
tagged SHRabs_diff_pic_num .xdata :
|
tagged SHRabs_diff_pic_num .xdata :
|
begin
|
begin
|
if(!reorderRefPicList)
|
if(!reorderRefPicList)
|
begin
|
begin
|
infifo.deq();
|
infifo.deq();
|
Bit#(16) picNumLXNoWrap;
|
Bit#(16) picNumLXNoWrap;
|
Bit#(17) tempOne = 1;
|
Bit#(17) tempOne = 1;
|
Bit#(17) maxPicNum = tempOne << log2_max_frame_num;
|
Bit#(17) maxPicNum = tempOne << log2_max_frame_num;
|
if(reordering_of_pic_nums_idc==0)
|
if(reordering_of_pic_nums_idc==0)
|
begin
|
begin
|
if(picNumLXPred < truncate(xdata))
|
if(picNumLXPred < truncate(xdata))
|
picNumLXNoWrap = truncate(zeroExtend(picNumLXPred)-xdata+maxPicNum);
|
picNumLXNoWrap = truncate(zeroExtend(picNumLXPred)-xdata+maxPicNum);
|
else
|
else
|
picNumLXNoWrap = truncate(zeroExtend(picNumLXPred)-xdata);
|
picNumLXNoWrap = truncate(zeroExtend(picNumLXPred)-xdata);
|
end
|
end
|
else
|
else
|
begin
|
begin
|
if(zeroExtend(picNumLXPred)+xdata >= maxPicNum)
|
if(zeroExtend(picNumLXPred)+xdata >= maxPicNum)
|
picNumLXNoWrap = truncate(zeroExtend(picNumLXPred)+xdata-maxPicNum);
|
picNumLXNoWrap = truncate(zeroExtend(picNumLXPred)+xdata-maxPicNum);
|
else
|
else
|
picNumLXNoWrap = truncate(zeroExtend(picNumLXPred)+xdata);
|
picNumLXNoWrap = truncate(zeroExtend(picNumLXPred)+xdata);
|
end
|
end
|
picNumLXPred <= picNumLXNoWrap;
|
picNumLXPred <= picNumLXNoWrap;
|
shortTermPicList.search(picNumLXNoWrap);
|
shortTermPicList.search(picNumLXNoWrap);
|
reorderRefPicList <= True;
|
reorderRefPicList <= True;
|
refPicListCount <= 0;
|
refPicListCount <= 0;
|
end
|
end
|
else
|
else
|
donotfire.doNotFire();
|
donotfire.doNotFire();
|
end
|
end
|
tagged SHRlong_term_pic_num .xdata :
|
tagged SHRlong_term_pic_num .xdata :
|
begin
|
begin
|
if(!reorderRefPicList)
|
if(!reorderRefPicList)
|
begin
|
begin
|
infifo.deq();
|
infifo.deq();
|
longTermPicList.search(xdata);
|
longTermPicList.search(xdata);
|
reorderRefPicList <= True;
|
reorderRefPicList <= True;
|
refPicListCount <= 0;
|
refPicListCount <= 0;
|
end
|
end
|
else
|
else
|
donotfire.doNotFire();
|
donotfire.doNotFire();
|
end
|
end
|
tagged SHDlong_term_reference_flag .xdata :
|
tagged SHDlong_term_reference_flag .xdata :
|
begin
|
begin
|
infifo.deq();
|
infifo.deq();
|
if(xdata==0)
|
if(xdata==0)
|
shortTermPicList.insert(frame_num,inSlot,num_ref_frames);
|
shortTermPicList.insert(frame_num,inSlot,num_ref_frames);
|
else
|
else
|
longTermPicList.insert(0,inSlot);
|
longTermPicList.insert(0,inSlot);
|
adjustFreeSlots <= 1;
|
adjustFreeSlots <= 1;
|
end
|
end
|
tagged SHDadaptive_ref_pic_marking_mode_flag .xdata :
|
tagged SHDadaptive_ref_pic_marking_mode_flag .xdata :
|
begin
|
begin
|
infifo.deq();
|
infifo.deq();
|
Bit#(17) tempFrameNum = zeroExtend(frame_num);
|
Bit#(17) tempFrameNum = zeroExtend(frame_num);
|
Bit#(17) tempOne = 1;
|
Bit#(17) tempOne = 1;
|
Bit#(17) maxPicNum = tempOne << log2_max_frame_num;
|
Bit#(17) maxPicNum = tempOne << log2_max_frame_num;
|
Bit#(16) tempGap = 0;
|
Bit#(16) tempGap = 0;
|
if(frame_num < prevRefFrameNum)
|
if(frame_num < prevRefFrameNum)
|
tempFrameNum = tempFrameNum + maxPicNum;
|
tempFrameNum = tempFrameNum + maxPicNum;
|
if(tempFrameNum-zeroExtend(prevRefFrameNum) > 1)
|
if(tempFrameNum-zeroExtend(prevRefFrameNum) > 1)
|
tempGap = truncate(tempFrameNum-zeroExtend(prevRefFrameNum)-1);
|
tempGap = truncate(tempFrameNum-zeroExtend(prevRefFrameNum)-1);
|
if(xdata==0)
|
if(xdata==0)
|
begin
|
begin
|
if(tempGap==0)
|
if(tempGap==0)
|
shortTermPicList.insert(frame_num,inSlot,(num_ref_frames-longTermPicList.numPics()));
|
shortTermPicList.insert(frame_num,inSlot,(num_ref_frames-longTermPicList.numPics()));
|
else
|
else
|
shortTermPicList.insert_gap(frame_num,inSlot,(num_ref_frames-longTermPicList.numPics()),tempGap,log2_max_frame_num);
|
shortTermPicList.insert_gap(frame_num,inSlot,(num_ref_frames-longTermPicList.numPics()),tempGap,log2_max_frame_num);
|
adjustFreeSlots <= 1;
|
adjustFreeSlots <= 1;
|
end
|
end
|
prevRefFrameNum <= frame_num;
|
prevRefFrameNum <= frame_num;
|
end
|
end
|
tagged SHDmemory_management_control_operation .xdata :
|
tagged SHDmemory_management_control_operation .xdata :
|
begin
|
begin
|
infifo.deq();
|
infifo.deq();
|
memory_management_control_operation <= xdata;
|
memory_management_control_operation <= xdata;
|
if(xdata==0)
|
if(xdata==0)
|
adjustFreeSlots <= 1;
|
adjustFreeSlots <= 1;
|
else if(xdata==5)
|
else if(xdata==5)
|
begin
|
begin
|
shortTermPicList.clear();
|
shortTermPicList.clear();
|
longTermPicList.clear();
|
longTermPicList.clear();
|
end
|
end
|
end
|
end
|
tagged SHDdifference_of_pic_nums .xdata :
|
tagged SHDdifference_of_pic_nums .xdata :
|
begin
|
begin
|
infifo.deq();
|
infifo.deq();
|
Bit#(16) picNumXNoWrap;
|
Bit#(16) picNumXNoWrap;
|
Bit#(17) tempOne = 1;
|
Bit#(17) tempOne = 1;
|
Bit#(17) maxPicNum = tempOne << log2_max_frame_num;
|
Bit#(17) maxPicNum = tempOne << log2_max_frame_num;
|
if(frame_num < truncate(xdata))
|
if(frame_num < truncate(xdata))
|
picNumXNoWrap = truncate(zeroExtend(frame_num)-xdata+maxPicNum);
|
picNumXNoWrap = truncate(zeroExtend(frame_num)-xdata+maxPicNum);
|
else
|
else
|
picNumXNoWrap = truncate(zeroExtend(frame_num)-xdata);
|
picNumXNoWrap = truncate(zeroExtend(frame_num)-xdata);
|
if(memory_management_control_operation == 1)
|
if(memory_management_control_operation == 1)
|
shortTermPicList.remove(picNumXNoWrap,False);
|
shortTermPicList.remove(picNumXNoWrap,False);
|
else
|
else
|
shortTermPicList.remove(picNumXNoWrap,True);
|
shortTermPicList.remove(picNumXNoWrap,True);
|
end
|
end
|
tagged SHDlong_term_pic_num .xdata :
|
tagged SHDlong_term_pic_num .xdata :
|
begin
|
begin
|
infifo.deq();
|
infifo.deq();
|
longTermPicList.remove(xdata);
|
longTermPicList.remove(xdata);
|
end
|
end
|
tagged SHDlong_term_frame_idx .xdata :
|
tagged SHDlong_term_frame_idx .xdata :
|
begin
|
begin
|
infifo.deq();
|
infifo.deq();
|
if(memory_management_control_operation == 3)
|
if(memory_management_control_operation == 3)
|
begin
|
begin
|
if(shortTermPicList.resultSlot() matches tagged Valid .validdata)
|
if(shortTermPicList.resultSlot() matches tagged Valid .validdata)
|
longTermPicList.insert(xdata,validdata);
|
longTermPicList.insert(xdata,validdata);
|
else
|
else
|
$display( "ERROR BufferControl: SHDlong_term_frame_idx Invalid output from shortTermPicList");
|
$display( "ERROR BufferControl: SHDlong_term_frame_idx Invalid output from shortTermPicList");
|
shortTermPicList.deq();
|
shortTermPicList.deq();
|
end
|
end
|
else
|
else
|
longTermPicList.insert(xdata,inSlot);
|
longTermPicList.insert(xdata,inSlot);
|
end
|
end
|
tagged SHDmax_long_term_frame_idx_plus1 .xdata :
|
tagged SHDmax_long_term_frame_idx_plus1 .xdata :
|
begin
|
begin
|
infifo.deq();
|
infifo.deq();
|
longTermPicList.maxIndexPlus1(xdata);
|
longTermPicList.maxIndexPlus1(xdata);
|
end
|
end
|
tagged EndOfFile :
|
tagged EndOfFile :
|
begin
|
begin
|
infifo.deq();
|
infifo.deq();
|
$display( "INFO Buffer Control: EndOfFile reached");
|
$display( "INFO Buffer Control: EndOfFile reached");
|
noMoreInput <= True;
|
noMoreInput <= True;
|
//$finish(0);
|
//$finish(0);
|
//outfifo.enq(EndOfFile);
|
//outfifo.enq(EndOfFile);
|
end
|
end
|
default:
|
default:
|
begin
|
begin
|
$display("WARNING: Why are we in this clause");
|
$display("WARNING: Why are we in this clause");
|
infifo.deq();
|
infifo.deq();
|
end
|
end
|
endcase
|
endcase
|
end
|
end
|
tagged DFBLuma .indata :
|
tagged DFBLuma .indata :
|
begin
|
begin
|
infifo.deq();
|
infifo.deq();
|
//$display( "TRACE Buffer Control: input Luma %0d %h %h", indata.mb, indata.pixel, indata.data);
|
//$display( "TRACE Buffer Control: input Luma %0d %h %h", indata.mb, indata.pixel, indata.data);
|
Bit#(TAdd#(PicAreaSz,6)) addr = {(zeroExtend(indata.ver)*zeroExtend(picWidth)),2'b00}+zeroExtend(indata.hor);
|
Bit#(TAdd#(PicAreaSz,6)) addr = {(zeroExtend(indata.ver)*zeroExtend(picWidth)),2'b00}+zeroExtend(indata.hor);
|
storeReqQ.enq(FBStoreReq {addr:inAddrBase+zeroExtend(addr),data:indata.data});
|
storeReqQ.enq(FBStoreReq {addr:inAddrBase+zeroExtend(addr),data:indata.data});
|
end
|
end
|
tagged DFBChroma .indata :
|
tagged DFBChroma .indata :
|
begin
|
begin
|
infifo.deq();
|
infifo.deq();
|
Bit#(TAdd#(PicAreaSz,4)) addr = {(zeroExtend(indata.ver)*zeroExtend(picWidth)),1'b0}+zeroExtend(indata.hor);
|
Bit#(TAdd#(PicAreaSz,4)) addr = {(zeroExtend(indata.ver)*zeroExtend(picWidth)),1'b0}+zeroExtend(indata.hor);
|
Bit#(TAdd#(PicAreaSz,6)) chromaOffset = {frameinmb,6'b000000};
|
Bit#(TAdd#(PicAreaSz,6)) chromaOffset = {frameinmb,6'b000000};
|
Bit#(TAdd#(PicAreaSz,4)) vOffset = 0;
|
Bit#(TAdd#(PicAreaSz,4)) vOffset = 0;
|
if(indata.uv == 1)
|
if(indata.uv == 1)
|
vOffset = {frameinmb,4'b0000};
|
vOffset = {frameinmb,4'b0000};
|
storeReqQ.enq(FBStoreReq {addr:(inAddrBase+zeroExtend(chromaOffset)+zeroExtend(vOffset)+zeroExtend(addr)),data:indata.data});
|
storeReqQ.enq(FBStoreReq {addr:(inAddrBase+zeroExtend(chromaOffset)+zeroExtend(vOffset)+zeroExtend(addr)),data:indata.data});
|
//$display( "TRACE Buffer Control: input Chroma %0d %0h %h %h %h %h", indata.uv, indata.ver, indata.hor, indata.data, addr, (inAddrBase+zeroExtend(chromaOffset)+zeroExtend(vOffset)+zeroExtend(addr)));
|
//$display( "TRACE Buffer Control: input Chroma %0d %0h %h %h %h %h", indata.uv, indata.ver, indata.hor, indata.data, addr, (inAddrBase+zeroExtend(chromaOffset)+zeroExtend(vOffset)+zeroExtend(addr)));
|
end
|
end
|
tagged EndOfFrame :
|
tagged EndOfFrame :
|
begin
|
begin
|
infifo.deq();
|
infifo.deq();
|
$display( "INFO Buffer Control: EndOfFrame reached");
|
$display( "INFO Buffer Control: EndOfFrame reached");
|
inputframedone <= True;
|
inputframedone <= True;
|
newInputFrame <= True;
|
newInputFrame <= True;
|
refPicListDone <= False;
|
refPicListDone <= False;
|
end
|
end
|
default: infifo.deq();
|
default: infifo.deq();
|
endcase
|
endcase
|
endrule
|
endrule
|
|
|
|
|
rule initingRefPicList ( initRefPicList );
|
rule initingRefPicList ( initRefPicList );
|
if(shortTermPicList.resultSlot() matches tagged Valid .xdata)
|
if(shortTermPicList.resultSlot() matches tagged Valid .xdata)
|
begin
|
begin
|
shortTermPicList.deq();
|
shortTermPicList.deq();
|
refPicList.upd(refPicListCount,xdata);
|
refPicList.upd(refPicListCount,xdata);
|
refPicListCount <= refPicListCount+1;
|
refPicListCount <= refPicListCount+1;
|
$display( "Trace BufferControl: initingRefPicList shortTermPicList %h", xdata);
|
$display( "Trace BufferControl: initingRefPicList shortTermPicList %h", xdata);
|
end
|
end
|
else if(longTermPicList.resultSlot() matches tagged Valid .xdata)
|
else if(longTermPicList.resultSlot() matches tagged Valid .xdata)
|
begin
|
begin
|
longTermPicList.deq();
|
longTermPicList.deq();
|
refPicList.upd(refPicListCount,xdata);
|
refPicList.upd(refPicListCount,xdata);
|
refPicListCount <= refPicListCount+1;
|
refPicListCount <= refPicListCount+1;
|
$display( "Trace BufferControl: initingRefPicList longTermPicList %h", xdata);
|
$display( "Trace BufferControl: initingRefPicList longTermPicList %h", xdata);
|
end
|
end
|
else
|
else
|
begin
|
begin
|
shortTermPicList.deq();
|
shortTermPicList.deq();
|
longTermPicList.deq();
|
longTermPicList.deq();
|
initRefPicList <= False;
|
initRefPicList <= False;
|
refPicListCount <= 0;
|
refPicListCount <= 0;
|
$display( "Trace BufferControl: initingRefPicList end");
|
$display( "Trace BufferControl: initingRefPicList end");
|
end
|
end
|
endrule
|
endrule
|
|
|
|
|
rule reorderingRefPicList ( reorderRefPicList );
|
rule reorderingRefPicList ( reorderRefPicList );
|
$display( "Trace BufferControl: reorderingRefPicList");
|
$display( "Trace BufferControl: reorderingRefPicList");
|
if(shortTermPicList.resultSlot() matches tagged Valid .xdata)//////////////////////////////////////////////////////////////////////////////////////////
|
if(shortTermPicList.resultSlot() matches tagged Valid .xdata)//////////////////////////////////////////////////////////////////////////////////////////
|
begin
|
begin
|
shortTermPicList.deq();
|
shortTermPicList.deq();
|
tempSlot <= refPicList.sub(refIdx);
|
tempSlot <= refPicList.sub(refIdx);
|
refPicList.upd(refIdx,xdata);
|
refPicList.upd(refIdx,xdata);
|
refPicListCount <= refIdx+1;
|
refPicListCount <= refIdx+1;
|
tempSlot2 <= xdata;
|
tempSlot2 <= xdata;
|
end
|
end
|
else if(longTermPicList.resultSlot() matches tagged Valid .xdata)/////////////////////////////////////////////////////////////////////////////////////may get stuck?
|
else if(longTermPicList.resultSlot() matches tagged Valid .xdata)/////////////////////////////////////////////////////////////////////////////////////may get stuck?
|
begin
|
begin
|
longTermPicList.deq();
|
longTermPicList.deq();
|
tempSlot <= refPicList.sub(refIdx);
|
tempSlot <= refPicList.sub(refIdx);
|
refPicList.upd(refIdx,xdata);
|
refPicList.upd(refIdx,xdata);
|
refPicListCount <= refIdx+1;
|
refPicListCount <= refIdx+1;
|
tempSlot2 <= xdata;
|
tempSlot2 <= xdata;
|
end
|
end
|
else
|
else
|
begin
|
begin
|
if(refPicListCount
|
if(refPicListCount
|
begin
|
begin
|
tempSlot <= refPicList.sub(refPicListCount);
|
tempSlot <= refPicList.sub(refPicListCount);
|
refPicList.upd(refPicListCount,tempSlot);
|
refPicList.upd(refPicListCount,tempSlot);
|
refPicListCount <= refPicListCount+1;
|
refPicListCount <= refPicListCount+1;
|
end
|
end
|
else
|
else
|
begin
|
begin
|
reorderRefPicList <= False;
|
reorderRefPicList <= False;
|
refPicListCount <= 0;
|
refPicListCount <= 0;
|
refIdx <= refIdx+1;
|
refIdx <= refIdx+1;
|
end
|
end
|
end
|
end
|
endrule
|
endrule
|
|
|
|
|
rule adjustingFreeSlots ( adjustFreeSlots != 0 );
|
rule adjustingFreeSlots ( adjustFreeSlots != 0 );
|
if(adjustFreeSlots == 1)
|
if(adjustFreeSlots == 1)
|
begin
|
begin
|
shortTermPicList.listAll();
|
shortTermPicList.listAll();
|
longTermPicList.listAll();
|
longTermPicList.listAll();
|
freeSlots.init();
|
freeSlots.init();
|
adjustFreeSlots <= 2;
|
adjustFreeSlots <= 2;
|
$display( "Trace BufferControl: adjustingFreeSlots begin");
|
$display( "Trace BufferControl: adjustingFreeSlots begin");
|
end
|
end
|
else
|
else
|
begin
|
begin
|
if(shortTermPicList.resultSlot() matches tagged Valid .xdata)
|
if(shortTermPicList.resultSlot() matches tagged Valid .xdata)
|
begin
|
begin
|
shortTermPicList.deq();
|
shortTermPicList.deq();
|
freeSlots.remove(xdata);
|
freeSlots.remove(xdata);
|
$display( "Trace BufferControl: adjustingFreeSlots shortTermPicList %h", xdata);
|
$display( "Trace BufferControl: adjustingFreeSlots shortTermPicList %h", xdata);
|
end
|
end
|
else if(longTermPicList.resultSlot() matches tagged Valid .xdata)
|
else if(longTermPicList.resultSlot() matches tagged Valid .xdata)
|
begin
|
begin
|
longTermPicList.deq();
|
longTermPicList.deq();
|
freeSlots.remove(xdata);
|
freeSlots.remove(xdata);
|
$display( "Trace BufferControl: adjustingFreeSlots longTermPicList %h", xdata);
|
$display( "Trace BufferControl: adjustingFreeSlots longTermPicList %h", xdata);
|
end
|
end
|
else
|
else
|
begin
|
begin
|
shortTermPicList.deq();
|
shortTermPicList.deq();
|
longTermPicList.deq();
|
longTermPicList.deq();
|
adjustFreeSlots <= 0;
|
adjustFreeSlots <= 0;
|
$display( "Trace BufferControl: adjustingFreeSlots end");
|
$display( "Trace BufferControl: adjustingFreeSlots end");
|
end
|
end
|
end
|
end
|
endrule
|
endrule
|
|
|
|
|
rule outputingReq ( outprocess != Idle );
|
rule outputingReq ( outprocess != Idle );
|
if(outprocess==Y)
|
if(outprocess==Y)
|
begin
|
begin
|
loadReqQ1.enq(FBLoadReq (outAddrBase+zeroExtend(outReqCount)));
|
loadReqQ1.enq(FBLoadReq (outAddrBase+zeroExtend(outReqCount)));
|
if(outReqCount == {1'b0,frameinmb,6'b000000}-1)
|
if(outReqCount == {1'b0,frameinmb,6'b000000}-1)
|
outprocess <= U;
|
outprocess <= U;
|
outReqCount <= outReqCount+1;
|
outReqCount <= outReqCount+1;
|
end
|
end
|
else if(outprocess==U)
|
else if(outprocess==U)
|
begin
|
begin
|
loadReqQ1.enq(FBLoadReq (outAddrBase+zeroExtend(outReqCount)));
|
loadReqQ1.enq(FBLoadReq (outAddrBase+zeroExtend(outReqCount)));
|
if(outReqCount == {1'b0,frameinmb,6'b000000}+{3'b000,frameinmb,4'b0000}-1)
|
if(outReqCount == {1'b0,frameinmb,6'b000000}+{3'b000,frameinmb,4'b0000}-1)
|
outprocess <= V;
|
outprocess <= V;
|
outReqCount <= outReqCount+1;
|
outReqCount <= outReqCount+1;
|
end
|
end
|
else
|
else
|
begin
|
begin
|
//$display( "TRACE BufferControl: outputingReq V %h %h %h", outAddrBase, outReqCount, (outAddrBase+zeroExtend(outReqCount)));
|
//$display( "TRACE BufferControl: outputingReq V %h %h %h", outAddrBase, outReqCount, (outAddrBase+zeroExtend(outReqCount)));
|
loadReqQ1.enq(FBLoadReq (outAddrBase+zeroExtend(outReqCount)));
|
loadReqQ1.enq(FBLoadReq (outAddrBase+zeroExtend(outReqCount)));
|
if(outReqCount == {1'b0,frameinmb,6'b000000}+{2'b00,frameinmb,5'b00000}-1)
|
if(outReqCount == {1'b0,frameinmb,6'b000000}+{2'b00,frameinmb,5'b00000}-1)
|
outprocess <= Idle;
|
outprocess <= Idle;
|
outReqCount <= outReqCount+1;
|
outReqCount <= outReqCount+1;
|
end
|
end
|
endrule
|
endrule
|
|
|
|
|
rule outputingResp ( !outputframedone );
|
rule outputingResp ( !outputframedone );
|
if(loadRespQ1.first() matches tagged FBLoadResp .xdata)
|
if(loadRespQ1.first() matches tagged FBLoadResp .xdata)
|
begin
|
begin
|
loadRespQ1.deq();
|
loadRespQ1.deq();
|
outfifo.enq(tagged YUV xdata);
|
outfifo.enq(tagged YUV xdata);
|
if(outRespCount == {1'b0,frameinmb,6'b000000}+{2'b00,frameinmb,5'b00000}-1)
|
if(outRespCount == {1'b0,frameinmb,6'b000000}+{2'b00,frameinmb,5'b00000}-1)
|
outputframedone <= True;
|
outputframedone <= True;
|
outRespCount <= outRespCount+1;
|
outRespCount <= outRespCount+1;
|
end
|
end
|
endrule
|
endrule
|
|
|
|
|
rule goToNextFrame ( outputframedone && inputframedone && inLoadReqQ.first()==IPLoadEndFrame );
|
rule goToNextFrame ( outputframedone && inputframedone && inLoadReqQ.first()==IPLoadEndFrame );
|
inputframedone <= False;
|
inputframedone <= False;
|
outprocess <= Y;
|
outprocess <= Y;
|
outputframedone <= False;
|
outputframedone <= False;
|
outSlot <= inSlot;
|
outSlot <= inSlot;
|
outAddrBase <= inAddrBase;
|
outAddrBase <= inAddrBase;
|
outReqCount <= 0;
|
outReqCount <= 0;
|
outRespCount <= 0;
|
outRespCount <= 0;
|
loadReqQ1.enq(FBEndFrameSync);
|
loadReqQ1.enq(FBEndFrameSync);
|
loadReqQ2.enq(FBEndFrameSync);
|
loadReqQ2.enq(FBEndFrameSync);
|
storeReqQ.enq(FBEndFrameSync);
|
storeReqQ.enq(FBEndFrameSync);
|
inLoadReqQ.deq();
|
inLoadReqQ.deq();
|
lockInterLoads <= True;
|
lockInterLoads <= True;
|
endrule
|
endrule
|
|
|
|
|
rule unlockInterLoads ( lockInterLoads && refPicListDone );
|
rule unlockInterLoads ( lockInterLoads && refPicListDone );
|
lockInterLoads <= False;
|
lockInterLoads <= False;
|
endrule
|
endrule
|
|
|
|
|
rule theEndOfFile ( outputframedone && noMoreInput );
|
rule theEndOfFile ( outputframedone && noMoreInput );
|
outfifo.enq(tagged EndOfFile);
|
outfifo.enq(tagged EndOfFile);
|
endrule
|
endrule
|
|
|
|
|
rule interLumaReq ( inLoadReqQ.first() matches tagged IPLoadLuma .reqdata &&& !lockInterLoads );
|
rule interLumaReq ( inLoadReqQ.first() matches tagged IPLoadLuma .reqdata &&& !lockInterLoads );
|
inLoadReqQ.deq();
|
inLoadReqQ.deq();
|
Bit#(5) slot = refPicList.sub(zeroExtend(reqdata.refIdx));
|
Bit#(5) slot = refPicList.sub(zeroExtend(reqdata.refIdx));
|
Bit#(FrameBufferSz) addrBase = (zeroExtend(slot)*zeroExtend(frameinmb)*3)<<5;
|
Bit#(FrameBufferSz) addrBase = (zeroExtend(slot)*zeroExtend(frameinmb)*3)<<5;
|
Bit#(TAdd#(PicAreaSz,6)) addr = {(zeroExtend(reqdata.ver)*zeroExtend(picWidth)),2'b00}+zeroExtend(reqdata.hor);
|
Bit#(TAdd#(PicAreaSz,6)) addr = {(zeroExtend(reqdata.ver)*zeroExtend(picWidth)),2'b00}+zeroExtend(reqdata.hor);
|
inLoadOutOfBounds.enq({reqdata.horOutOfBounds,(reqdata.hor==0 ? 0 : 1)});
|
inLoadOutOfBounds.enq({reqdata.horOutOfBounds,(reqdata.hor==0 ? 0 : 1)});
|
loadReqQ2.enq(FBLoadReq (addrBase+zeroExtend(addr)));
|
loadReqQ2.enq(FBLoadReq (addrBase+zeroExtend(addr)));
|
//$display( "Trace BufferControl: interLumaReq %h %h %h %h %h", reqdata.refIdx, slot, addrBase, addr, addrBase+zeroExtend(addr));
|
//$display( "Trace BufferControl: interLumaReq %h %h %h %h %h", reqdata.refIdx, slot, addrBase, addr, addrBase+zeroExtend(addr));
|
endrule
|
endrule
|
|
|
|
|
rule interChromaReq ( inLoadReqQ.first() matches tagged IPLoadChroma .reqdata &&& !lockInterLoads );
|
rule interChromaReq ( inLoadReqQ.first() matches tagged IPLoadChroma .reqdata &&& !lockInterLoads );
|
inLoadReqQ.deq();
|
inLoadReqQ.deq();
|
Bit#(5) slot = refPicList.sub(zeroExtend(reqdata.refIdx));
|
Bit#(5) slot = refPicList.sub(zeroExtend(reqdata.refIdx));
|
Bit#(FrameBufferSz) addrBase = (zeroExtend(slot)*zeroExtend(frameinmb)*3)<<5;
|
Bit#(FrameBufferSz) addrBase = (zeroExtend(slot)*zeroExtend(frameinmb)*3)<<5;
|
Bit#(TAdd#(PicAreaSz,6)) chromaOffset = {frameinmb,6'b000000};
|
Bit#(TAdd#(PicAreaSz,6)) chromaOffset = {frameinmb,6'b000000};
|
Bit#(TAdd#(PicAreaSz,4)) vOffset = 0;
|
Bit#(TAdd#(PicAreaSz,4)) vOffset = 0;
|
if(reqdata.uv == 1)
|
if(reqdata.uv == 1)
|
vOffset = {frameinmb,4'b0000};
|
vOffset = {frameinmb,4'b0000};
|
Bit#(TAdd#(PicAreaSz,6)) addr = {(zeroExtend(reqdata.ver)*zeroExtend(picWidth)),1'b0}+zeroExtend(reqdata.hor);
|
Bit#(TAdd#(PicAreaSz,6)) addr = {(zeroExtend(reqdata.ver)*zeroExtend(picWidth)),1'b0}+zeroExtend(reqdata.hor);
|
inLoadOutOfBounds.enq({reqdata.horOutOfBounds,(reqdata.hor==0 ? 0 : 1)});
|
inLoadOutOfBounds.enq({reqdata.horOutOfBounds,(reqdata.hor==0 ? 0 : 1)});
|
loadReqQ2.enq(FBLoadReq (addrBase+zeroExtend(chromaOffset)+zeroExtend(vOffset)+zeroExtend(addr)));
|
loadReqQ2.enq(FBLoadReq (addrBase+zeroExtend(chromaOffset)+zeroExtend(vOffset)+zeroExtend(addr)));
|
//$display( "Trace BufferControl: interChromaReq %h %h %h %h %h", reqdata.refIdx, slot, addrBase, addr, addrBase+zeroExtend(chromaOffset)+zeroExtend(vOffset)+zeroExtend(addr));
|
//$display( "Trace BufferControl: interChromaReq %h %h %h %h %h", reqdata.refIdx, slot, addrBase, addr, addrBase+zeroExtend(chromaOffset)+zeroExtend(vOffset)+zeroExtend(addr));
|
endrule
|
endrule
|
|
|
|
|
rule interResp ( loadRespQ2.first() matches tagged FBLoadResp .data );
|
rule interResp ( loadRespQ2.first() matches tagged FBLoadResp .data );
|
loadRespQ2.deq();
|
loadRespQ2.deq();
|
if(inLoadOutOfBounds.first() == 2'b10)
|
if(inLoadOutOfBounds.first() == 2'b10)
|
inLoadRespQ.enq(IPLoadResp ({data[7:0],data[7:0],data[7:0],data[7:0]}));
|
inLoadRespQ.enq(IPLoadResp ({data[7:0],data[7:0],data[7:0],data[7:0]}));
|
else if(inLoadOutOfBounds.first() == 2'b11)
|
else if(inLoadOutOfBounds.first() == 2'b11)
|
inLoadRespQ.enq(IPLoadResp ({data[31:24],data[31:24],data[31:24],data[31:24]}));
|
inLoadRespQ.enq(IPLoadResp ({data[31:24],data[31:24],data[31:24],data[31:24]}));
|
else
|
else
|
inLoadRespQ.enq(tagged IPLoadResp data);
|
inLoadRespQ.enq(tagged IPLoadResp data);
|
inLoadOutOfBounds.deq();
|
inLoadOutOfBounds.deq();
|
//$display( "Trace BufferControl: interResp %h %h", inLoadOutOfBounds.first(), data);
|
//$display( "Trace BufferControl: interResp %h %h", inLoadOutOfBounds.first(), data);
|
endrule
|
endrule
|
|
|
|
|
|
|
interface Put ioin = fifoToPut(infifo);
|
interface Put ioin = fifoToPut(infifo);
|
interface Get ioout = fifoToGet(outfifo);
|
interface Get ioout = fifoToGet(outfifo);
|
interface Client buffer_client_load1;
|
interface Client buffer_client_load1;
|
interface Get request = fifoToGet(loadReqQ1);
|
interface Get request = fifoToGet(loadReqQ1);
|
interface Put response = fifoToPut(loadRespQ1);
|
interface Put response = fifoToPut(loadRespQ1);
|
endinterface
|
endinterface
|
interface Client buffer_client_load2;
|
interface Client buffer_client_load2;
|
interface Get request = fifoToGet(loadReqQ2);
|
interface Get request = fifoToGet(loadReqQ2);
|
interface Put response = fifoToPut(loadRespQ2);
|
interface Put response = fifoToPut(loadRespQ2);
|
endinterface
|
endinterface
|
interface Get buffer_client_store = fifoToGet(storeReqQ);
|
interface Get buffer_client_store = fifoToGet(storeReqQ);
|
interface Server inter_server;
|
interface Server inter_server;
|
interface Put request = fifoToPut(inLoadReqQ);
|
interface Put request = fifoToPut(inLoadReqQ);
|
interface Get response = fifoToGet(inLoadRespQ);
|
interface Get response = fifoToGet(inLoadRespQ);
|
endinterface
|
endinterface
|
|
|
|
|
endmodule
|
endmodule
|
|
|
endpackage
|
endpackage
|
|
|