?? ctc_tx_fsm.v
字號:
///*********************************************************************
/// Copyright(c) 2006, ZTE.
/// All rights reserved.
///
/// Project name : ZXMBW-250(WIMAX)
/// File name : ctc_tx_fsm.v
/// Author : wangjinshan yuanliuqing
/// Department : 2nd IC department
/// Email : wang.jinshan1@zte.com.cn
///
/// Module_name : ctc_tx_fsm
/// Called by : ctc_decoder module
///---------------------------------------------------------------------
/// Module Hiberarchy:
/// ctc_tx_fsm-----|----ctc_tx_arb
///---------------------------------------------------------------------
///
/// Release History:
///---------------------------------------------------------------------
/// Version | Date | Author Description
///---------------------------------------------------------------------
/// 1.0-0 | 2006-06-10 | 建立文件
///---------------------------------------------------------------------
/// 1.1-0 | 2006-10-09 | 更改為3個譯碼核
///---------------------------------------------------------------------
// Main Function:
/// 1、CTC譯碼核輸出狀態(tài)機
///*********************************************************************
`timescale 1ns/100ps
module ctc_tx_fsm
(
///interface with ctc_fifo1
///input
input [31:0] ctc_fifo1_rddat, ///core1輸出FIFO數據線
input [8:0] ctc_fifo1_usedw, ///core1輸出FIFO空間使用
input ctc_fifo1_empty, ///core1輸出FIFO空信號
///output
output reg ctc_fifo1_rdreq, ///core1輸出FIFO讀信號
///interface with ctc_fifo2
///input
input [31:0] ctc_fifo2_rddat,
input [8:0] ctc_fifo2_usedw,
input ctc_fifo2_empty,
///output
output reg ctc_fifo2_rdreq,
///interface with ctc_fifo3
///input
input [31:0] ctc_fifo3_rddat,
input [8:0] ctc_fifo3_usedw,
input ctc_fifo3_empty,
///output
output reg ctc_fifo3_rdreq,
///interface with post_ctc_fifo
///input
input full_post_ctc_fifo, ///數據輸出FIFO滿信號
input empty_post_ctc_fifo, ///數據輸出FIFO空信號
input [8:0] wrusedword_post_ctc_fifo, ///數據輸出FIFO空間使用
///output
output reg wr_post_ctc_fifo, ///數據輸出FIFO寫信號
output reg eop_wr_post_ctc_fifo, ///數據輸出FIFO寫結束信號
output reg [31:0] dat_wr_post_ctc_fifo, ///數據輸出FIFO寫數據線
///system signals
input sys_clk, ///系統(tǒng)時鐘信號
input reset_b, ///輸入復位信號
output reg [15:0] tx_counter1_nc,
output reg [15:0] tx_counter2_nc,
output reg [15:0] tx_counter3_nc
);
///*********************************************************************
///local parameter define:(本地參數:)
///*********************************************************************
/// State codes definitions:
parameter IDLE = 10'b00_0000_0001; ///空閑
parameter RD_FIFO1 = 10'b00_0000_0010; ///讀core1的輸出FIFO
parameter WT1 = 10'b00_0000_0100; ///等待一個cycle
parameter WR_FIFO1 = 10'b00_0000_1000; ///寫FIFO
parameter RD_FIFO2 = 10'b00_0001_0000; ///讀core2的輸出FIFO
parameter WT2 = 10'b00_0010_0000; ///等待一個cycle
parameter WR_FIFO2 = 10'b00_0100_0000; ///寫FIFO
parameter RD_FIFO3 = 10'b00_1000_0000; ///讀core3的輸出FIFO
parameter WT3 = 10'b01_0000_0000; ///等待一個cycle
parameter WR_FIFO3 = 10'b10_0000_0000; ///寫FIFO
///*********************************************************************
///內部信號定義
///*********************************************************************
reg [9:0] st_current;
reg [9:0] st_next;
reg [15:0] r0_cnt;
reg [15:0] r1_cnt;
reg [15:0] r2_cnt;
reg [15:0] p_len;
///reg [15:0] r0_cnt_next;
///reg [15:0] r1_cnt_next;
///reg [15:0] r2_cnt_next;
///reg [15:0] p_len_next;
wire core1_gnt;
wire core2_gnt;
wire core3_gnt;
///*********************************************************************
///主程序代碼:
///*********************************************************************
always @(posedge sys_clk or negedge reset_b) begin
if(!reset_b)
tx_counter1_nc <= 1'b0;
else
begin
if(st_current==RD_FIFO1)
tx_counter1_nc <= tx_counter1_nc + 1'b1;
else
tx_counter1_nc <= tx_counter1_nc;
end
end
always @(posedge sys_clk or negedge reset_b) begin
if(!reset_b)
tx_counter2_nc <= 1'b0;
else
begin
if(st_current==RD_FIFO2)
tx_counter2_nc <= tx_counter2_nc + 1'b1;
else
tx_counter2_nc <= tx_counter2_nc;
end
end
always @(posedge sys_clk or negedge reset_b) begin
if(!reset_b)
tx_counter3_nc <= 1'b0;
else
begin
if(st_current==RD_FIFO3)
tx_counter3_nc <= tx_counter3_nc + 1'b1;
else
tx_counter3_nc <= tx_counter3_nc;
end
end
///*********************************************************************
/// Current State Logic (sequential)
/// state_intialization
always @(posedge sys_clk or negedge reset_b)
if (~reset_b)
st_current <= IDLE;
else
st_current <= st_next;
// state machine
always @(*) begin
st_next = st_current;
case(st_current)
IDLE:
if(core1_gnt)
st_next = RD_FIFO1;
else if(core2_gnt)
st_next = RD_FIFO2;
else if(core3_gnt)
st_next = RD_FIFO3;
else
st_next = IDLE;
RD_FIFO1: st_next = WT1;
WT1:
if(ctc_fifo1_usedw >= (p_len[8:0]-1'b1))
st_next = WR_FIFO1;
else
st_next = WT1;
WR_FIFO1:
if(r0_cnt<p_len)
st_next = WR_FIFO1;
else
st_next = IDLE;
RD_FIFO2:
st_next = WT2;
WT2:
if(ctc_fifo2_usedw >= (p_len[8:0]-1'b1))
st_next = WR_FIFO2;
else
st_next = WT2;
WR_FIFO2:
if(r1_cnt<p_len)
st_next = WR_FIFO2;
else
st_next = IDLE;
RD_FIFO3:
st_next = WT3;
WT3:
if(ctc_fifo3_usedw >= (p_len[8:0]-1'b1))
st_next = WR_FIFO3;
else
st_next = WT3;
WR_FIFO3:
if(r2_cnt<p_len)
st_next = WR_FIFO3;
else
st_next = IDLE;
default: st_next = IDLE;
endcase
end //state machine
///**************************************************************************
///生成計數器r0_cnt,r1_cnt,r2_cnt及包長plen
///將if_else結構改成case結構
///Fang.yongzhong
///**************************************************************************
/*
always @(posedge sys_clk or negedge reset_b) begin
if (~reset_b) begin
r0_cnt <= 16'b0;
r1_cnt <= 16'b0;
r2_cnt <= 16'b0;
p_len <= 16'b0;
end
else begin
r0_cnt <= r0_cnt_next;
r1_cnt <= r1_cnt_next;
r2_cnt <= r2_cnt_next;
p_len <= p_len_next;
end
end
always @(*) begin
case(st_current)
RD_FIFO1:
r0_cnt_next = 16'b0;
WR_FIFO1:
r0_cnt_next = r0_cnt + 1'b1;
RD_FIFO2:
r1_cnt_next = 16'b0;
WR_FIFO2:
r1_cnt_next = r1_cnt + 1'b1;
RD_FIFO3:
r2_cnt_next = 16'b0;
WR_FIFO3:
r2_cnt_next = r2_cnt + 1'b1;
WT1:
if(~|ctc_fifo1_rddat[1:0])
p_len_next = (ctc_fifo1_rddat[15:0]>>2) + 16'h2;
else
p_len_next = (ctc_fifo1_rddat[15:0]>>2) + 16'h3;
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -