// 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.
|
//**********************************************************************
|
//**********************************************************************
|
// final output implementation
|
// final output implementation
|
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
//
|
//
|
//
|
//
|
|
|
package mkFinalOutput;
|
package mkFinalOutput;
|
|
|
import H264Types::*;
|
import H264Types::*;
|
import IFinalOutput::*;
|
import IFinalOutput::*;
|
import FIFO::*;
|
import FIFO::*;
|
import RegFile::*;
|
import RegFile::*;
|
|
|
import Connectable::*;
|
import Connectable::*;
|
import GetPut::*;
|
import GetPut::*;
|
|
|
//-----------------------------------------------------------
|
//-----------------------------------------------------------
|
// Final Output Module
|
// Final Output Module
|
//-----------------------------------------------------------
|
//-----------------------------------------------------------
|
|
|
module mkFinalOutput( IFinalOutput );
|
module mkFinalOutput( IFinalOutput );
|
|
|
FIFO#(BufferControlOT) infifo <- mkFIFO;
|
FIFO#(BufferControlOT) infifo <- mkFIFO;
|
Reg#(Bit#(27)) index <- mkReg(0);
|
Reg#(Bit#(27)) index <- mkReg(0);
|
|
|
Reg#(Bit#(32)) tick_counter <- mkReg(0);
|
Reg#(Bit#(32)) tick_counter <- mkReg(0);
|
Reg#(Bit#(32)) data_seen_counter <- mkReg(0);
|
Reg#(Bit#(32)) data_seen_counter <- mkReg(0);
|
Reg#(Bit#(32)) last_f_count <- mkReg(0);
|
Reg#(Bit#(32)) last_f_count <- mkReg(0);
|
Reg#(Bit#(32)) f_count <- mkReg(0);
|
Reg#(Bit#(32)) f_count <- mkReg(0);
|
|
|
rule tick;
|
rule tick;
|
tick_counter <= tick_counter + 1;
|
tick_counter <= tick_counter + 1;
|
if(tick_counter%2000000 == 0)
|
if(tick_counter%2000000 == 0)
|
begin
|
begin
|
if(last_f_count == f_count)
|
if(last_f_count == f_count)
|
begin
|
begin
|
$display("mkFinalOutput: Warning: no new frames, stuck at %d", last_f_count);
|
$display("mkFinalOutput: Warning: no new frames, stuck at %d", last_f_count);
|
end
|
end
|
else
|
else
|
begin
|
begin
|
$display("mkFinalOutput: Feelin' fine current frames: %d", last_f_count);
|
$display("mkFinalOutput: Feelin' fine current frames: %d", last_f_count);
|
end
|
end
|
last_f_count <= f_count;
|
last_f_count <= f_count;
|
end
|
end
|
endrule
|
endrule
|
|
|
//-----------------------------------------------------------
|
//-----------------------------------------------------------
|
// Rules
|
// Rules
|
rule finalout (True);
|
rule finalout (True);
|
// Bit#(32) data_constant = pack(fromInteger(horizontal_pixels * vertical_pixels))*3/2;
|
// Bit#(32) data_constant = pack(fromInteger(horizontal_pixels * vertical_pixels))*3/2;
|
//if(data_seen_counter + 4 > data_constant)
|
//if(data_seen_counter + 4 > data_constant)
|
// begin
|
// begin
|
// f_count <= f_count + 1;
|
// f_count <= f_count + 1;
|
// data_seen_counter <= 0;
|
// data_seen_counter <= 0;
|
// end
|
// end
|
//else
|
//else
|
// begin
|
// begin
|
// data_seen_counter <= data_seen_counter+4;
|
// data_seen_counter <= data_seen_counter+4;
|
// end
|
// end
|
|
|
index <= index + 4;
|
index <= index + 4;
|
if(infifo.first() matches tagged YUV .xdata)
|
if(infifo.first() matches tagged YUV .xdata)
|
begin
|
begin
|
$display("OUT %h", xdata[7:0]);
|
$display("OUT %h", xdata[7:0]);
|
$display("OUT %h", xdata[15:8]);
|
$display("OUT %h", xdata[15:8]);
|
$display("OUT %h", xdata[23:16]);
|
$display("OUT %h", xdata[23:16]);
|
$display("OUT %h", xdata[31:24]);
|
$display("OUT %h", xdata[31:24]);
|
infifo.deq();
|
infifo.deq();
|
end
|
end
|
else
|
else
|
$finish(0);
|
$finish(0);
|
endrule
|
endrule
|
|
|
|
|
interface Put ioin = fifoToPut(infifo);
|
interface Put ioin = fifoToPut(infifo);
|
|
|
endmodule
|
endmodule
|
|
|
|
|