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

Subversion Repositories bluespec-h264

[/] [bluespec-h264/] [trunk/] [src/] [mkInterpolator.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...
//**********************************************************************
//**********************************************************************
// interpolator implementation
// interpolator implementation
//----------------------------------------------------------------------
//----------------------------------------------------------------------
// Section 8.4.2.2 in spec
 
//
//
//
//
 
 
package mkInterpolator;
package mkInterpolator;
 
 
Line 448... Line 447...
      Vector#(16,Bit#(1)) resultReadyNext = resultReady;
      Vector#(16,Bit#(1)) resultReadyNext = resultReady;
      Vector#(4,Bit#(8)) tempResult8 = replicate(0);
      Vector#(4,Bit#(8)) tempResult8 = replicate(0);
      Vector#(4,Bit#(15)) readdata = replicate(0);
      Vector#(4,Bit#(15)) readdata = replicate(0);
      if(yfracl==0)
      if(yfracl==0)
         begin
         begin
            readdata <- workFile.sub({(1-workFileFlag),1'b0,work2VerNum[1],work2HorNum,work2VerNum[0]});
            readdata = workFile.sub({(1-workFileFlag),1'b0,work2VerNum[1],work2HorNum,work2VerNum[0]});
            for(Integer ii=0; ii<4; ii=ii+1)
            for(Integer ii=0; ii<4; ii=ii+1)
               tempResult8[ii] = (readdata[ii])[12:5];
               tempResult8[ii] = (readdata[ii])[12:5];
            resultFile.upd({work2VerNum[1],work2HorNum,work2VerNum[0]},tempResult8);
            resultFile.upd({work2VerNum[1],work2HorNum,work2VerNum[0]},tempResult8);
            resultReadyNext[{work2VerNum[1],work2HorNum,work2VerNum[0]}] = 1;
            resultReadyNext[{work2VerNum[1],work2HorNum,work2VerNum[0]}] = 1;
            work2HorNum <= work2HorNum+1;
            work2HorNum <= work2HorNum+1;
Line 474... Line 473...
                     work2VerNum <= work2VerNum+1;
                     work2VerNum <= work2VerNum+1;
               end
               end
         end
         end
      else if(xfracl==0 || xfracl==2)//vertical interpolation
      else if(xfracl==0 || xfracl==2)//vertical interpolation
         begin
         begin
            readdata <- workFile.sub({(1-workFileFlag),work2VerNum,work2HorNum[0]});
            readdata = workFile.sub({(1-workFileFlag),work2VerNum,work2HorNum[0]});
            for(Integer ii=0; ii<4; ii=ii+1)
            for(Integer ii=0; ii<4; ii=ii+1)
               begin
               begin
                  tempResult8[ii] = interpolate15to8(work2Vector15[ii],work2Vector15[ii+4],work2Vector15[ii+8],work2Vector15[ii+12],work2Vector15[ii+16],readdata[ii]);
                  tempResult8[ii] = interpolate15to8(work2Vector15[ii],work2Vector15[ii+4],work2Vector15[ii+8],work2Vector15[ii+12],work2Vector15[ii+16],readdata[ii]);
                  if(yfracl == 1)
                  if(yfracl == 1)
                     tempResult8[ii] = truncate(({1'b0,tempResult8[ii]} + {1'b0,clip1y10to8(truncate((work2Vector15[ii+8]+16)>>5))} + 1) >> 1);
                     tempResult8[ii] = truncate(({1'b0,tempResult8[ii]} + {1'b0,clip1y10to8(truncate((work2Vector15[ii+8]+16)>>5))} + 1) >> 1);
Line 524... Line 523...
      else//horizontal interpolation
      else//horizontal interpolation
         begin
         begin
            offset = offset-2;
            offset = offset-2;
            if(yfracl == 2)
            if(yfracl == 2)
               begin
               begin
                  readdata <- workFile.sub({(1-workFileFlag),work2VerNum[2:0],work2HorNum});
                  readdata = workFile.sub({(1-workFileFlag),work2VerNum[2:0],work2HorNum});
                  for(Integer ii=0; ii<8; ii=ii+1)
                  for(Integer ii=0; ii<8; ii=ii+1)
                     work2Vector15Next[ii] = work2Vector15[ii+4];
                     work2Vector15Next[ii] = work2Vector15[ii+4];
                  for(Integer ii=0; ii<4; ii=ii+1)
                  for(Integer ii=0; ii<4; ii=ii+1)
                     begin
                     begin
                        Bit#(4) tempIndex = fromInteger(ii) + 8 - zeroExtend(offset);
                        Bit#(4) tempIndex = fromInteger(ii) + 8 - zeroExtend(offset);
Line 543... Line 542...
                           tempResult8[ii] = truncate(({1'b0,tempResult8[ii]} + {1'b0,clip1y10to8(truncate((work2Vector15Next[ii+3]+16)>>5))} + 1) >> 1);
                           tempResult8[ii] = truncate(({1'b0,tempResult8[ii]} + {1'b0,clip1y10to8(truncate((work2Vector15Next[ii+3]+16)>>5))} + 1) >> 1);
                     end
                     end
               end
               end
            else
            else
               begin
               begin
                  Vector#(4,Bit#(8)) readdata8 <- storeFile.sub({(1-workFileFlag),work2VerNum[2:0],work2HorNum});
                  Vector#(4,Bit#(8)) readdata8 = storeFile.sub({(1-workFileFlag),work2VerNum[2:0],work2HorNum});
                  for(Integer ii=0; ii<8; ii=ii+1)
                  for(Integer ii=0; ii<8; ii=ii+1)
                     work2Vector8Next[ii] = work2Vector8[ii+4];
                     work2Vector8Next[ii] = work2Vector8[ii+4];
                  for(Integer ii=0; ii<4; ii=ii+1)
                  for(Integer ii=0; ii<4; ii=ii+1)
                     begin
                     begin
                        Bit#(4) tempIndex = fromInteger(ii) + 8 - zeroExtend(offset);
                        Bit#(4) tempIndex = fromInteger(ii) + 8 - zeroExtend(offset);
Line 563... Line 562...
                  Vector#(4,Bit#(15)) verResult15 = replicate(0);
                  Vector#(4,Bit#(15)) verResult15 = replicate(0);
                  if(xfracl == 1)
                  if(xfracl == 1)
                     verOffset = reqdata.offset;
                     verOffset = reqdata.offset;
                  else
                  else
                     verOffset = reqdata.offset+1;
                     verOffset = reqdata.offset+1;
                  readdata <- workFile.sub({(1-workFileFlag),work2VerNum[2:0],(work2HorNum-2+(verOffset==0?0:1))});
                  readdata = workFile.sub({(1-workFileFlag),work2VerNum[2:0],(work2HorNum-2+(verOffset==0?0:1))});
                  for(Integer ii=0; ii<4; ii=ii+1)
                  for(Integer ii=0; ii<4; ii=ii+1)
                     begin
                     begin
                        Bit#(2) offsetplusii = verOffset+fromInteger(ii);
                        Bit#(2) offsetplusii = verOffset+fromInteger(ii);
                        if(verOffset <= 3-fromInteger(ii) && verOffset!=0)
                        if(verOffset <= 3-fromInteger(ii) && verOffset!=0)
                           verResult15[ii] = work2Vector15[offsetplusii];
                           verResult15[ii] = work2Vector15[offsetplusii];
Line 746... Line 745...
   endrule
   endrule
 
 
 
 
   rule work2Chroma ( reqregWork2 matches tagged Valid .vdata &&& vdata matches tagged IPWChroma .reqdata &&& !work2Done &&& !work8x8Done );
   rule work2Chroma ( reqregWork2 matches tagged Valid .vdata &&& vdata matches tagged IPWChroma .reqdata &&& !work2Done &&& !work8x8Done );
      Vector#(16,Bit#(1)) resultReadyNext = resultReady;
      Vector#(16,Bit#(1)) resultReadyNext = resultReady;
      Vector#(4,Bit#(8)) resultData <- storeFile.sub({(1-workFileFlag),1'b0,work2VerNum[1],work2HorNum,work2VerNum[0]});
      resultFile.upd({work2VerNum[1],work2HorNum,work2VerNum[0]},storeFile.sub({(1-workFileFlag),1'b0,work2VerNum[1],work2HorNum,work2VerNum[0]}));
      resultFile.upd({work2VerNum[1],work2HorNum,work2VerNum[0]},resultData);
 
      resultReadyNext[{work2VerNum[1],work2HorNum,work2VerNum[0]}] = 1;
      resultReadyNext[{work2VerNum[1],work2HorNum,work2VerNum[0]}] = 1;
      work2HorNum <= work2HorNum+1;
      work2HorNum <= work2HorNum+1;
      if(work2HorNum == 3)
      if(work2HorNum == 3)
         begin
         begin
            if(work2VerNum == 3)
            if(work2VerNum == 3)
Line 767... Line 765...
      $display( "Trace interpolator: work2Chroma %h %h", work2HorNum, work2VerNum);
      $display( "Trace interpolator: work2Chroma %h %h", work2HorNum, work2VerNum);
   endrule
   endrule
 
 
 
 
  rule outputing( !outDone && resultReady[{outBlockNum[1],outPixelNum,outBlockNum[0]}]==1 );
  rule outputing( !outDone && resultReady[{outBlockNum[1],outPixelNum,outBlockNum[0]}]==1 );
      Vector#(4,Bit#(8)) outputData <- resultFile.sub({outBlockNum[1],outPixelNum,outBlockNum[0]});
      outfifo.enq(resultFile.sub({outBlockNum[1],outPixelNum,outBlockNum[0]}));
      outfifo.enq(outputData);
 
      outPixelNum <= outPixelNum+1;
      outPixelNum <= outPixelNum+1;
      if(outPixelNum == 3)
      if(outPixelNum == 3)
         begin
         begin
            outBlockNum <= outBlockNum+1;
            outBlockNum <= outBlockNum+1;
            if(outBlockNum == 3)
            if(outBlockNum == 3)
Line 783... Line 780...
 
 
 
 
   rule switching( work1Done && (work2Done || reqregWork2==Invalid) && !work8x8Done);
   rule switching( work1Done && (work2Done || reqregWork2==Invalid) && !work8x8Done);
      work1Done <= False;
      work1Done <= False;
      work2Done <= False;
      work2Done <= False;
      reqregWork2 <= (Valid (reqfifoWork1.first()));
      reqregWork2 <= (Valid reqfifoWork1.first());
      workFileFlag <= 1-workFileFlag;
      workFileFlag <= 1-workFileFlag;
      reqfifoWork1.deq();
      reqfifoWork1.deq();
      $display( "Trace interpolator: switching %h %h", outBlockNum, outPixelNum);
      $display( "Trace interpolator: switching %h %h", outBlockNum, outPixelNum);
   endrule
   endrule
 
 
Line 796... Line 793...
      outDone <= False;
      outDone <= False;
      work8x8Done <= False;
      work8x8Done <= False;
      resultReady <= replicate(0);
      resultReady <= replicate(0);
      work1Done <= False;
      work1Done <= False;
      work2Done <= False;
      work2Done <= False;
      reqregWork2 <= (Valid (reqfifoWork1.first()));
      reqregWork2 <= (Valid reqfifoWork1.first());
      workFileFlag <= 1-workFileFlag;
      workFileFlag <= 1-workFileFlag;
      reqfifoWork1.deq();
      reqfifoWork1.deq();
      $display( "Trace interpolator: switching8x8 %h %h", outBlockNum, outPixelNum);
      $display( "Trace interpolator: switching8x8 %h %h", outBlockNum, outPixelNum);
   endrule
   endrule
 
 

powered by: WebSVN 2.1.0

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