?? ctc_mctrl.v
字號:
///*********************************************************************/// Copyright(c) 2006, ZTE./// All rights reserved.////// Project name : ZXMBW-250(WIMAX)/// File name : ctc_mctrl.v/// Author : wangjinshan/// Department : 2nd IC department/// Email : wang.jinshan1@zte.com.cn////// Module_name : ctc_mctrl/// Called by : ctc_decoder_core module///---------------------------------------------------------------------/// Module Hiberarchy:/// |----le_ram_u1/// ctc_mctrl-----|----le_ram_u2///---------------------------------------------------------------------////// Release History:///---------------------------------------------------------------------/// Version | Date | Author Description///---------------------------------------------------------------------/// 1.0-0 | 2006-05-08 | 建立文件///---------------------------------------------------------------------/// Main Function:/// 1、CTC譯碼核數主控模塊///*********************************************************************`timescale 1ns/100psmodule ctc_mctrl ( ///interface with ctc_rx_fsm ///input input core_gnt, ///應答信號 input wr_over, ///寫dpram結束信號 input [15:0] rx2ctrl_length, ///FEC譯碼塊的長度 input [2:0] rx2ctrl_type, ///類型號 input [2:0] rx2ctrl_frame_end_flag, input [1:0] rx2ctrl_inst, ///instance input [2:0] rx2ctrl_code_rate, ///碼率 000:HARQ 001:1/2 010:2/3 011:3/4 input [1:0] rx2ctrl_modu_type, ///00為QPSK,01為16QAM,10為64QAM input [15:0] rx2ctrl_bnum, ///突發號 input [7:0] rx2ctrl_fnum, ///FEC號 input [3:0] rx2ctrl_miter, ///最大迭代次數 input [3:0] rx2ctrl_segId, ///segment號 ///output output reg dec_finish, ///單譯碼塊譯碼結束標記 output reg core_req, ///請求信號 ///interface with ctc_dpram_1 ///input input [11:0] dpram1_rddat, ///雙口RAM的讀數據 ///output output reg [11:0] dpram1_rdadr, ///存放譯碼數據的雙口RAM地址 output reg dpram1_rd, ///雙口RAM地址的讀信號 ///interface with ctc_dpram_2 ///input input [23:0] dpram2_rddat, ///雙口RAM的讀數據 ///output output reg [11:0] dpram2_rdadr, ///存放譯碼數據的雙口RAM地址 output reg dpram2_rd, ///雙口RAM地址的讀信號 ///interface with ctc_map ///input input [23:0] le, ///外部信息輸入 input sop_sink, ///輸入包開始信號 input eop_sink, ///輸入包結束信號 input val_sink, ///輸入數據有效信號 ///output output reg [23:0] la, ///輸出先驗信息 output reg [11:0] ys, ///輸出信息比特軟信息 output reg [11:0] yp, ///輸出校驗比特軟信息 output reg sop_source, ///輸出包開始信號 output reg eop_source, ///輸出包結束信號 output reg val_source, ///輸出數據有效信號 ///同交織解交織地址生成模塊接口 ///input input [11:0] dat_addr, ///地址索引RAM輸出數據 ///LLR交織地址索引RAM與譯碼數據交織地址索引RAM共用一塊 input [11:0] llrde_addr, ///解交織地址索引RAM輸出數據 ///output output reg mctrl2dat_en, ///使能信號 output reg [11:0] mctrl2dat_addr, ///地址索引RAM讀地址 output reg mctrl2dat_rd, ///地址索引RAM讀信號 output reg [11:0] mctrl2llrde_addr, ///解交織地址索引RAM讀地址 output reg mctrl2llrde_rd, ///解交織地址索引RAM讀信號 ///interface with resm ///input input dec_end, ///譯碼結束信號 ///output output reg [3:0] dec_no, ///迭代次數 output reg [15:0] ctrl2resm_length, ///FEC譯碼塊的長度 output reg [2:0] ctrl2resm_type, ///類型號 output reg [2:0] ctrl2resm_frame_end_flag, output reg [1:0] ctrl2resm_inst, ///instance output reg [2:0] ctrl2resm_code_rate, ///碼率 000:HARQ 001:1/2 010:2/3 011:3/4 output reg [1:0] ctrl2resm_modu_type, ///00為QPSK,01為16QAM,10為64QAM output reg [15:0] ctrl2resm_bnum, ///突發號 output reg [7:0] ctrl2resm_fnum, ///FEC號 output reg [3:0] ctrl2resm_miter, ///最大迭代次數 output reg [3:0] ctrl2resm_segId, ///segment號 ///system signals input sys_clk, ///系統時鐘信號 input reset_b ///輸入復位信號 );///*********************************************************************///local parameter define:(本地參數:)///*********************************************************************parameter WIN_SIZE = 6'd32; ///譯碼活動窗大小/// State codes definitions:parameter IDLE = 6'b00_0001;parameter WAIT = 6'b00_0010;parameter RD = 6'b00_0100;parameter EOP = 6'b00_1000;parameter DEC_ED = 6'b01_0000;parameter DEC_AD = 6'b10_0000;///*********************************************************************///內部信號定義///*********************************************************************reg [5:0] st_current; ///當前狀態reg [5:0] st_next; ///下一狀態reg [13:0] fec_cnt; ///FEC塊長度計數器reg [5:0] fwin_cnt; ///FEC塊長度計數器reg [5:0] win_cnt; ///滑動窗計數器reg [2:0] cnt; ///計數器reg [15:0] length_1; ///FEC譯碼塊的長度///*********************************************************************///主程序代碼:///*********************************************************************/// Current State Logic (sequential)/// state_intialization///**************************************************************************// Current State Logic (sequential)// state_intialization///**************************************************************************always @(posedge sys_clk or negedge reset_b) begin if (~reset_b) st_current <= IDLE; else st_current <= st_next;endalways @(*) begin st_next = st_current; case(st_current) IDLE: if(core_gnt) st_next = WAIT; else st_next = IDLE; WAIT: if(wr_over) st_next = RD; else st_next = WAIT; RD: if(win_cnt < WIN_SIZE) st_next = RD; else st_next = EOP; EOP: if(eop_sink) st_next = DEC_ED; else st_next = EOP; DEC_ED: if(cnt>=3'd5) st_next = DEC_AD; else st_next = DEC_ED; DEC_AD: if(dec_end | (dec_no>=ctrl2resm_miter)) st_next = IDLE; else st_next = RD; default: st_next = IDLE; endcaseend///**************************************************************************///延遲四個時鐘為了接收dec_endalways @(negedge reset_b or posedge sys_clk) begin if(!reset_b) cnt <= 1'b0; else if(st_next==DEC_ED) cnt <= cnt + 1'b1; else cnt <= 1'b0;end///**************************************************************************///請求信號always @(negedge reset_b or posedge sys_clk) begin if(!reset_b) core_req <= 1'b0; else if((st_current == IDLE && dec_finish) || (st_current == IDLE && (~|dec_no))) //fyz修改 core_req <= 1'b1; else if(core_gnt) core_req <= 1'b0;end///計數器處理reg [13:0] p_len; ///滑動窗計數器always @(negedge reset_b or posedge sys_clk) begin if(!reset_b) begin p_len <= 14'b0; end else begin case(ctrl2resm_length) 14'd24: begin p_len <= ctrl2resm_length[13:0] + 14'd8; end 14'd48: begin p_len <= ctrl2resm_length[13:0] + 14'd16; end 14'd72: begin p_len <= ctrl2resm_length[13:0] + 14'd24; end 14'd120: begin p_len <= ctrl2resm_length[13:0] + 14'd8; end 14'd144: begin p_len <= ctrl2resm_length[13:0] + 14'd16; end 14'd216: begin p_len <= ctrl2resm_length[13:0] + 14'd8; end 14'd240: begin p_len <= ctrl2resm_length[13:0] + 14'd16; end 14'd36: begin p_len <= ctrl2resm_length[13:0] + 14'd28; end 14'd108: begin p_len <= ctrl2resm_length[13:0] + 14'd20; end 14'd180: begin p_len <= ctrl2resm_length[13:0] + 14'd12; end default: begin p_len <= ctrl2resm_length[13:0]; end endcase endend///**************************************************************************///fwin_cnt、fec_cnt、win_cnt計數器//////**************************************************************************always @(negedge reset_b or posedge sys_clk) begin if(!reset_b) begin fwin_cnt <= 6'b0; fec_cnt <= 14'b0; win_cnt <= 6'b0; end else case(st_current) DEC_AD: begin fwin_cnt <= 6'b0; fec_cnt <= 14'b0; win_cnt <= 6'b0; end RD: begin if(fwin_cnt<WIN_SIZE) fwin_cnt <= fwin_cnt + 1'b1; else if((fwin_cnt==WIN_SIZE) & (fec_cnt<p_len)) fec_cnt <= fec_cnt + 1'b1; else if((fec_cnt==p_len) & (win_cnt<WIN_SIZE)) win_cnt <= win_cnt + 1'b1; else begin fwin_cnt <= fwin_cnt; fec_cnt <= fec_cnt; win_cnt <= win_cnt; end end default: begin fwin_cnt <= fwin_cnt; fec_cnt <= fec_cnt; win_cnt <= win_cnt; end endcaseend///**************************************************************************///迭代次數計算///**************************************************************************always @(negedge reset_b or posedge sys_clk) begin if(!reset_b) dec_no <= 4'b0; else if(st_current==IDLE) dec_no <= 4'b0;
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -