OpenCores
URL https://opencores.org/ocsvn/bluespec-h264/bluespec-h264/trunk

Subversion Repositories bluespec-h264

[/] [bluespec-h264/] [trunk/] [src/] [mkBufferControl.bsv] - Diff between revs 15 and 19

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 15 Rev 19
Line 1... Line 1...
//**********************************************************************
//**********************************************************************
// Buffer Controller
// Buffer Controller
//----------------------------------------------------------------------
//----------------------------------------------------------------------
// Sections 8.2.4 and 8.2.5 in spec
 
//
//
//
//
 
 
package mkBufferControl;
package mkBufferControl;
 
 
Line 86... Line 85...
   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(Valid (tpl_2(temp)));
                     returnList.enq(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);
            let rData <- rfile.sub(tempPic);
            rfile.upd(tempPrev,rfile.sub(tempPic));
            rfile.upd(tempPrev,rData);
 
            if(tempCount==picCount)
            if(tempCount==picCount)
               begin
               begin
                  picCount <= picCount-1;
                  picCount <= picCount-1;
                  nextPic <= tempPrev;
                  nextPic <= tempPrev;
                  state <= Idle;
                  state <= Idle;
Line 135... Line 133...
   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(Valid (tpl_2(temp)));
                  returnList.enq(Valid tpl_2(temp));
                  state <= Idle;
                  state <= Idle;
               end
               end
            tempPic <= shortTermPicListPrev(tempPic);
            tempPic <= shortTermPicListPrev(tempPic);
            tempCount <= tempCount+1;
            tempCount <= tempCount+1;
         end
         end
Line 151... Line 149...
   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(Valid (tpl_2(temp)));
            returnList.enq(Valid tpl_2(temp));
            tempPic <= shortTermPicListPrev(tempPic);
            tempPic <= shortTermPicListPrev(tempPic);
            tempCount <= tempCount+1;
            tempCount <= tempCount+1;
         end
         end
      else
      else
         begin
         begin
Line 273... Line 271...
   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
            let rData <- rfile.sub(tempPic);
            if(rfile.sub(tempPic) matches tagged Valid .data &&& picCount!=0)
            if(rData 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
Line 287... Line 284...
   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(Valid (data));
               returnList.enq(Valid data);
            tempPic <= tempPic+1;
            tempPic <= tempPic+1;
         end
         end
      else
      else
         begin
         begin
            returnList.enq(Invalid);
            returnList.enq(Invalid);
Line 307... Line 304...
      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);
      let rData <- rfile.sub(frameNum);
      if(rfile.sub(frameNum) matches tagged Invalid)
      if(rData matches tagged Invalid)
 
         picCount <= picCount+1;
         picCount <= picCount+1;
      rfile.upd(frameNum,Valid (slot));
      rfile.upd(frameNum,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);
      let rData <- rfile.sub(frameNum);
      if(rfile.sub(frameNum) matches tagged Invalid)
      if(rData 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);
Line 331... Line 326...
      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);
      let rData <- rfile.sub(frameNum);
      returnList.enq(rfile.sub(frameNum));
      returnList.enq(rData);
 
      //$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;
Line 783... Line 777...
   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();
            let picListData <- refPicList.sub(refIdx);
            tempSlot <= refPicList.sub(refIdx);
            tempSlot <= picListData;
 
            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
            let picListData <- refPicList.sub(refIdx);
 
            longTermPicList.deq();
            longTermPicList.deq();
            tempSlot <= picListData;
            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
                  let picListData <- refPicList.sub(refPicListCount);
                  tempSlot <= refPicList.sub(refPicListCount);
                  tempSlot <= picListData;
 
                  refPicList.upd(refPicListCount,tempSlot);
                  refPicList.upd(refPicListCount,tempSlot);
                  refPicListCount <= refPicListCount+1;
                  refPicListCount <= refPicListCount+1;
               end
               end
            else
            else
               begin
               begin
Line 881... Line 872...
 
 
   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(YUV (xdata));
            outfifo.enq(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
Line 917... Line 908...
   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};
Line 948... Line 939...
      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(IPLoadResp (data));
         inLoadRespQ.enq(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
 
 
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2025 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.