Home » Source Code » H264 Verilog » run_decoding.v

run_decoding.v ( File view )

From:H264 Verilog
  • By culourwq 2016-05-23
  • View(s):0
  • Download(s):2
  • Point(s): 1
			//--------------------------------------------------------------------------------------------------
// Design    : nova
// Author(s) : Ke Xu
// Email	   : eexuke@yahoo.com
// File      : run_decoding.v
// Generated : June 11, 2005
// Copyright (C) 2008 Ke Xu                
//-------------------------------------------------------------------------------------------------
// Description 
// Decoding the all the remaining syntax for CAVLC
//-------------------------------------------------------------------------------------------------

// synopsys translate_off
`include "timescale.v"
// synopsys translate_on
`include "nova_defines.v"

module run_decoding (clk,reset_n,cavlc_decoder_state,BitStream_buffer_output,total_zeros,
	level_0,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,
	TotalCoeff,i_run,i_TotalCoeff,coeffNum,IsRunLoop,
	
	run_of_zeros_len,zerosLeft,run,
	coeffLevel_0,coeffLevel_1,coeffLevel_2, coeffLevel_3, coeffLevel_4, coeffLevel_5, coeffLevel_6, coeffLevel_7,
	coeffLevel_8,coeffLevel_9,coeffLevel_10,coeffLevel_11,coeffLevel_12,coeffLevel_13,coeffLevel_14,coeffLevel_15);
	input clk,reset_n;
	input [3:0] cavlc_decoder_state;
	input [15:0] BitStream_buffer_output;
	input [3:0] total_zeros;
	input [8:0] level_0,level_1,level_2,level_3,level_4,level_5,level_6,level_7;
	input [8:0] level_8,level_9,level_10,level_11,level_12,level_13,level_14,level_15;
	input [4:0] TotalCoeff;
	input [3:0] i_run;
	input [3:0] i_TotalCoeff;
	input [3:0] coeffNum;
	input IsRunLoop;
	output [3:0] run_of_zeros_len;
	output [3:0] zerosLeft;
	output [3:0] run;
	output [8:0] coeffLevel_0, coeffLevel_1, coeffLevel_2,coeffLevel_3, coeffLevel_4, coeffLevel_5, coeffLevel_6;
	output [8:0] coeffLevel_7, coeffLevel_8, coeffLevel_9,coeffLevel_10,coeffLevel_11,coeffLevel_12,coeffLevel_13;
	output [8:0] coeffLevel_14,coeffLevel_15;
	
	reg [3:0] run_of_zeros_len;
	reg [3:0] zerosLeft;
	reg [3:0] run;
	reg [8:0] coeffLevel_0, coeffLevel_1, coeffLevel_2,coeffLevel_3, coeffLevel_4, coeffLevel_5, coeffLevel_6;
	reg [8:0] coeffLevel_7, coeffLevel_8, coeffLevel_9,coeffLevel_10,coeffLevel_11,coeffLevel_12,coeffLevel_13;
	reg [8:0] coeffLevel_14,coeffLevel_15;
	
	reg [3:0] run_before;
	reg [3:0] zerosLeft_reg;
	reg [3:0] run_0,run_1,run_2,run_3,run_4,run_5,run_6,run_7;
	reg [3:0] run_8,run_9,run_10,run_11,run_12,run_13,run_14,run_15;
	reg [8:0] level_output;
	
	//decoding Table 9-10
	always @ (cavlc_decoder_state or zerosLeft or BitStream_buffer_output) 
		if (cavlc_decoder_state == `run_before_LUT)
			case (zerosLeft)
				0:run_of_zeros_len <= 0;//special case added for "total_zeros==0"
				1:run_of_zeros_len <= 1;
				2:run_of_zeros_len <= (BitStream_buffer_output[15] == 1)? 4'd1:4'd2;
				3:run_of_zeros_len <= 2;
				4:run_of_zeros_len <= (BitStream_buffer_output[15:14] == 2'b00)? 4'd3:4'd2;
				5:run_of_zeros_len <= (BitStream_buffer_output[15] == 1)? 4'd2:4'd3;
				6:run_of_zeros_len <= (BitStream_buffer_output[15:14] == 2'b11)? 4'd2:4'd3;
				default:
				if (BitStream_buffer_output[15] == 1 || BitStream_buffer_output[14] == 1 || BitStream_buffer_output[13] == 1)			
                                                      run_of_zeros_len <= 3;
				else if (BitStream_buffer_output[15:12] == 1)	run_of_zeros_len <= 4;
				else if (BitStream_buffer_output[15:11] == 1)	run_of_zeros_len <= 5;
				else if (BitStream_buffer_output[15:10] == 1)	run_of_zeros_len <= 6;
				else if (BitStream_buffer_output[15:9]  == 1)	run_of_zeros_len <= 7;
				else if (BitStream_buffer_output[15:8]  == 1)	run_of_zeros_len <= 4'd8;
				else if (BitStream_buffer_output[15:7]  == 1)	run_of_zeros_len <= 4'd9;
				else if (BitStream_buffer_output[15:6]  == 1)	run_of_zeros_len <= 4'd10;
				else if (BitStream_buffer_output[15:5]  == 1)	run_of_zeros_len <= 4'd11;
				else                                          run_of_zeros_len <= 0;
			endcase
		else
			run_of_zeros_len <= 0; 
			
	always @ (posedge clk)
		if (reset_n == 0)
			run_before <= 0;
		else if (cavlc_decoder_state == `run_before_LUT)
			case (zerosLeft)
				0:run_before <= 0;//special case added for "total_zeros==0"
				1:run_before <= (BitStream_buffer_output[15] == 0)? 4'd1:4'd0;
				2:if      (BitStream_buffer_output[15] == 1)        run_before <= 0;					
				  else if (BitStream_buffer_output[15:14] == 2'b01)	run_before <= 1;
				  else                                              run_before <= 2;	
				3:case (BitStream_buffer_output[15:14])
					2'b00:run_before <= 3;
					2'b01:run_before <= 2;
					2'b10:run_before <= 1;
					2'b11:run_before <= 0;
				  endcase
				4:case (BitStream_buffer_output[15:14])
					2'b00:run_before <= (BitStream_buffer_output[13] == 1)? 4'd3:4'd4;
					2'b01:run_before <= 2;
					2'b10:run_before <= 1;
					2'b11:run_before <= 0;
				  endcase
				5:case (BitStream_buffer_output[15:14])
					2'b00:run_before <= (BitStream_buffer_output[13] == 1)? 4'd4:4'd5;
					2'b01:run_before <= (BitStream_buffer_output[13] == 1)? 4'd2:4'd3;
					2'b10:run_before <= 1;
					2'b11:run_before <= 0;
				  endcase
				6:casex (BitStream_buffer_output[15:13])
					3'b11x:run_before <= 0;
					3'b000:run_before <= 1;
					3'b001:run_before <= 2;
					3'b011:run_before <= 3;
					3'b010:run_before <= 4;
					3'b101:run_before <= 5;
					3'b100:run_before <= 6;
				  endcase
				default:
				case (BitStream_buffer_output[15:13])
					3'b000:run_before <= run_of_zeros_len + 3;
					3'b111:run_before <= 0;
					3'b110:run_before <= 1;
					3'b101:run_before <= 2;
					3'b100:run_before <= 3;
					3'b011:run_before <= 4;
					3'b010:run_before <= 5;
					3'b001:run_before <= 6;
				endcase
			endcase
			
	always @ (cavlc_decoder_state or total_zeros or run_before or zerosLeft_reg or IsRunLoop)
		if (cavlc_decoder_state == `run_before_LUT)
			zerosLeft <= (IsRunLoop == 0)? total_zeros:zerosLeft_reg; 
		else if (cavlc_decoder_state == `RunOfZeros)
			zerosLeft <= zerosLeft_reg - run_before;
		else 
			zerosLeft <= 0;
			
	always @ (posedge clk)
		if (reset_n == 0)
			zerosLeft_reg <= 0;
		else if (cavlc_decoder_state == `run_before_LUT || cavlc_decoder_state == `RunOfZeros)
			zerosLeft_reg <= zerosLeft;
	
	always @ (posedge clk)
		if (reset_n == 0)
			begin
				run_0  <= 0;	run_1  <= 0;	run_2  <= 0;	run_3  <= 0;	
				run_4  <= 0;	run_5  <= 0;	run_6  <= 0;	run_7  <= 0;
				run_8  <= 0;	run_9  <= 0;	run_10 <= 0;	run_11 <= 0;
				run_12 <= 0;	run_13 <= 0;	run_14 <= 0;	run_15 <= 0;
			end
		//reset run0 ~ run15 for each 4x4 CAVLC as early as nAnB_decoding_s stage
		else if (cavlc_decoder_state == `nAnB_decoding_s)
		   begin
				run_0  <= 0;	run_1  <= 0;	run_2  <= 0;	run_3  <= 0;	
				run_4  <= 0;	run_5  <= 0;	run_6  <= 0;	run_7  <= 0;
				run_8  <= 0;	run_9  <= 0;	run_10 <= 0;	run_11 <= 0;
				run_12 <= 0;	run_13 <= 0;	run_14 <= 0;	run_15 <= 0;
			end
		else if (cavlc_decoder_state == `RunOfZeros)
			begin
				if (TotalCoeff == 1)
					run_0 <= total_zeros;
				else if (total_zeros == 0)
					begin
						run_0  <= 0;	run_1  <= 0;	run_2  <= 0;	run_3  <= 0;	
						run_4  <= 0;	run_5  <= 0;	run_6  <= 0;	run_7  <= 0;
						run_8  <= 0;	run_9  <= 0;	run_10 <= 0;	run_11 <= 0;
						run_12 <= 0;	run_13 <= 0;	run_14 <= 0;	run_15 <= 0;
					end
				else if ({
1'b0,i_run
} == TotalCoeff - 2)
					case (i_run)
						0 :begin	run_0 <= run_before;	run_1 <= zerosLeft;	end
						1 :begin	run_1 <= run_before;	run_2 <= zerosLeft;	end
						2 :begin	run_2 <= run_before;	run_3 <= zerosLeft;	end
						3 :begin	run_3 <= run_before;	run_4 <= zerosLeft;	end
						4 :begin	run_4 <= run_before;	run_5 <= zerosLeft;	end
						5 :begin	run_5 <= run_before;	run_6 <= zerosLeft;	end
						6 :begin	run_6 <= run_before;	run_7 <= zerosLeft;	end
						7 :begin	run_7 <= run_before;	run_8 <= zerosLeft;	end
						8 :begin	run_8 <= run_before;	run_9 <= zerosLeft;	end
						9 :begin	run_9 <= run_before;	run_10<= zerosLeft;	end
			
...
...
(Please download the complete source code to view)
			
...
Expand> <Close

Want complete source code? Download it here

Point(s): 1

Download
0 lines left, continue to read
Sponsored links

File list

Tips: You can preview the content of files by clicking file names^_^
Name Size Date
Beha_BitStream_ram.v1.16 kB30-04-08|11:58
BitStream_buffer.v11.65 kB30-04-08|11:58
BitStream_controller.v25.60 kB30-04-08|11:58
bitstream_gclk_gen.v12.67 kB30-04-08|11:58
BitStream_parser_FSM_gating.v27.58 kB30-04-08|11:58
bs_decoding.v45.34 kB30-04-08|11:58
cavlc_consumed_bits_decoding.v1.85 kB30-04-08|11:58
cavlc_decoder.v10.33 kB30-04-08|11:58
CodedBlockPattern_decoding.v5.83 kB30-04-08|11:58
dependent_variable_decoding.v2.42 kB30-04-08|11:58
DF_mem_ctrl.v29.69 kB30-04-08|11:58
DF_pipeline.v33.65 kB30-04-08|11:58
DF_reg_ctrl.v15.94 kB30-04-08|11:58
DF_top.v7.41 kB30-04-08|11:58
end_of_blk_decoding.v2.82 kB30-04-08|11:58
exp_golomb_decoding.v6.17 kB30-04-08|11:58
ext_frame_RAM0_wrapper.v5.09 kB30-04-08|11:58
ext_frame_RAM1_wrapper.v5.10 kB30-04-08|11:58
ext_RAM_ctrl.v3.46 kB30-04-08|11:58
H.264.cr.mti2.20 kB28-02-09|13:54
H.264.mpf55.79 kB28-02-09|00:05
heading_one_detector.v2.51 kB30-04-08|11:58
hybrid_pipeline_ctrl.v10.79 kB30-04-08|11:58
Inter_mv_decoding.v93.25 kB30-04-08|11:58
Inter_pred_CPE.v3.74 kB30-04-08|11:58
Inter_pred_LPE.v23.87 kB30-04-08|11:58
Inter_pred_pipeline.v33.29 kB30-04-08|11:58
Inter_pred_reg_ctrl.v124.27 kB30-04-08|11:58
Inter_pred_sliding_window.v130.18 kB30-04-08|11:58
Inter_pred_top.v28.66 kB30-04-08|11:58
Intra4x4_PredMode_decoding.v14.99 kB30-04-08|11:58
Intra_pred_PE.v69.16 kB30-04-08|11:58
Intra_pred_pipeline.v32.46 kB24-02-09|22:46
Intra_pred_reg_ctrl.v36.37 kB30-04-08|11:58
Intra_pred_top.v14.40 kB30-04-08|11:58
IQIT.v32.48 kB30-04-08|11:58
level_decoding.v7.45 kB30-04-08|11:58
nC_decoding.v30.47 kB30-04-08|11:58
nova.v8.19 kB30-04-08|11:58
nova_defines.v12.10 kB30-04-08|11:58
nova_tb.v2.92 kB30-04-08|11:58
NumCoeffTrailingOnes_decoding.v25.79 kB30-04-08|11:58
pc_decoding.v10.34 kB30-04-08|11:58
QP_decoding.v2.31 kB30-04-08|11:58
ram_async_1r_sync_1w.v2.71 kB30-04-08|11:58
ram_sync_1r_sync_1w.v3.01 kB30-04-08|11:58
reconstruction.v22.49 kB30-04-08|11:58
rec_DF_RAM0_96x32.v18.23 kB30-04-08|11:58
rec_DF_RAM0_wrapper.v1.73 kB30-04-08|11:58
rec_DF_RAM1_96x32.v18.23 kB30-04-08|11:58
rec_DF_RAM1_wrapper.v1.73 kB30-04-08|11:58
rec_DF_RAM_ctrl.v6.42 kB30-04-08|11:58
rec_gclk_gen.v16.68 kB30-04-08|11:58
Intra_pred_PE.areasrr10.14 kB22-02-09|14:06
Intra_pred_PE.edn2.76 MB22-02-09|14:06
Intra_pred_PE.fse0.00 B22-02-09|14:06
Intra_pred_PE.sdf2.05 MB22-02-09|14:06
Intra_pred_PE.srd1.03 MB22-02-09|14:06
Intra_pred_PE.srm1.61 MB22-02-09|14:06
Intra_pred_PE.srr34.82 kB22-02-09|14:06
Intra_pred_PE.srs102.69 kB22-02-09|14:06
Intra_pred_PE.tlg418.00 B22-02-09|14:06
Intra_pred_PE_sdc.sdc310.00 B22-02-09|14:06
Intra_pred_PE.msg0.00 B22-02-09|14:46
Intra_pred_PE.plg441.00 B22-02-09|14:06
run_decoding.v11.61 kB30-04-08|11:58
sum.v23.78 kB30-04-08|11:58
syntax_decoding.v24.94 kB30-04-08|11:58
timescale.v546.00 B30-04-08|11:58
total_zeros_decoding.v14.96 kB30-04-08|11:58
vsim.wlf32.00 kB24-02-09|16:06
_primary.dat73.20 kB24-02-09|15:26
_primary.vhd11.00 kB24-02-09|15:26
verilog.asm49.59 kB21-02-09|17:50
_primary.dat7.28 kB21-02-09|17:50
_primary.vhd1.23 kB21-02-09|17:50
verilog.asm275.78 kB24-02-09|15:27
_primary.dat39.36 kB24-02-09|15:27
_primary.vhd4.99 kB24-02-09|15:27
_primary.dat15.08 kB26-02-09|11:49
_primary.vhd3.73 kB26-02-09|11:49
_primary.dat17.38 kB26-02-09|11:49
_primary.vhd4.65 kB26-02-09|11:49
verilog.asm61.01 kB22-02-09|21:56
_primary.dat8.81 kB19-02-09|20:59
_primary.vhd3.04 kB22-02-09|21:56
verilog.asm15.53 kB24-02-09|15:27
_primary.dat1.24 kB24-02-09|15:27
_primary.vhd902.00 B24-02-09|15:27
_primary.dat986.00 B26-02-09|11:49
_primary.vhd419.00 B26-02-09|11:49
_primary.dat1.40 kB26-02-09|11:49
_primary.vhd749.00 B26-02-09|11:49
_primary.dat328.00 B26-02-09|11:49
_primary.vhd307.00 B26-02-09|11:49
_primary.dat687.00 B26-02-09|11:49
_primary.vhd291.00 B26-02-09|11:49
_primary.dat1.73 kB26-02-09|11:24
_primary.vhd585.00 B26-02-09|11:24
_info2.66 kB26-02-09|11:49
syntmp0.00 B22-02-09|14:46
@inter_pred_reg_ctrl0.00 B24-02-09|15:26
@intra4x4_@pred@mode_decoding0.00 B21-02-09|17:50
@intra_pred_@p@e0.00 B24-02-09|15:27
@intra_pred_pipeline0.00 B26-02-09|11:49
@intra_pred_reg_ctrl0.00 B26-02-09|11:49
@intra_pred_top0.00 B22-02-09|21:56
@p@e0.00 B24-02-09|15:27
main_seed_precomputation0.00 B26-02-09|11:49
plane_@h@v_precomputation0.00 B26-02-09|11:49
plane_a_precomputation0.00 B26-02-09|11:49
plane_bc_precomputation0.00 B26-02-09|11:49
ram_sync_1r_sync_1w0.00 B26-02-09|11:24
_temp0.00 B26-02-09|11:49
rev_10.00 B22-02-09|14:06
work0.00 B26-02-09|11:49
H.2640.00 B08-03-09|19:18
...
Sponsored links

run_decoding.v (808.37 kB)

Need 1 point
Your Point(s)

Your Point isn't enough.

Get point immediately by PayPal

More(Debit card / Credit card / PayPal Credit / Online Banking)

Submit your source codes. Get more point

LOGIN

Don't have an account? Register now
Need any help?
Mail to: support@codeforge.com

切换到中文版?

CodeForge Chinese Version
CodeForge English Version

Where are you going?

^_^"Oops ...

Sorry!This guy is mysterious, its blog hasn't been opened, try another, please!
OK

Warm tip!

CodeForge to FavoriteFavorite by Ctrl+D