1 Star 0 Fork 6

风雉Zere/H.264_Decoder

forked from 黄锦伟/H.264_Decoder 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
Run_before_Decoder.v 10.98 KB
一键复制 编辑 原始数据 按行查看 历史
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 11:35:04 11/22/2013
// Design Name:
// Module Name: Run_before_Decoder
// Project Name:
// Target Devices:
// Tool versions:
// Description:
//
// Dependencies:
//
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
//
//////////////////////////////////////////////////////////////////////////////////
module run_before_decoder(
Code,//码字
Clk,//时钟信号
Rst,//复位信号
Sig_start,//触发信号
Sig_done,//模块完成信号
Sig_code_fill_done,//码字更新完成信号
Sig_code_fill,//码字长度不足,发送信号更新Code
TotalCoeff,//输入TotalCoeff值
TotalZero,//输入TotalZero值
RunBefore_code_length,//返回runbefore码字长度
Level_0,//按从高频到低频顺序输入level
Level_1,
Level_2,
Level_3,
Level_4,
Level_5,
Level_6,
Level_7,
Level_8,
Level_9,
Level_10,
Level_11,
Level_12,
Level_13,
Level_14,
Level_15,
Level_0_de,//输出解码后的4x4块值,从高频到低频。
Level_1_de,
Level_2_de,
Level_3_de,
Level_4_de,
Level_5_de,
Level_6_de,
Level_7_de,
Level_8_de,
Level_9_de,
Level_10_de,
Level_11_de,
Level_12_de,
Level_13_de,
Level_14_de,
Level_15_de,
//DEBUG
level_cnt_t,
CodeLength
//
);
parameter Level_Length = 16;
input Clk,Rst;
input Sig_start;
input Sig_code_fill_done;
input [63:0]Code;
input [4:0] TotalCoeff;
input [3:0] TotalZero;
input [Level_Length -1:0]Level_0;
input [Level_Length -1:0]Level_1;
input [Level_Length -1:0]Level_2;
input [Level_Length -1:0]Level_3;
input [Level_Length -1:0]Level_4;
input [Level_Length -1:0]Level_5;
input [Level_Length -1:0]Level_6;
input [Level_Length -1:0]Level_7;
input [Level_Length -1:0]Level_8;
input [Level_Length -1:0]Level_9;
input [Level_Length -1:0]Level_10;
input [Level_Length -1:0]Level_11;
input [Level_Length -1:0]Level_12;
input [Level_Length -1:0]Level_13;
input [Level_Length -1:0]Level_14;
input [Level_Length -1:0]Level_15;
output Sig_done;
output Sig_code_fill;
output [7:0]RunBefore_code_length;
output [Level_Length -1:0]Level_0_de;
output [Level_Length -1:0]Level_1_de;
output [Level_Length -1:0]Level_2_de;
output [Level_Length -1:0]Level_3_de;
output [Level_Length -1:0]Level_4_de;
output [Level_Length -1:0]Level_5_de;
output [Level_Length -1:0]Level_6_de;
output [Level_Length -1:0]Level_7_de;
output [Level_Length -1:0]Level_8_de;
output [Level_Length -1:0]Level_9_de;
output [Level_Length -1:0]Level_10_de;
output [Level_Length -1:0]Level_11_de;
output [Level_Length -1:0]Level_12_de;
output [Level_Length -1:0]Level_13_de;
output [Level_Length -1:0]Level_14_de;
output [Level_Length -1:0]Level_15_de;
//DEBUG
output [3:0] level_cnt_t;
output [3:0] CodeLength;
//
wire [Level_Length -1:0]Level_0_de;
wire [Level_Length -1:0]Level_1_de;
wire [Level_Length -1:0]Level_2_de;
wire [Level_Length -1:0]Level_3_de;
wire [Level_Length -1:0]Level_4_de;
wire [Level_Length -1:0]Level_5_de;
wire [Level_Length -1:0]Level_6_de;
wire [Level_Length -1:0]Level_7_de;
wire [Level_Length -1:0]Level_8_de;
wire [Level_Length -1:0]Level_9_de;
wire [Level_Length -1:0]Level_10_de;
wire [Level_Length -1:0]Level_11_de;
wire [Level_Length -1:0]Level_12_de;
wire [Level_Length -1:0]Level_13_de;
wire [Level_Length -1:0]Level_14_de;
wire [Level_Length -1:0]Level_15_de;
reg [63:0]Code_t;
reg [7:0] Bound;
reg Sig_code_fill;
wire [63:0] Code_spliced;
wire [63:0] Code;
reg Sig_done;
reg [7:0]RunBefore_code_length;
reg [2:0] cnt;
//reg [3:0] residue;//=TotalCoeff+TotalZero;
reg [3:0] level_cnt_t;
reg [3:0] ZerosLeft;
wire [3:0] RunBefore;
reg [3:0] RunBefore_t;
reg [Level_Length -1:0] Level_value;
//reg [3:0] Level_num;
reg Sig_level_write;
reg Sig_level_clr;
reg [4:0] TotalCoeff_t;
wire [3:0] CodeLength;
ZerosLeft_lut zerosLeft_lut (
.Code(Code_t[15:0]),
.ZerosLeft(ZerosLeft),
.RunBefore(RunBefore),
.CodeLength(CodeLength)
);
Level_Buffer level_Buffer (
.Clk(Clk),
.Rst(Rst),
.Sig_level_write(Sig_level_write),
.Sig_level_clr(Sig_level_clr),
.Level_num(level_cnt_t),
.Level_value(Level_value),
.Level_0(Level_0_de),
.Level_1(Level_1_de),
.Level_2(Level_2_de),
.Level_3(Level_3_de),
.Level_4(Level_4_de),
.Level_5(Level_5_de),
.Level_6(Level_6_de),
.Level_7(Level_7_de),
.Level_8(Level_8_de),
.Level_9(Level_9_de),
.Level_10(Level_10_de),
.Level_11(Level_11_de),
.Level_12(Level_12_de),
.Level_13(Level_13_de),
.Level_14(Level_14_de),
.Level_15(Level_15_de)
);
code_splice Code_splice_for_runbefore_decoder (
.Code_A(Code_t),
.Code_B(Code),
.Bound(Bound),
.Code_spliced(Code_spliced)
);
always @(posedge Clk or negedge Rst) begin
if(!Rst) begin
cnt <= 0;
Code_t <= 0;
RunBefore_code_length <=0;
Sig_done <= 0;
ZerosLeft <= 0;
level_cnt_t <= 0;
Sig_level_write <= 0;
TotalCoeff_t <= 0;
RunBefore_t <=0 ;
Sig_code_fill <= 0;
end
else begin
case(cnt)
0:begin
if(Sig_start) begin
/*
Level_0_de <= 0;
Level_1_de <= 0;
Level_2_de <= 0;
Level_3_de <= 0;
Level_4_de <= 0;
Level_5_de <= 0;
Level_6_de <= 0;
Level_7_de <= 0;
Level_8_de <= 0;
Level_9_de <= 0;
Level_10_de <= 0;
Level_11_de <= 0;
Level_12_de <= 0;
Level_13_de <= 0;
Level_14_de <= 0;
Level_15_de <= 0;*/
Code_t <= Code;
RunBefore_code_length <=0;
level_cnt_t <= 16-(TotalCoeff+TotalZero);
TotalCoeff_t <= 0;
RunBefore_t <= 0;
ZerosLeft <= TotalZero;
Sig_level_write <= 0;
Sig_level_clr <= 1;
Sig_done <= 0;
Sig_code_fill <= 0;
cnt <= 1;
end
else begin
Sig_level_clr <= 0;
Sig_level_write <= 0;
cnt<=0;
end
end
1:begin
//Level_num <= level_cnt;
Sig_level_write <= 1;
Sig_level_clr <= 0;
ZerosLeft <= ZerosLeft-RunBefore_t;
TotalCoeff_t <= TotalCoeff_t+1;
if(TotalCoeff_t==0)begin
level_cnt_t <= 16-(TotalCoeff+TotalZero);
end
else begin
level_cnt_t <= level_cnt_t+RunBefore_t+1;
end
cnt <= cnt + 1;
case(TotalCoeff_t)
0:begin
Level_value <= Level_0;
end
1:begin
Level_value <= Level_1;
end
2:begin
Level_value <= Level_2;
end
3:begin
Level_value <= Level_3;
end
4:begin
Level_value <= Level_4;
end
5:begin
Level_value <= Level_5;
end
6:begin
Level_value <= Level_6;
end
7:begin
Level_value <= Level_7;
end
8:begin
Level_value <= Level_8;
end
9:begin
Level_value <= Level_9;
end
10:begin
Level_value <= Level_10;
end
11:begin
Level_value <= Level_11;
end
12:begin
Level_value <= Level_12;
end
13:begin
Level_value <= Level_13;
end
14:begin
Level_value <= Level_14;
end
15:begin
Level_value <= Level_15;
end
endcase
end
2:begin
Sig_level_write <= 0;
if(ZerosLeft<=0) begin
RunBefore_code_length <= RunBefore_code_length;
RunBefore_t <= 0;
if(TotalCoeff_t==TotalCoeff) begin
cnt <= cnt+1;
Sig_done <= 1;
end
else begin
cnt <= 1;
end
end
else begin
Code_t <= Code_t>>CodeLength;
RunBefore_t <= RunBefore;
if(TotalCoeff_t==TotalCoeff) begin
cnt <= cnt+1;
Sig_done <= 1;
RunBefore_code_length <= RunBefore_code_length;
end
else begin
cnt <= 1;
RunBefore_code_length <= RunBefore_code_length+CodeLength;
if((RunBefore_code_length+CodeLength)<=53) begin //runbefore码字最长长度为11,53 = 64 - 11,
Bound <= (RunBefore_code_length+CodeLength);
end
else begin
Sig_code_fill <= 1;
cnt <= 3'd4;
end
end
end
end
3:begin
Sig_done <= 0;
cnt <= 0;
end
4:begin
Sig_code_fill <= 0;
if(Sig_code_fill_done==1'b1) begin
Code_t <= Code_spliced;
Bound <= 0;
cnt <= 1;
end
else begin
cnt <= 4;
end
end
default:begin
cnt <= 0;
end
endcase
end
end
endmodule
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Verilog
1
https://gitee.com/wind-pheasant-zere/H.264_Decoder.git
git@gitee.com:wind-pheasant-zere/H.264_Decoder.git
wind-pheasant-zere
H.264_Decoder
H.264_Decoder
master

搜索帮助