Line 1... |
Line 1... |
|
//////////////////////////////////////////////////////////////////////
|
|
//// ////
|
|
//// cavlc_read_total_coeffs ////
|
|
//// ////
|
|
//// Description ////
|
|
//// decode total_coeffs and trailing ones ////
|
|
//// ////
|
|
//// Author(s): ////
|
|
//// - bin qiu, qiubin@opencores.org ////
|
|
//// ////
|
|
//////////////////////////////////////////////////////////////////////
|
|
//// ////
|
|
//// Copyright (C) 2011 Authors and OPENCORES.ORG ////
|
|
//// ////
|
|
//// This source file may be used and distributed without ////
|
|
//// restriction provided that this copyright statement is not ////
|
|
//// removed from the file and that any derivative work contains ////
|
|
//// the original copyright notice and the associated disclaimer. ////
|
|
//// ////
|
|
//// This source file is free software; you can redistribute it ////
|
|
//// and/or modify it under the terms of the GNU Lesser General ////
|
|
//// Public License as published by the Free Software Foundation; ////
|
|
//// either version 2.1 of the License, or (at your option) any ////
|
|
//// later version. ////
|
|
//// ////
|
|
//// This source is distributed in the hope that it will be ////
|
|
//// useful, but WITHOUT ANY WARRANTY; without even the implied ////
|
|
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ////
|
|
//// PURPOSE. See the GNU Lesser General Public License for more ////
|
|
//// details. ////
|
|
//// ////
|
|
//// You should have received a copy of the GNU Lesser General ////
|
|
//// Public License along with this source; if not, download it ////
|
|
//// from http://www.opencores.org/lgpl.shtml ////
|
|
//// ////
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
//2011-8-7 initial creation
|
//2011-8-7 initial creation
|
//2011-8-9 optimize output mux
|
//2011-8-9 optimize output mux
|
//2011-9-10 reduce nC to 5 bits
|
|
|
|
|
|
`include "defines.v"
|
`include "defines.v"
|
|
|
module cavlc_read_total_coeffs(
|
module cavlc_read_total_coeffs
|
clk, rst_n,
|
(
|
|
clk,
|
|
rst_n,
|
ena,
|
ena,
|
|
|
start,
|
start,
|
sel,
|
sel,
|
rbsp, nC,
|
rbsp, nC,
|
|
TrailingOnes,
|
TrailingOnes, TotalCoeff,
|
TotalCoeff,
|
TrailingOnes_comb, TotalCoeff_comb,
|
TrailingOnes_comb,
|
|
TotalCoeff_comb,
|
len_comb
|
len_comb
|
);
|
);
|
//------------------------
|
//------------------------
|
//ports
|
//ports
|
//------------------------
|
//------------------------
|
input clk, rst_n;
|
input clk;
|
|
input rst_n;
|
input ena;
|
input ena;
|
|
|
input start;
|
input start;
|
input sel;
|
input sel;
|
|
|
|
|
input [0:15] rbsp;
|
input [0:15] rbsp;
|
input signed [4:0] nC;
|
input signed [5:0] nC;
|
|
|
output [4:0] TotalCoeff; //range from 0 to 16
|
output [4:0] TotalCoeff; //range from 0 to 16
|
output [1:0] TrailingOnes; //range from 0 to 3
|
output [1:0] TrailingOnes; //range from 0 to 3
|
output [4:0] TotalCoeff_comb; //unsaved result of TotalCoeff_comb
|
output [4:0] TotalCoeff_comb; //unsaved result of TotalCoeff_comb
|
output [1:0] TrailingOnes_comb; //unsaved result of TrailingOnes_comb
|
output [1:0] TrailingOnes_comb; //unsaved result of TrailingOnes_comb
|
Line 86... |
Line 123... |
reg [1:0] TrailingOnes;
|
reg [1:0] TrailingOnes;
|
|
|
//------------------------
|
//------------------------
|
//input mux
|
//input mux
|
//------------------------
|
//------------------------
|
wire rbsp_refresh = ena && start;
|
|
|
|
always @(posedge clk or negedge rst_n)
|
always @(posedge clk or negedge rst_n)
|
if (!rst_n)
|
if (!rst_n)
|
begin
|
begin
|
rbsp_1 <= 0;
|
rbsp_1 <= 0;
|
rbsp_2 <= 0;
|
rbsp_2 <= 0;
|
rbsp_3 <= 0;
|
rbsp_3 <= 0;
|
rbsp_4 <= 0;
|
rbsp_4 <= 0;
|
rbsp_5 <= 0;
|
rbsp_5 <= 0;
|
|
|
end
|
end
|
else if (rbsp_refresh)
|
else if (ena && start)
|
begin
|
begin
|
if (nC[4])
|
if (nC[5])
|
rbsp_5 <= rbsp[0:7];
|
rbsp_5 <= rbsp[0:7];
|
else if (nC[3])
|
else if ( nC[4] || nC[3])
|
rbsp_4 <= rbsp[0:5];
|
rbsp_4 <= rbsp[0:5];
|
else if (nC[2])
|
else if (nC[2])
|
rbsp_3 <= rbsp[0:9];
|
rbsp_3 <= rbsp[0:9];
|
else if (nC[1])
|
else if (nC[1])
|
rbsp_2 <= rbsp[0:13];
|
rbsp_2 <= rbsp[0:13];
|
Line 1015... |
Line 1050... |
TrailingOnes_3 <= 0;
|
TrailingOnes_3 <= 0;
|
TotalCoeff_3 <= 16;
|
TotalCoeff_3 <= 16;
|
end
|
end
|
endcase
|
endcase
|
|
|
//------------------ Colum 4 : nC >= 8---------------------
|
//------------------------
|
|
// nC > 8
|
|
//------------------------
|
always @(rbsp_4)
|
always @(rbsp_4)
|
begin
|
begin
|
len_4 <= 6;
|
len_4 <= 6;
|
if (rbsp_4[0:4] == 5'b00001) begin
|
if (rbsp_4[0:4] == 5'b00001) begin
|
TrailingOnes_4 <= 0;
|
TrailingOnes_4 <= 0;
|
Line 1119... |
Line 1156... |
if (nC == -1) begin
|
if (nC == -1) begin
|
TrailingOnes_comb <= TrailingOnes_5;
|
TrailingOnes_comb <= TrailingOnes_5;
|
TotalCoeff_comb <= TotalCoeff_5;
|
TotalCoeff_comb <= TotalCoeff_5;
|
len_comb <= len_5;
|
len_comb <= len_5;
|
end
|
end
|
else if (nC[3]) begin
|
else if (nC[4] | nC[3]) begin
|
TrailingOnes_comb <= TrailingOnes_4;
|
TrailingOnes_comb <= TrailingOnes_4;
|
TotalCoeff_comb <= TotalCoeff_4;
|
TotalCoeff_comb <= TotalCoeff_4;
|
len_comb <= len_4;
|
len_comb <= len_4;
|
end
|
end
|
else if (nC[2]) begin
|
else if (nC[2]) begin
|
Line 1140... |
Line 1177... |
TrailingOnes_comb <= TrailingOnes_1;
|
TrailingOnes_comb <= TrailingOnes_1;
|
TotalCoeff_comb <= TotalCoeff_1;
|
TotalCoeff_comb <= TotalCoeff_1;
|
len_comb <= len_1;
|
len_comb <= len_1;
|
end
|
end
|
end
|
end
|
|
|
//------------------------
|
//------------------------
|
//TrailingOnes & TotalCoeff
|
//TrailingOnes & TotalCoeff
|
//------------------------
|
//------------------------
|
wire output_refresh = ena && sel;
|
|
|
|
always @(posedge clk or negedge rst_n)
|
always @(posedge clk or negedge rst_n)
|
if (~rst_n) begin
|
if (!rst_n) begin
|
TrailingOnes <= 0;
|
TrailingOnes <= 0;
|
TotalCoeff <= 0;
|
TotalCoeff <= 0;
|
end
|
end
|
else if (output_refresh) begin
|
else if (ena && sel) begin
|
TrailingOnes <= TrailingOnes_comb;
|
TrailingOnes <= TrailingOnes_comb;
|
TotalCoeff <= TotalCoeff_comb;
|
TotalCoeff <= TotalCoeff_comb;
|
end
|
end
|
|
|
endmodule
|
endmodule
|