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

Subversion Repositories bluespec-h264

[/] [bluespec-h264/] [trunk/] [src/] [mkPrediction.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...
//**********************************************************************
//**********************************************************************
// Prediction
// Prediction
//----------------------------------------------------------------------
//----------------------------------------------------------------------
// Sections 8.3 and 8.4 in spec
 
//
//
//
//
 
 
package mkPrediction;
package mkPrediction;
 
 
Line 13... Line 12...
import IInterpolator::*;
import IInterpolator::*;
import mkInterpolator::*;
import mkInterpolator::*;
import FIFO::*;
import FIFO::*;
import FIFOF::*;
import FIFOF::*;
import Vector::*;
import Vector::*;
import RegFile::*;
 
import Connectable::*;
import Connectable::*;
import GetPut::*;
import GetPut::*;
import ClientServer::*;
import ClientServer::*;
 
 
 
 
Line 186... Line 185...
   Reg#(Bit#(2)) interMbPartNum <- mkReg(0);
   Reg#(Bit#(2)) interMbPartNum <- mkReg(0);
   Reg#(Bit#(2)) interSubMbPartNum <- mkReg(0);
   Reg#(Bit#(2)) interSubMbPartNum <- mkReg(0);
   Reg#(Bit#(2)) interPassingCount <- mkReg(0);
   Reg#(Bit#(2)) interPassingCount <- mkReg(0);
   Reg#(Vector#(4,Bit#(4))) interRefIdxVector <- mkRegU();
   Reg#(Vector#(4,Bit#(4))) interRefIdxVector <- mkRegU();
   Reg#(Vector#(4,Bit#(2))) interSubMbTypeVector <- mkRegU();
   Reg#(Vector#(4,Bit#(2))) interSubMbTypeVector <- mkRegU();
   // Fix this at some point
   RFile1#(Bit#(4),Tuple2#(Bit#(14),Bit#(12))) interMvFile <- mkRFile1Full();
   RegFile#(Bit#(4),Tuple2#(Bit#(14),Bit#(12))) interMvFile <- mkRegFileFull();
 
   Reg#(Bit#(15)) interMvDiffTemp <- mkReg(0);
   Reg#(Bit#(15)) interMvDiffTemp <- mkReg(0);
   FIFO#(Tuple2#(Bit#(15),Bit#(13))) interMvDiff <- mkFIFO;
   FIFO#(Tuple2#(Bit#(15),Bit#(13))) interMvDiff <- mkFIFO;
   Reg#(Bit#(5)) interNewestMv <- mkReg(0);
   Reg#(Bit#(5)) interNewestMv <- mkReg(0);
 
 
   Reg#(Bit#(2)) interIPStepCount <- mkReg(0);
   Reg#(Bit#(2)) interIPStepCount <- mkReg(0);
Line 295... Line 293...
               firstMb   <= xdata;
               firstMb   <= xdata;
               currMb    <= xdata;
               currMb    <= xdata;
               currMbHor <= xdata;
               currMbHor <= xdata;
               currMbVer <= 0;
               currMbVer <= 0;
               intra4x4typeLeft <= replicate(15);
               intra4x4typeLeft <= replicate(15);
               interTopLeftVal <= replicate(NotInter (0));
               interTopLeftVal <= replicate(NotInter 0);
               if(xdata==0)
               if(xdata==0)
                  interLeftVal <= replicate(NotInter (0));
                  interLeftVal <= replicate(NotInter 0);
               outFirstQPFlag <= True;
               outFirstQPFlag <= True;
            end
            end
         tagged SDmb_skip_run .xdata : passFlag <= False;
         tagged SDmb_skip_run .xdata : passFlag <= False;
         tagged SDMmbtype .xdata : passFlag <= False;
         tagged SDMmbtype .xdata : passFlag <= False;
         tagged EndOfFile :
         tagged EndOfFile :
Line 336... Line 334...
                                 interstate <= InterPskip;
                                 interstate <= InterPskip;
                                 interReqCount <= 1;
                                 interReqCount <= 1;
                                 interRespCount <= 1;
                                 interRespCount <= 1;
                                 intra4x4typeLeft <= replicate(14);
                                 intra4x4typeLeft <= replicate(14);
                                 intra4x4typeTop <= replicate(14);
                                 intra4x4typeTop <= replicate(14);
                                 interTopLeftVal <= update(interTopLeftVal , 0, (NotInter (0)));
                                 interTopLeftVal <= update(interTopLeftVal , 0, (NotInter 0));
                                 interTopVal <= replicate(NotInter (0));
                                 interTopVal <= replicate(NotInter 0);
                                 interPskipCount <= interPskipCount+1;
                                 interPskipCount <= interPskipCount+1;
                                 interNewestMv <= 0;
                                 interNewestMv <= 0;
                                 interRefIdxVector <= replicate(0);
                                 interRefIdxVector <= replicate(0);
                                 interCurrMbDiff <= interCurrMbDiff+1;
                                 interCurrMbDiff <= interCurrMbDiff+1;
                                 nextoutputfifo.enq(SkipMB);
                                 nextoutputfifo.enq(SkipMB);
Line 375... Line 373...
                                    intra16x16_pred_mode <= tempv1;
                                    intra16x16_pred_mode <= tempv1;
                                 else
                                 else
                                    $display( "ERROR Prediction: MacroblockLayer 5 sdmmbtype not I_16x16" );
                                    $display( "ERROR Prediction: MacroblockLayer 5 sdmmbtype not I_16x16" );
                                 intraReqCount <= 1;
                                 intraReqCount <= 1;
                                 intraRespCount <= 1;
                                 intraRespCount <= 1;
                                 interTopLeftVal <= replicate(NotInter (1));
                                 interTopLeftVal <= replicate(NotInter 1);
                                 interLeftVal <= replicate(NotInter (1));
                                 interLeftVal <= replicate(NotInter 1);
                                 interTopVal <= replicate(NotInter (1));
                                 interTopVal <= replicate(NotInter 1);
                              end
                              end
                           else
                           else
                              donotfire.doNotFire();
                              donotfire.doNotFire();
                        end
                        end
                     else if(xdata==I_NxN)
                     else if(xdata==I_NxN)
Line 390... Line 388...
                              begin
                              begin
                                 outstatefifo.enq(Intra4x4);
                                 outstatefifo.enq(Intra4x4);
                                 intrastate <= Intra4x4;
                                 intrastate <= Intra4x4;
                                 intraReqCount <= 1;
                                 intraReqCount <= 1;
                                 intraRespCount <= 1;
                                 intraRespCount <= 1;
                                 interTopLeftVal <= replicate(NotInter (1));
                                 interTopLeftVal <= replicate(NotInter 1);
                                 interLeftVal <= replicate(NotInter (1));
                                 interLeftVal <= replicate(NotInter 1);
                                 interTopVal <= replicate(NotInter (1));
                                 interTopVal <= replicate(NotInter 1);
                              end
                              end
                           else
                           else
                              donotfire.doNotFire();
                              donotfire.doNotFire();
                        end
                        end
                     else if(xdata==I_PCM)
                     else if(xdata==I_PCM)
                        begin
                        begin
                           $display( "ERROR Prediction: I_PCM not implemented yet");
                           $display( "ERROR Prediction: I_PCM not implemented yet");
                           $finish;////////////////////////////////////////////////////////////////////////////////////////
                           $finish;////////////////////////////////////////////////////////////////////////////////////////
                           intra4x4typeLeft <= replicate(13);
                           intra4x4typeLeft <= replicate(13);
                           intra4x4typeTop <= replicate(13);
                           intra4x4typeTop <= replicate(13);
                           interTopLeftVal <= replicate(NotInter (1));
                           interTopLeftVal <= replicate(NotInter 1);
                           interLeftVal <= replicate(NotInter (1));
                           interLeftVal <= replicate(NotInter 1);
                           interTopVal <= replicate(NotInter (1));
                           interTopVal <= replicate(NotInter 1);
                        end
                        end
                     else
                     else
                        begin
                        begin
                           if(!outstatefifo.notEmpty() || interCurrMbDiff
                           if(!outstatefifo.notEmpty() || interCurrMbDiff
                              begin
                              begin
Line 424... Line 422...
                                 endcase
                                 endcase
                                 interReqCount <= 1;
                                 interReqCount <= 1;
                                 interRespCount <= 1;
                                 interRespCount <= 1;
                                 intra4x4typeLeft <= replicate(14);/////////////////////////////////////////////////////////////////////////////
                                 intra4x4typeLeft <= replicate(14);/////////////////////////////////////////////////////////////////////////////
                                 intra4x4typeTop <= replicate(14);
                                 intra4x4typeTop <= replicate(14);
                                 interTopLeftVal <= update(interTopLeftVal , 0, (NotInter (0)));
                                 interTopLeftVal <= update(interTopLeftVal , 0, (NotInter 0));
                                 interTopVal <= replicate(NotInter (0));
                                 interTopVal <= replicate(NotInter 0);
                                 interNewestMv <= 0;
                                 interNewestMv <= 0;
                                 interRefIdxVector <= replicate(0);
                                 interRefIdxVector <= replicate(0);
                                 nextoutputfifo.enq(NonSkipMB);
                                 nextoutputfifo.enq(NonSkipMB);
                              end
                              end
                           else
                           else
Line 550... Line 548...
               end
               end
            else
            else
               begin
               begin
                  interBSoutput <= True;
                  interBSoutput <= True;
                  outputVector = predictedfifo.first();
                  outputVector = predictedfifo.first();
                  outfifo.enq(PBoutput (outputVector));
                  outfifo.enq(PBoutput outputVector);
                  outputFlag = 1;
                  outputFlag = 1;
                  predictedfifo.deq();
                  predictedfifo.deq();
                  $display( "Trace Prediction: outputing SkipMB out %h %h %h", outBlockNum, outPixelNum, outputVector);
                  $display( "Trace Prediction: outputing SkipMB out %h %h %h", outBlockNum, outPixelNum, outputVector);
               end
               end
         end
         end
Line 600... Line 598...
                                 else if(tempOutputValue[9:0] > 255)
                                 else if(tempOutputValue[9:0] > 255)
                                    outputVector[ii] = 255;
                                    outputVector[ii] = 255;
                                 else
                                 else
                                    outputVector[ii] = tempOutputValue[7:0];
                                    outputVector[ii] = tempOutputValue[7:0];
                              end
                              end
                           outfifo.enq(PBoutput (outputVector));
                           outfifo.enq(PBoutput outputVector);
                           infifo_ITB.deq();
                           infifo_ITB.deq();
                           predictedfifo.deq();
                           predictedfifo.deq();
                           outputFlag = 1;
                           outputFlag = 1;
                           $display( "Trace Prediction: outputing ITBresidual out %h %h %h %h %h %h", outChromaFlag, outBlockNum, outPixelNum, predictedfifo.first(), xdata, outputVector);
                           $display( "Trace Prediction: outputing ITBresidual out %h %h %h %h %h %h", outChromaFlag, outBlockNum, outPixelNum, predictedfifo.first(), xdata, outputVector);
                        end
                        end
Line 633... Line 631...
                        begin
                        begin
                           interBSoutput <= True;
                           interBSoutput <= True;
                           if(outPixelNum == 12)
                           if(outPixelNum == 12)
                              infifo_ITB.deq();
                              infifo_ITB.deq();
                           outputVector = predictedfifo.first();
                           outputVector = predictedfifo.first();
                           outfifo.enq(PBoutput (outputVector));
                           outfifo.enq(PBoutput outputVector);
                           outputFlag = 1;
                           outputFlag = 1;
                           predictedfifo.deq();
                           predictedfifo.deq();
                           $display( "Trace Prediction: outputing ITBcoeffLevelZeros out %h %h %h %h %h", outChromaFlag, outBlockNum, outPixelNum, predictedfifo.first(), outputVector);
                           $display( "Trace Prediction: outputing ITBcoeffLevelZeros out %h %h %h %h %h", outChromaFlag, outBlockNum, outPixelNum, predictedfifo.first(), outputVector);
                        end
                        end
                  end
                  end
Line 848... Line 846...
            else
            else
               noMoreReq = True;
               noMoreReq = True;
         end
         end
      if(!noMoreReq)
      if(!noMoreReq)
         begin
         begin
            interMemReqQ.enq(LoadReq (temp));
            interMemReqQ.enq(LoadReq temp);
            interReqCount <= interReqCount+1;
            interReqCount <= interReqCount+1;
            //$display( "TRACE Prediction: interSendReq addr %0d",temp);///////////////////////
            //$display( "TRACE Prediction: interSendReq addr %0d",temp);///////////////////////
         end
         end
      else
      else
         interReqCount <= 0;
         interReqCount <= 0;
Line 867... Line 865...
      interRespCount <= 0;
      interRespCount <= 0;
      interStepCount <= 1;
      interStepCount <= 1;
      interIPStepCount <= 1;
      interIPStepCount <= 1;
      if(currMbHorTemp == 0)
      if(currMbHorTemp == 0)
         begin
         begin
            interLeftVal <= replicate(NotInter (0));
            interLeftVal <= replicate(NotInter 0);
            interTopLeftVal <= replicate(NotInter (0));
            interTopLeftVal <= replicate(NotInter 0);
         end
         end
      $display( "Trace Prediction: interReceiveNoResp %h %h", interstate, interRespCount);
      $display( "Trace Prediction: interReceiveNoResp %h %h", interstate, interRespCount);
   endrule
   endrule
 
 
 
 
Line 922... Line 920...
            interRespCount <= 0;
            interRespCount <= 0;
            interStepCount <= 1;
            interStepCount <= 1;
            interIPStepCount <= 1;
            interIPStepCount <= 1;
            if(currMbHorTemp == 0)
            if(currMbHorTemp == 0)
               begin
               begin
                  interLeftVal <= replicate(NotInter (0));
                  interLeftVal <= replicate(NotInter 0);
                  interTopLeftValNext = replicate(NotInter (0));
                  interTopLeftValNext = replicate(NotInter 0);
               end
               end
         end
         end
      interTopVal <= interTopValNext;
      interTopVal <= interTopValNext;
      interTopLeftVal <= interTopLeftValNext;
      interTopLeftVal <= interTopLeftValNext;
      $display( "Trace Prediction: interReceiveResp %h %h %h", interstate, interRespCount, data);
      $display( "Trace Prediction: interReceiveResp %h %h %h", interstate, interRespCount, data);
Line 1014... Line 1012...
            endcase
            endcase
         end
         end
      else
      else
         $display( "ERROR Prediction: interProcessStep unexpected interstate");
         $display( "ERROR Prediction: interProcessStep unexpected interstate");
      Bit#(4) refIndex = ((interstate==InterPskip||interstate==InterP8x8ref0) ? 0 : interRefIdxVector[interMbPartNum]);
      Bit#(4) refIndex = ((interstate==InterPskip||interstate==InterP8x8ref0) ? 0 : interRefIdxVector[interMbPartNum]);
      Vector#(3,InterBlockMv) blockABC = replicate(NotInter (0));
      Vector#(3,InterBlockMv) blockABC = replicate(NotInter 0);
      if( currMbTemp-firstMb==0 && blockHor==0 )
      if( currMbTemp-firstMb==0 && blockHor==0 )
         blockABC[0] = (NotInter (0));
         blockABC[0] = (NotInter 0);
      else
      else
         blockABC[0] = interLeftVal[blockVer];
         blockABC[0] = interLeftVal[blockVer];
      if( currMbTemp-firstMb
      if( currMbTemp-firstMb
         blockABC[1] = (NotInter (0));
         blockABC[1] = (NotInter 0);
      else
      else
         blockABC[1] = interTopVal[blockHor];
         blockABC[1] = interTopVal[blockHor];
      blockABC[2] = interTopVal[{1'b0,blockHor}+partWidth];
      blockABC[2] = interTopVal[{1'b0,blockHor}+partWidth];
      if(noBlockC || blockABC[2]==(NotInter (0)))
      if(noBlockC || blockABC[2]==(NotInter 0))
         blockABC[2] = interTopLeftVal[blockVer];
         blockABC[2] = interTopLeftVal[blockVer];
      Bit#(14) mvhorfinal = 0;
      Bit#(14) mvhorfinal = 0;
      Bit#(12) mvverfinal = 0;
      Bit#(12) mvverfinal = 0;
      Bit#(5) interNewestMvNext = 0;
      Bit#(5) interNewestMvNext = 0;
      if(calcmv)//motion vector caculation
      if(calcmv)//motion vector caculation
Line 1082... Line 1080...
                                 begin
                                 begin
                                    mvhorPred = 0;
                                    mvhorPred = 0;
                                    mvverPred = 0;
                                    mvverPred = 0;
                                 end
                                 end
                           end
                           end
                        else if(blockABC[ii] matches tagged NotInter (0))
                        else if(blockABC[ii] matches tagged NotInter 0)
                           begin
                           begin
                              mvhorPred = 0;
                              mvhorPred = 0;
                              mvverPred = 0;
                              mvverPred = 0;
                           end
                           end
                     end
                     end
Line 1357... Line 1355...
            else
            else
               noMoreReq = 1;
               noMoreReq = 1;
         end
         end
      if(noMoreReq == 0)
      if(noMoreReq == 0)
         begin
         begin
            intraMemReqQ.enq(LoadReq (temp));
            intraMemReqQ.enq(LoadReq temp);
            intraReqCount <= intraReqCount+1;
            intraReqCount <= intraReqCount+1;
            //$display( "TRACE Prediction: intraSendReq addr %0d",temp);///////////////////////
            //$display( "TRACE Prediction: intraSendReq addr %0d",temp);///////////////////////
         end
         end
      else
      else
         intraReqCount <= 0;
         intraReqCount <= 0;
Line 1373... Line 1371...
      intra4x4typeTop <= replicate(15);
      intra4x4typeTop <= replicate(15);
      intraRespCount <= 0;
      intraRespCount <= 0;
      intraStepCount <= 1;
      intraStepCount <= 1;
      blockNum <= 0;
      blockNum <= 0;
      pixelNum <= 0;
      pixelNum <= 0;
      interOutBlockMvfifo.enq(NotInter (1));
      interOutBlockMvfifo.enq(NotInter 1);
      $display( "Trace Prediction: intraReceiveNoResp");
      $display( "Trace Prediction: intraReceiveNoResp");
   endrule
   endrule
 
 
 
 
   rule intraReceiveResp ( intraRespCount>0 && intraRespCount<7 && currMbHor
   rule intraReceiveResp ( intraRespCount>0 && intraRespCount<7 && currMbHor
Line 1435... Line 1433...
         begin
         begin
            intraRespCount <= 0;
            intraRespCount <= 0;
            intraStepCount <= 1;
            intraStepCount <= 1;
            blockNum <= 0;
            blockNum <= 0;
            pixelNum <= 0;
            pixelNum <= 0;
            interOutBlockMvfifo.enq(NotInter (1));
            interOutBlockMvfifo.enq(NotInter 1);
         end
         end
      $display( "Trace Prediction: intraReceiveResp");
      $display( "Trace Prediction: intraReceiveResp");
   endrule
   endrule
 
 
 
 

powered by: WebSVN 2.1.0

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