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

Subversion Repositories bluespec-h264

[/] [bluespec-h264/] [trunk/] [src/] [mkFinalOutput.bsv] - Blame information for rev 9

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 jamey.hick
//**********************************************************************
2
// final output implementation
3
//----------------------------------------------------------------------
4
//
5
//
6
 
7
package mkFinalOutput;
8
 
9
import H264Types::*;
10
import IFinalOutput::*;
11
import FIFO::*;
12 6 jamey.hick
import RegFile::*;
13 2 jamey.hick
 
14
import Connectable::*;
15
import GetPut::*;
16
 
17 6 jamey.hick
`define INPUT_SIZE 17740800
18
 
19 2 jamey.hick
//-----------------------------------------------------------
20
// Final Output Module
21
//-----------------------------------------------------------
22
 
23
module mkFinalOutput( IFinalOutput );
24
 
25
   FIFO#(BufferControlOT)  infifo    <- mkFIFO;
26 6 jamey.hick
   RegFile#(Bit#(27), Bit#(8)) rfile <- mkRegFileLoad("golden.hex", 0, `INPUT_SIZE);
27
 
28
   Reg#(Bit#(27))    index   <- mkReg(0);
29 2 jamey.hick
 
30 6 jamey.hick
   Reg#(Bit#(32)) tick_counter <- mkReg(0);
31
   Reg#(Bit#(32)) data_seen_counter <- mkReg(0);
32
   Reg#(Bit#(32)) last_f_count <- mkReg(0);
33
   Reg#(Bit#(32)) f_count <- mkReg(0);
34
 
35
   rule tick;
36
     tick_counter <= tick_counter + 1;
37
     if(tick_counter%2000000 == 0)
38
       begin
39
         if(last_f_count == f_count)
40
           begin
41
             $display("mkFinalOutput: Warning: no new frames, stuck at %d", last_f_count);
42
           end
43
         else
44
           begin
45
             $display("mkFinalOutput: Feelin' fine current frames: %d", last_f_count);
46
           end
47
         last_f_count <= f_count;
48
       end
49
   endrule
50
 
51 2 jamey.hick
   //-----------------------------------------------------------
52
   // Rules
53 6 jamey.hick
   rule finalout (True);
54
      Bit#(32) data_constant = pack(fromInteger(horizontal_pixels * vertical_pixels))*3/2;
55
      if(data_seen_counter + 4 > data_constant)
56
        begin
57
          f_count <= f_count + 1;
58
          data_seen_counter <= 0;
59
        end
60
      else
61
        begin
62
          data_seen_counter <= data_seen_counter+4;
63
        end
64
 
65
      index <= index + 4;
66 2 jamey.hick
      if(infifo.first() matches tagged YUV .xdata)
67
         begin
68 9 jamey.hick
            $display("OUT %h", xdata[31:24]);
69
            $display("OUT %h", xdata[23:16]);
70
            $display("OUT %h", xdata[15:8]);
71
            $display("OUT %h", xdata[7:0]);
72 6 jamey.hick
            if( xdata[7:0] != rfile.sub(index))
73
              begin
74 9 jamey.hick
                $display("mkFinalOutput: ccl5finalout ERROR %h, index %d", xdata[7:0], index);
75 6 jamey.hick
              end
76
            if( xdata[15:8] != rfile.sub(index + 1))
77
              begin
78 9 jamey.hick
                $display("mkFinalOutput: ccl5finalout ERROR %h, index %d", xdata[15:8], index + 1);
79 6 jamey.hick
              end
80
            if( xdata[23:16] != rfile.sub(index+2))
81
              begin
82 9 jamey.hick
                $display("mkFinalOutput: ccl5finalout ERROR %h, index %d", xdata[23:16], index+2);
83 6 jamey.hick
              end
84
            if( xdata[31:24] != rfile.sub(index+3))
85
              begin
86 9 jamey.hick
                $display("mkFinalOutput: ccl5finalout ERROR %h, index %d", xdata[31:24], index+3);
87 6 jamey.hick
              end
88 2 jamey.hick
            infifo.deq();
89
         end
90
      else
91
         $finish(0);
92
   endrule
93
 
94
 
95
   interface Put ioin  = fifoToPut(infifo);
96
 
97
endmodule
98
 
99
endpackage

powered by: WebSVN 2.1.0

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