Line 56... |
Line 56... |
output reg ready_tx_data,
|
output reg ready_tx_data,
|
output reg ready_tx_timecode
|
output reg ready_tx_timecode
|
|
|
);
|
);
|
|
|
localparam [2:0] tx_spw_start = 3'b000,
|
localparam [6:0] tx_spw_start = 7'b0000000,
|
tx_spw_null = 3'b001,
|
tx_spw_null = 7'b0000001,
|
tx_spw_null_fct = 3'b010,
|
tx_spw_fct = 7'b0000010,
|
tx_spw_full = 3'b100;
|
tx_spw_null_c = 7'b0000100,
|
|
tx_spw_fct_c = 7'b0001000,
|
|
tx_spw_data_c = 7'b0010000,
|
|
tx_spw_time_code_c = 7'b0100000;
|
|
|
localparam [5:0] NULL = 6'b000001,
|
localparam [5:0] NULL = 6'b000001,
|
FCT = 6'b000010,
|
FCT = 6'b000010,
|
EOP = 6'b000100,
|
EOP = 6'b000100,
|
EEP = 6'b001000,
|
EEP = 6'b001000,
|
Line 77... |
Line 80... |
localparam [3:0] eep_s = 4'b0110;
|
localparam [3:0] eep_s = 4'b0110;
|
localparam [13:0] timecode_ss = 14'b01110000000000;
|
localparam [13:0] timecode_ss = 14'b01110000000000;
|
|
|
|
|
|
|
reg [2:0] state_tx;
|
reg [6:0] state_tx;
|
reg [2:0] next_state_tx;
|
reg [6:0] next_state_tx;
|
|
|
|
reg [2:0] state_fct_send;
|
|
reg [2:0] next_state_fct_send;
|
|
|
|
reg [2:0] state_fct_receive;
|
|
reg [2:0] next_state_fct_receive;
|
|
|
reg [13:0] timecode_s;
|
reg [13:0] timecode_s;
|
|
|
reg [5:0] last_type;
|
reg [5:0] last_type;
|
reg [8:0] txdata_flagctrl_tx_last;
|
reg [8:0] txdata_flagctrl_tx_last;
|
Line 90... |
Line 99... |
reg data_rdy_trnsp;
|
reg data_rdy_trnsp;
|
reg [7:0] last_timein_control_flag_tx;
|
reg [7:0] last_timein_control_flag_tx;
|
reg [7:0] tx_tcode_in;
|
reg [7:0] tx_tcode_in;
|
reg tcode_rdy_trnsp;
|
reg tcode_rdy_trnsp;
|
|
|
reg hold_null;
|
|
reg hold_fct;
|
|
reg hold_data;
|
|
reg hold_time_code;
|
|
|
|
reg enable_null;
|
|
reg enable_fct;
|
|
reg enable_n_char;
|
|
reg enable_time_code;
|
|
|
|
reg [2:0] fct_send;
|
reg [2:0] fct_send;
|
reg [2:0] fct_flag;
|
reg [2:0] fct_flag;
|
|
|
reg [5:0] fct_counter;
|
|
reg [5:0] fct_counter_receive;
|
reg [5:0] fct_counter_receive;
|
|
|
|
//reg block_increment;
|
|
reg block_decrement;
|
|
reg char_sent;
|
|
|
|
//reg block_increment_fct_send;
|
|
//reg block_decrement_fct_send;
|
|
reg fct_sent;
|
|
|
reg last_tx_dout;
|
reg last_tx_dout;
|
reg last_tx_sout;
|
reg last_tx_sout;
|
|
|
reg tx_dout;
|
reg tx_dout;
|
reg tx_sout;
|
reg tx_sout;
|
Line 117... |
Line 123... |
reg tx_dout_null;
|
reg tx_dout_null;
|
reg tx_dout_fct;
|
reg tx_dout_fct;
|
reg tx_dout_timecode;
|
reg tx_dout_timecode;
|
reg tx_dout_data;
|
reg tx_dout_data;
|
|
|
reg block_sum;
|
|
reg block_sum_fct_send;
|
|
|
|
reg [3:0] global_counter_transfer;
|
reg [3:0] global_counter_transfer;
|
|
|
|
|
|
|
always@(*)
|
always@(*)
|
begin
|
begin
|
tx_dout_null = last_tx_dout;
|
tx_dout = last_tx_dout;
|
|
|
if(enable_null)
|
case(state_tx)
|
|
tx_spw_start:
|
|
begin
|
|
end
|
|
tx_spw_null,tx_spw_null_c:
|
begin
|
begin
|
if(last_type == NULL && global_counter_transfer[3:0] == 4'd0)
|
if(last_type == NULL && global_counter_transfer[3:0] == 4'd0)
|
begin
|
begin
|
tx_dout_null = !(null_s[6]^null_s[0]^null_s[1]);
|
tx_dout = !(null_s[6]^null_s[0]^null_s[1]);
|
end
|
end
|
else if(last_type == FCT && global_counter_transfer[3:0] == 4'd0)
|
else if(last_type == FCT && global_counter_transfer[3:0] == 4'd0)
|
begin
|
begin
|
tx_dout_null = !(null_s[6]^fct_s[0]^fct_s[1]);
|
tx_dout = !(null_s[6]^fct_s[0]^fct_s[1]);
|
end
|
end
|
else if(last_type == EOP && global_counter_transfer[3:0] == 4'd0)
|
else if(last_type == EOP && global_counter_transfer[3:0] == 4'd0)
|
begin
|
begin
|
tx_dout_null = !(null_s[6]^eop_s[0]^eop_s[1]);
|
tx_dout = !(null_s[6]^eop_s[0]^eop_s[1]);
|
end
|
end
|
else if(last_type == EEP && global_counter_transfer[3:0] == 4'd0)
|
else if(last_type == EEP && global_counter_transfer[3:0] == 4'd0)
|
begin
|
begin
|
tx_dout_null = !(null_s[6]^eep_s[0]^eep_s[1]);
|
tx_dout = !(null_s[6]^eep_s[0]^eep_s[1]);
|
end
|
end
|
else if(last_type == DATA && global_counter_transfer[3:0] == 4'd0)
|
else if(last_type == DATA && global_counter_transfer[3:0] == 4'd0)
|
begin
|
begin
|
tx_dout_null = !(null_s[6]^txdata_flagctrl_tx_last[0]^txdata_flagctrl_tx_last[1]^txdata_flagctrl_tx_last[2]^txdata_flagctrl_tx_last[3]^ txdata_flagctrl_tx_last[4]^txdata_flagctrl_tx_last[5]^txdata_flagctrl_tx_last[6]^txdata_flagctrl_tx_last[7]);
|
tx_dout = !(null_s[6]^txdata_flagctrl_tx_last[0]^txdata_flagctrl_tx_last[1]^txdata_flagctrl_tx_last[2]^txdata_flagctrl_tx_last[3]^ txdata_flagctrl_tx_last[4]^txdata_flagctrl_tx_last[5]^txdata_flagctrl_tx_last[6]^txdata_flagctrl_tx_last[7]);
|
end
|
end
|
else if(last_type == TIMEC && global_counter_transfer[3:0] == 4'd0)
|
else if(last_type == TIMEC && global_counter_transfer[3:0] == 4'd0)
|
begin
|
begin
|
tx_dout_null = !(null_s[6]^last_timein_control_flag_tx[7]^last_timein_control_flag_tx[6]^last_timein_control_flag_tx[5]^last_timein_control_flag_tx[4]^last_timein_control_flag_tx[3]^last_timein_control_flag_tx[2]^last_timein_control_flag_tx[1]^last_timein_control_flag_tx[0]);
|
tx_dout = !(null_s[6]^last_timein_control_flag_tx[7]^last_timein_control_flag_tx[6]^last_timein_control_flag_tx[5]^last_timein_control_flag_tx[4]^last_timein_control_flag_tx[3]^last_timein_control_flag_tx[2]^last_timein_control_flag_tx[1]^last_timein_control_flag_tx[0]);
|
end
|
end
|
else if(global_counter_transfer[3:0] == 4'd1)
|
else if(global_counter_transfer[3:0] == 4'd1)
|
begin
|
begin
|
tx_dout_null = null_s[6];
|
tx_dout = null_s[6];
|
end
|
end
|
else if(global_counter_transfer[3:0] == 4'd2)
|
else if(global_counter_transfer[3:0] == 4'd2)
|
begin
|
begin
|
tx_dout_null = null_s[5];
|
tx_dout = null_s[5];
|
end
|
end
|
else if(global_counter_transfer[3:0] == 4'd3)
|
else if(global_counter_transfer[3:0] == 4'd3)
|
begin
|
begin
|
tx_dout_null = null_s[4];
|
tx_dout = null_s[4];
|
end
|
end
|
else if(global_counter_transfer[3:0] == 4'd4)
|
else if(global_counter_transfer[3:0] == 4'd4)
|
begin
|
begin
|
tx_dout_null = null_s[3];
|
tx_dout = null_s[3];
|
end
|
end
|
else if(global_counter_transfer[3:0] == 4'd5)
|
else if(global_counter_transfer[3:0] == 4'd5)
|
begin
|
begin
|
tx_dout_null = null_s[2];
|
tx_dout = null_s[2];
|
end
|
end
|
else if(global_counter_transfer[3:0] == 4'd6)
|
else if(global_counter_transfer[3:0] == 4'd6)
|
begin
|
begin
|
tx_dout_null = null_s[1];
|
tx_dout = null_s[1];
|
end
|
end
|
else if(global_counter_transfer[3:0] == 4'd7)
|
else if(global_counter_transfer[3:0] == 4'd7)
|
begin
|
begin
|
tx_dout_null = null_s[0];
|
tx_dout = null_s[0];
|
end
|
end
|
end
|
end
|
end
|
tx_spw_fct,tx_spw_fct_c:
|
|
|
|
|
always@(*)
|
|
begin
|
begin
|
|
|
tx_dout_fct = last_tx_dout;
|
|
|
|
if(enable_fct)
|
|
begin
|
|
|
|
if(last_type == NULL && global_counter_transfer[3:0] == 4'd0)
|
if(last_type == NULL && global_counter_transfer[3:0] == 4'd0)
|
begin
|
begin
|
tx_dout_fct = !(fct_s[2]^null_s[0]^null_s[1]);
|
tx_dout = !(fct_s[2]^null_s[0]^null_s[1]);
|
end
|
end
|
else if(last_type == FCT && global_counter_transfer[3:0] == 4'd0)
|
else if(last_type == FCT && global_counter_transfer[3:0] == 4'd0)
|
begin
|
begin
|
tx_dout_fct = !(fct_s[2]^fct_s[0]^fct_s[1]);
|
tx_dout = !(fct_s[2]^fct_s[0]^fct_s[1]);
|
end
|
end
|
else if(last_type == EOP && global_counter_transfer[3:0] == 4'd0)
|
else if(last_type == EOP && global_counter_transfer[3:0] == 4'd0)
|
begin
|
begin
|
tx_dout_fct = !(fct_s[2]^eop_s[0]^eop_s[1]);
|
tx_dout = !(fct_s[2]^eop_s[0]^eop_s[1]);
|
end
|
end
|
else if(last_type == EEP && global_counter_transfer[3:0] == 4'd0)
|
else if(last_type == EEP && global_counter_transfer[3:0] == 4'd0)
|
begin
|
begin
|
tx_dout_fct = !(fct_s[2]^eep_s[0]^eep_s[1]);
|
tx_dout = !(fct_s[2]^eep_s[0]^eep_s[1]);
|
end
|
end
|
else if (last_type == DATA && global_counter_transfer[3:0] == 4'd0)
|
else if (last_type == DATA && global_counter_transfer[3:0] == 4'd0)
|
begin
|
begin
|
tx_dout_fct = !(fct_s[2]^txdata_flagctrl_tx_last[0]^txdata_flagctrl_tx_last[1]^txdata_flagctrl_tx_last[2]^txdata_flagctrl_tx_last[3]^ txdata_flagctrl_tx_last[4]^txdata_flagctrl_tx_last[5]^txdata_flagctrl_tx_last[6]^txdata_flagctrl_tx_last[7]);
|
tx_dout = !(fct_s[2]^txdata_flagctrl_tx_last[0]^txdata_flagctrl_tx_last[1]^txdata_flagctrl_tx_last[2]^txdata_flagctrl_tx_last[3]^ txdata_flagctrl_tx_last[4]^txdata_flagctrl_tx_last[5]^txdata_flagctrl_tx_last[6]^txdata_flagctrl_tx_last[7]);
|
end
|
end
|
else if(last_type == TIMEC && global_counter_transfer[3:0] == 4'd0)
|
else if(last_type == TIMEC && global_counter_transfer[3:0] == 4'd0)
|
begin
|
begin
|
tx_dout_fct = !(fct_s[2]^last_timein_control_flag_tx[7]^last_timein_control_flag_tx[6]^last_timein_control_flag_tx[5]^last_timein_control_flag_tx[4]^last_timein_control_flag_tx[3]^last_timein_control_flag_tx[2]^last_timein_control_flag_tx[1]^last_timein_control_flag_tx[0]);
|
tx_dout = !(fct_s[2]^last_timein_control_flag_tx[7]^last_timein_control_flag_tx[6]^last_timein_control_flag_tx[5]^last_timein_control_flag_tx[4]^last_timein_control_flag_tx[3]^last_timein_control_flag_tx[2]^last_timein_control_flag_tx[1]^last_timein_control_flag_tx[0]);
|
end
|
end
|
else if(global_counter_transfer[3:0] == 4'd1)
|
else if(global_counter_transfer[3:0] == 4'd1)
|
begin
|
begin
|
tx_dout_fct = fct_s[2];
|
tx_dout = fct_s[2];
|
end
|
end
|
else if(global_counter_transfer[3:0] == 4'd2)
|
else if(global_counter_transfer[3:0] == 4'd2)
|
begin
|
begin
|
tx_dout_fct = fct_s[1];
|
tx_dout = fct_s[1];
|
end
|
end
|
else if(global_counter_transfer[3:0] == 4'd3)
|
else if(global_counter_transfer[3:0] == 4'd3)
|
begin
|
begin
|
tx_dout_fct = fct_s[0];
|
tx_dout = fct_s[0];
|
end
|
|
|
|
end
|
end
|
end
|
end
|
|
tx_spw_data_c:
|
always@(*)
|
|
begin
|
begin
|
tx_dout_timecode = last_tx_dout;
|
if(!tx_data_in[8] && last_type == NULL && global_counter_transfer[3:0] == 4'd0)
|
|
|
if(enable_time_code)
|
|
begin
|
|
if(last_type == NULL && global_counter_transfer[3:0] == 4'd0)
|
|
begin
|
begin
|
tx_dout_timecode = !(timecode_s[12]^null_s[0]^null_s[1]);
|
tx_dout = !(tx_data_in[8]^null_s[0]^null_s[1]);
|
end
|
end
|
else if(last_type == FCT && global_counter_transfer[3:0] == 4'd0)
|
else if(!tx_data_in[8] && last_type == FCT && global_counter_transfer[3:0] == 4'd0)
|
begin
|
begin
|
tx_dout_timecode = !(timecode_s[12]^fct_s[0]^fct_s[1]);
|
tx_dout = !(tx_data_in[8]^fct_s[0]^fct_s[1]);
|
end
|
end
|
else if (last_type == EOP && global_counter_transfer[3:0] == 4'd0)
|
else if(!tx_data_in[8] && last_type == EOP && global_counter_transfer[3:0] == 4'd0)
|
begin
|
begin
|
tx_dout_timecode = !(timecode_s[12]^eop_s[0]^eop_s[1]);
|
tx_dout = !(tx_data_in[8]^eop_s[0]^eop_s[1]);
|
end
|
end
|
else if( last_type == EEP && global_counter_transfer[3:0] == 4'd0)
|
else if(!tx_data_in[8] && last_type == EEP && global_counter_transfer[3:0] == 4'd0)
|
begin
|
begin
|
tx_dout_timecode = !(timecode_s[12]^eep_s[0]^eep_s[1]);
|
tx_dout = !(tx_data_in[8]^eep_s[0]^eep_s[1]);
|
end
|
end
|
else if( last_type == DATA && global_counter_transfer[3:0] == 4'd0)
|
else if(!tx_data_in[8] && last_type == DATA && global_counter_transfer[3:0] == 4'd0)
|
begin
|
begin
|
tx_dout_timecode = !(timecode_s[12]^txdata_flagctrl_tx_last[0]^txdata_flagctrl_tx_last[1]^txdata_flagctrl_tx_last[2]^txdata_flagctrl_tx_last[3]^ txdata_flagctrl_tx_last[4]^txdata_flagctrl_tx_last[5]^txdata_flagctrl_tx_last[6]^txdata_flagctrl_tx_last[7]);
|
tx_dout = !(tx_data_in[8]^txdata_flagctrl_tx_last[0]^txdata_flagctrl_tx_last[1]^txdata_flagctrl_tx_last[2]^txdata_flagctrl_tx_last[3]^ txdata_flagctrl_tx_last[4]^txdata_flagctrl_tx_last[5]^txdata_flagctrl_tx_last[6]^txdata_flagctrl_tx_last[7]);
|
end
|
end
|
else if( last_type == TIMEC && global_counter_transfer[3:0] == 4'd0)
|
else if(!tx_data_in[8] && last_type == TIMEC && global_counter_transfer[3:0] == 4'd0)
|
begin
|
begin
|
tx_dout_timecode = !(timecode_s[12]^last_timein_control_flag_tx[7]^last_timein_control_flag_tx[6]^last_timein_control_flag_tx[5]^last_timein_control_flag_tx[4]^last_timein_control_flag_tx[3]^last_timein_control_flag_tx[2]^last_timein_control_flag_tx[1]^last_timein_control_flag_tx[0]);
|
tx_dout = !(tx_data_in[8]^last_timein_control_flag_tx[7]^last_timein_control_flag_tx[6]^last_timein_control_flag_tx[5]^last_timein_control_flag_tx[4]^last_timein_control_flag_tx[3]^last_timein_control_flag_tx[2]^last_timein_control_flag_tx[1]^last_timein_control_flag_tx[0]);
|
end
|
end
|
else if( global_counter_transfer[3:0] == 4'd1)
|
else if(tx_data_in[8] && tx_data_in[1:0] == 2'b00 && last_type == NULL && global_counter_transfer[3:0] == 4'd0)
|
begin
|
begin
|
tx_dout_timecode = timecode_s[12];
|
tx_dout = !(eop_s[2]^null_s[0]^null_s[1]);
|
end
|
end
|
else if( global_counter_transfer[3:0] == 4'd2)
|
else if(tx_data_in[8] && tx_data_in[1:0] == 2'b00 && last_type == FCT && global_counter_transfer[3:0] == 4'd0)
|
begin
|
begin
|
tx_dout_timecode = timecode_s[11];
|
tx_dout = !(eop_s[2]^fct_s[0]^fct_s[1]);
|
end
|
end
|
else if( global_counter_transfer[3:0] == 4'd3)
|
else if(tx_data_in[8] && tx_data_in[1:0] == 2'b00 && last_type == EOP && global_counter_transfer[3:0] == 4'd0)
|
begin
|
begin
|
tx_dout_timecode = timecode_s[10];
|
tx_dout = !(eop_s[2]^eop_s[0]^eop_s[1]);
|
end
|
end
|
else if( global_counter_transfer[3:0] == 4'd4)
|
else if(tx_data_in[8] && tx_data_in[1:0] == 2'b00 && last_type == EEP && global_counter_transfer[3:0] == 4'd0)
|
begin
|
begin
|
tx_dout_timecode = timecode_s[9];
|
tx_dout = !(eop_s[2]^eep_s[0]^eep_s[1]);
|
end
|
end
|
else if( global_counter_transfer[3:0] == 4'd5)
|
else if(tx_data_in[8] && tx_data_in[1:0] == 2'b00 && last_type == DATA && global_counter_transfer[3:0] == 4'd0)
|
begin
|
begin
|
tx_dout_timecode = timecode_s[8];
|
tx_dout = !(eop_s[2]^txdata_flagctrl_tx_last[0]^txdata_flagctrl_tx_last[1]^txdata_flagctrl_tx_last[2]^txdata_flagctrl_tx_last[3]^ txdata_flagctrl_tx_last[4]^txdata_flagctrl_tx_last[5]^txdata_flagctrl_tx_last[6]^txdata_flagctrl_tx_last[7]);
|
end
|
end
|
else if( global_counter_transfer[3:0] == 4'd6)
|
else if(tx_data_in[8] && tx_data_in[1:0] == 2'b00 && last_type == TIMEC && global_counter_transfer[3:0] == 4'd0)
|
begin
|
begin
|
tx_dout_timecode = timecode_s[0];
|
tx_dout = !(eop_s[2]^last_timein_control_flag_tx[7]^last_timein_control_flag_tx[6]^last_timein_control_flag_tx[5]^last_timein_control_flag_tx[4]^last_timein_control_flag_tx[3]^last_timein_control_flag_tx[2]^last_timein_control_flag_tx[1]^last_timein_control_flag_tx[0]);
|
end
|
end
|
else if( global_counter_transfer[3:0] == 4'd7)
|
else if(tx_data_in[8] && tx_data_in[1:0] == 2'b01 && last_type == NULL && global_counter_transfer[3:0] == 4'd0)
|
begin
|
begin
|
tx_dout_timecode = timecode_s[1];
|
tx_dout = !(eep_s[2]^null_s[0]^null_s[1]);
|
end
|
end
|
else if( global_counter_transfer[3:0] == 4'd8)
|
else if(tx_data_in[8] && tx_data_in[1:0] == 2'b01 && last_type == FCT && global_counter_transfer[3:0] == 4'd0)
|
begin
|
begin
|
tx_dout_timecode = timecode_s[2];
|
tx_dout = !(eep_s[2]^fct_s[0]^fct_s[1]);
|
end
|
end
|
else if(global_counter_transfer[3:0] == 4'd9)
|
else if(tx_data_in[8] && tx_data_in[1:0] == 2'b01 && last_type == EOP && global_counter_transfer[3:0] == 4'd0)
|
begin
|
begin
|
tx_dout_timecode = timecode_s[3];
|
tx_dout = !(eep_s[2]^eop_s[0]^eop_s[1]);
|
end
|
end
|
else if(global_counter_transfer[3:0] == 4'd10)
|
else if(tx_data_in[8] && tx_data_in[1:0] == 2'b01 && last_type == EEP && global_counter_transfer[3:0] == 4'd0)
|
begin
|
begin
|
tx_dout_timecode = timecode_s[4];
|
tx_dout = !(eep_s[2]^eep_s[0]^eep_s[1]);
|
end
|
end
|
else if(global_counter_transfer[3:0] == 4'd11)
|
else if(tx_data_in[8] && tx_data_in[1:0] == 2'b01 && last_type == DATA && global_counter_transfer[3:0] == 4'd0)
|
begin
|
begin
|
tx_dout_timecode = timecode_s[5];
|
tx_dout = !(eep_s[2]^txdata_flagctrl_tx_last[0]^txdata_flagctrl_tx_last[1]^txdata_flagctrl_tx_last[2]^txdata_flagctrl_tx_last[3]^ txdata_flagctrl_tx_last[4]^txdata_flagctrl_tx_last[5]^txdata_flagctrl_tx_last[6]^txdata_flagctrl_tx_last[7]);
|
end
|
end
|
else if( global_counter_transfer[3:0] == 4'd12)
|
else if(tx_data_in[8] && tx_data_in[1:0] == 2'b01 && last_type == TIMEC && global_counter_transfer[3:0] == 4'd0)
|
begin
|
begin
|
tx_dout_timecode = timecode_s[6];
|
tx_dout = !(eep_s[2]^last_timein_control_flag_tx[7]^last_timein_control_flag_tx[6]^last_timein_control_flag_tx[5]^last_timein_control_flag_tx[4]^last_timein_control_flag_tx[3]^last_timein_control_flag_tx[2]^last_timein_control_flag_tx[1]^last_timein_control_flag_tx[0]);
|
end
|
end
|
else if(global_counter_transfer[3:0] == 4'd13)
|
else if(!tx_data_in[8] && global_counter_transfer[3:0] == 4'd1)
|
begin
|
begin
|
tx_dout_timecode = timecode_s[7];
|
tx_dout = tx_data_in[8];
|
end
|
end
|
end
|
else if(!tx_data_in[8] && global_counter_transfer[3:0] == 4'd2)
|
end
|
|
|
|
always@(*)
|
|
begin
|
|
tx_dout_data = last_tx_dout;
|
|
|
|
if(enable_n_char)
|
|
begin
|
|
if(!tx_data_in[8] && last_type == NULL && global_counter_transfer[3:0] == 4'd0)
|
|
begin
|
begin
|
tx_dout_data = !(tx_data_in[8]^null_s[0]^null_s[1]);
|
tx_dout = tx_data_in[0];
|
end
|
end
|
else if(!tx_data_in[8] && last_type == FCT && global_counter_transfer[3:0] == 4'd0)
|
else if(!tx_data_in[8] && global_counter_transfer[3:0] == 4'd3)
|
begin
|
begin
|
tx_dout_data = !(tx_data_in[8]^fct_s[0]^fct_s[1]);
|
tx_dout = tx_data_in[1];
|
end
|
end
|
else if(!tx_data_in[8] && last_type == EOP && global_counter_transfer[3:0] == 4'd0)
|
else if(!tx_data_in[8] && global_counter_transfer[3:0] == 4'd4)
|
begin
|
begin
|
tx_dout_data = !(tx_data_in[8]^eop_s[0]^eop_s[1]);
|
tx_dout = tx_data_in[2];
|
end
|
end
|
else if(!tx_data_in[8] && last_type == EEP && global_counter_transfer[3:0] == 4'd0)
|
else if(!tx_data_in[8] && global_counter_transfer[3:0] == 4'd5)
|
begin
|
begin
|
tx_dout_data = !(tx_data_in[8]^eep_s[0]^eep_s[1]);
|
tx_dout = tx_data_in[3];
|
end
|
end
|
else if(!tx_data_in[8] && last_type == DATA && global_counter_transfer[3:0] == 4'd0)
|
else if(!tx_data_in[8] && global_counter_transfer[3:0] == 4'd6)
|
begin
|
begin
|
tx_dout_data = !(tx_data_in[8]^txdata_flagctrl_tx_last[0]^txdata_flagctrl_tx_last[1]^txdata_flagctrl_tx_last[2]^txdata_flagctrl_tx_last[3]^ txdata_flagctrl_tx_last[4]^txdata_flagctrl_tx_last[5]^txdata_flagctrl_tx_last[6]^txdata_flagctrl_tx_last[7]);
|
tx_dout = tx_data_in[4];
|
end
|
end
|
else if(!tx_data_in[8] && last_type == TIMEC && global_counter_transfer[3:0] == 4'd0)
|
else if(!tx_data_in[8] && global_counter_transfer[3:0] == 4'd7)
|
begin
|
begin
|
tx_dout_data = !(tx_data_in[8]^last_timein_control_flag_tx[7]^last_timein_control_flag_tx[6]^last_timein_control_flag_tx[5]^last_timein_control_flag_tx[4]^last_timein_control_flag_tx[3]^last_timein_control_flag_tx[2]^last_timein_control_flag_tx[1]^last_timein_control_flag_tx[0]);
|
tx_dout = tx_data_in[5];
|
end
|
end
|
else if(tx_data_in[8] && tx_data_in[1:0] == 2'b00 && last_type == NULL && global_counter_transfer[3:0] == 4'd0)
|
else if(!tx_data_in[8] && global_counter_transfer[3:0] == 4'd8)
|
begin
|
begin
|
tx_dout_data = !(eop_s[2]^null_s[0]^null_s[1]);
|
tx_dout = tx_data_in[6];
|
end
|
end
|
else if(tx_data_in[8] && tx_data_in[1:0] == 2'b00 && last_type == FCT && global_counter_transfer[3:0] == 4'd0)
|
else if(!tx_data_in[8] && global_counter_transfer[3:0] == 4'd9)
|
begin
|
begin
|
tx_dout_data = !(eop_s[2]^fct_s[0]^fct_s[1]);
|
tx_dout = tx_data_in[7];
|
end
|
end
|
else if(tx_data_in[8] && tx_data_in[1:0] == 2'b00 && last_type == EOP && global_counter_transfer[3:0] == 4'd0)
|
else if(tx_data_in[8] && tx_data_in[1:0] == 2'b01 && global_counter_transfer[3:0] == 4'd1)
|
begin
|
begin
|
tx_dout_data = !(eop_s[2]^eop_s[0]^eop_s[1]);
|
tx_dout = eep_s[2];
|
end
|
end
|
else if(tx_data_in[8] && tx_data_in[1:0] == 2'b00 && last_type == EEP && global_counter_transfer[3:0] == 4'd0)
|
else if( tx_data_in[8] && tx_data_in[1:0] == 2'b01 && global_counter_transfer[3:0] == 4'd2)
|
begin
|
begin
|
tx_dout_data = !(eop_s[2]^eep_s[0]^eep_s[1]);
|
tx_dout = eep_s[1];
|
end
|
end
|
else if(tx_data_in[8] && tx_data_in[1:0] == 2'b00 && last_type == DATA && global_counter_transfer[3:0] == 4'd0)
|
else if(tx_data_in[8] && tx_data_in[1:0] == 2'b01 && global_counter_transfer[3:0] == 4'd3)
|
begin
|
begin
|
tx_dout_data = !(eop_s[2]^txdata_flagctrl_tx_last[0]^txdata_flagctrl_tx_last[1]^txdata_flagctrl_tx_last[2]^txdata_flagctrl_tx_last[3]^ txdata_flagctrl_tx_last[4]^txdata_flagctrl_tx_last[5]^txdata_flagctrl_tx_last[6]^txdata_flagctrl_tx_last[7]);
|
tx_dout = eep_s[0];
|
end
|
end
|
else if(tx_data_in[8] && tx_data_in[1:0] == 2'b00 && last_type == TIMEC && global_counter_transfer[3:0] == 4'd0)
|
else if(tx_data_in[8] && tx_data_in[1:0] == 2'b00 && global_counter_transfer[3:0] == 4'd1)
|
begin
|
begin
|
tx_dout_data = !(eop_s[2]^last_timein_control_flag_tx[7]^last_timein_control_flag_tx[6]^last_timein_control_flag_tx[5]^last_timein_control_flag_tx[4]^last_timein_control_flag_tx[3]^last_timein_control_flag_tx[2]^last_timein_control_flag_tx[1]^last_timein_control_flag_tx[0]);
|
tx_dout = eop_s[2];
|
end
|
end
|
else if(tx_data_in[8] && tx_data_in[1:0] == 2'b01 && last_type == NULL && global_counter_transfer[3:0] == 4'd0)
|
else if(tx_data_in[8] && tx_data_in[1:0] == 2'b00 && global_counter_transfer[3:0] == 4'd2)
|
begin
|
begin
|
tx_dout_data = !(eep_s[2]^null_s[0]^null_s[1]);
|
tx_dout = eop_s[1];
|
end
|
end
|
else if(tx_data_in[8] && tx_data_in[1:0] == 2'b01 && last_type == FCT && global_counter_transfer[3:0] == 4'd0)
|
else if(tx_data_in[8] && tx_data_in[1:0] == 2'b00 && global_counter_transfer[3:0] == 4'd3)
|
begin
|
begin
|
tx_dout_data = !(eep_s[2]^fct_s[0]^fct_s[1]);
|
tx_dout = eop_s[0];
|
end
|
end
|
else if(tx_data_in[8] && tx_data_in[1:0] == 2'b01 && last_type == EOP && global_counter_transfer[3:0] == 4'd0)
|
end
|
|
tx_spw_time_code_c:
|
|
begin
|
|
if(last_type == NULL && global_counter_transfer[3:0] == 4'd0)
|
begin
|
begin
|
tx_dout_data = !(eep_s[2]^eop_s[0]^eop_s[1]);
|
tx_dout = !(timecode_s[12]^null_s[0]^null_s[1]);
|
end
|
end
|
else if(tx_data_in[8] && tx_data_in[1:0] == 2'b01 && last_type == EEP && global_counter_transfer[3:0] == 4'd0)
|
else if(last_type == FCT && global_counter_transfer[3:0] == 4'd0)
|
begin
|
begin
|
tx_dout_data = !(eep_s[2]^eep_s[0]^eep_s[1]);
|
tx_dout = !(timecode_s[12]^fct_s[0]^fct_s[1]);
|
end
|
end
|
else if(tx_data_in[8] && tx_data_in[1:0] == 2'b01 && last_type == DATA && global_counter_transfer[3:0] == 4'd0)
|
else if (last_type == EOP && global_counter_transfer[3:0] == 4'd0)
|
begin
|
begin
|
tx_dout_data = !(eep_s[2]^txdata_flagctrl_tx_last[0]^txdata_flagctrl_tx_last[1]^txdata_flagctrl_tx_last[2]^txdata_flagctrl_tx_last[3]^ txdata_flagctrl_tx_last[4]^txdata_flagctrl_tx_last[5]^txdata_flagctrl_tx_last[6]^txdata_flagctrl_tx_last[7]);
|
tx_dout = !(timecode_s[12]^eop_s[0]^eop_s[1]);
|
end
|
end
|
else if(tx_data_in[8] && tx_data_in[1:0] == 2'b01 && last_type == TIMEC && global_counter_transfer[3:0] == 4'd0)
|
else if( last_type == EEP && global_counter_transfer[3:0] == 4'd0)
|
begin
|
begin
|
tx_dout_data = !(eep_s[2]^last_timein_control_flag_tx[7]^last_timein_control_flag_tx[6]^last_timein_control_flag_tx[5]^last_timein_control_flag_tx[4]^last_timein_control_flag_tx[3]^last_timein_control_flag_tx[2]^last_timein_control_flag_tx[1]^last_timein_control_flag_tx[0]);
|
tx_dout = !(timecode_s[12]^eep_s[0]^eep_s[1]);
|
end
|
end
|
else if(!tx_data_in[8] && global_counter_transfer[3:0] == 4'd1)
|
else if( last_type == DATA && global_counter_transfer[3:0] == 4'd0)
|
begin
|
begin
|
tx_dout_data = tx_data_in[8];
|
tx_dout = !(timecode_s[12]^txdata_flagctrl_tx_last[0]^txdata_flagctrl_tx_last[1]^txdata_flagctrl_tx_last[2]^txdata_flagctrl_tx_last[3]^ txdata_flagctrl_tx_last[4]^txdata_flagctrl_tx_last[5]^txdata_flagctrl_tx_last[6]^txdata_flagctrl_tx_last[7]);
|
end
|
end
|
else if(!tx_data_in[8] && global_counter_transfer[3:0] == 4'd2)
|
else if( last_type == TIMEC && global_counter_transfer[3:0] == 4'd0)
|
begin
|
begin
|
tx_dout_data = tx_data_in[0];
|
tx_dout = !(timecode_s[12]^last_timein_control_flag_tx[7]^last_timein_control_flag_tx[6]^last_timein_control_flag_tx[5]^last_timein_control_flag_tx[4]^last_timein_control_flag_tx[3]^last_timein_control_flag_tx[2]^last_timein_control_flag_tx[1]^last_timein_control_flag_tx[0]);
|
end
|
end
|
else if(!tx_data_in[8] && global_counter_transfer[3:0] == 4'd3)
|
else if( global_counter_transfer[3:0] == 4'd1)
|
begin
|
begin
|
tx_dout_data = tx_data_in[1];
|
tx_dout = timecode_s[12];
|
end
|
end
|
else if(!tx_data_in[8] && global_counter_transfer[3:0] == 4'd4)
|
else if( global_counter_transfer[3:0] == 4'd2)
|
begin
|
begin
|
tx_dout_data = tx_data_in[2];
|
tx_dout = timecode_s[11];
|
end
|
end
|
else if(!tx_data_in[8] && global_counter_transfer[3:0] == 4'd5)
|
else if( global_counter_transfer[3:0] == 4'd3)
|
begin
|
begin
|
tx_dout_data = tx_data_in[3];
|
tx_dout = timecode_s[10];
|
end
|
end
|
else if(!tx_data_in[8] && global_counter_transfer[3:0] == 4'd6)
|
else if( global_counter_transfer[3:0] == 4'd4)
|
begin
|
begin
|
tx_dout_data = tx_data_in[4];
|
tx_dout = timecode_s[9];
|
end
|
end
|
else if(!tx_data_in[8] && global_counter_transfer[3:0] == 4'd7)
|
else if( global_counter_transfer[3:0] == 4'd5)
|
begin
|
begin
|
tx_dout_data = tx_data_in[5];
|
tx_dout = timecode_s[8];
|
end
|
end
|
else if(!tx_data_in[8] && global_counter_transfer[3:0] == 4'd8)
|
else if( global_counter_transfer[3:0] == 4'd6)
|
begin
|
begin
|
tx_dout_data = tx_data_in[6];
|
tx_dout = timecode_s[0];
|
end
|
end
|
else if(!tx_data_in[8] && global_counter_transfer[3:0] == 4'd9)
|
else if( global_counter_transfer[3:0] == 4'd7)
|
begin
|
begin
|
tx_dout_data = tx_data_in[7];
|
tx_dout = timecode_s[1];
|
end
|
end
|
else if(tx_data_in[8] && tx_data_in[1:0] == 2'b01 && global_counter_transfer[3:0] == 4'd1)
|
else if( global_counter_transfer[3:0] == 4'd8)
|
begin
|
begin
|
tx_dout_data = eep_s[2];
|
tx_dout = timecode_s[2];
|
end
|
end
|
else if( tx_data_in[8] && tx_data_in[1:0] == 2'b01 && global_counter_transfer[3:0] == 4'd2)
|
else if(global_counter_transfer[3:0] == 4'd9)
|
begin
|
begin
|
tx_dout_data = eep_s[1];
|
tx_dout = timecode_s[3];
|
end
|
end
|
else if(tx_data_in[8] && tx_data_in[1:0] == 2'b01 && global_counter_transfer[3:0] == 4'd3)
|
else if(global_counter_transfer[3:0] == 4'd10)
|
begin
|
begin
|
tx_dout_data = eep_s[0];
|
tx_dout = timecode_s[4];
|
end
|
end
|
else if(tx_data_in[8] && tx_data_in[1:0] == 2'b00 && global_counter_transfer[3:0] == 4'd1)
|
else if(global_counter_transfer[3:0] == 4'd11)
|
begin
|
begin
|
tx_dout_data = eop_s[2];
|
tx_dout = timecode_s[5];
|
end
|
end
|
else if(tx_data_in[8] && tx_data_in[1:0] == 2'b00 && global_counter_transfer[3:0] == 4'd2)
|
else if( global_counter_transfer[3:0] == 4'd12)
|
begin
|
begin
|
tx_dout_data = eop_s[1];
|
tx_dout = timecode_s[6];
|
end
|
end
|
else if(tx_data_in[8] && tx_data_in[1:0] == 2'b00 && global_counter_transfer[3:0] == 4'd3)
|
else if(global_counter_transfer[3:0] == 4'd13)
|
begin
|
begin
|
tx_dout_data = eop_s[0];
|
tx_dout = timecode_s[7];
|
|
end
|
end
|
end
|
|
default:
|
|
begin
|
end
|
end
|
|
endcase
|
end
|
end
|
|
|
//strobe
|
//strobe
|
always@(*)
|
always@(*)
|
begin
|
begin
|
|
|
tx_sout = last_tx_sout;
|
tx_sout = last_tx_sout;
|
|
|
if((enable_null | enable_fct | enable_n_char | enable_time_code) & tx_dout == last_tx_dout)
|
if(tx_dout == last_tx_dout)
|
begin
|
begin
|
tx_sout = !last_tx_sout;
|
tx_sout = !last_tx_sout;
|
end
|
end
|
else if((enable_null | enable_fct | enable_n_char | enable_time_code) & tx_dout != last_tx_dout)
|
else if(tx_dout != last_tx_dout)
|
begin
|
begin
|
tx_sout = last_tx_sout;
|
tx_sout = last_tx_sout;
|
end
|
end
|
end
|
end
|
|
|
always@(*)
|
always@(*)
|
begin
|
begin
|
fct_counter = 6'd0;
|
next_state_fct_send = state_fct_send;
|
|
|
if(gotfct_tx)
|
case(state_fct_send)
|
|
3'd0:
|
|
begin
|
|
if(send_fct_now)
|
begin
|
begin
|
if(block_sum)
|
next_state_fct_send = 3'd1;
|
|
end
|
|
else if(fct_sent)
|
begin
|
begin
|
|
next_state_fct_send = 3'd3;
|
end
|
end
|
else
|
else
|
|
next_state_fct_send = 3'd0;
|
|
end
|
|
3'd1:
|
begin
|
begin
|
if(fct_counter_receive < 6'd48)
|
if(global_counter_transfer == 4'd2)
|
begin
|
begin
|
fct_counter = fct_counter_receive + 6'd8;
|
next_state_fct_send = 3'd2;
|
end
|
end
|
else
|
else
|
begin
|
begin
|
fct_counter = fct_counter_receive + 6'd7;
|
next_state_fct_send = 3'd1;
|
|
|
end
|
|
end
|
|
end
|
end
|
end
|
end
|
|
3'd2:
|
//slots open in our side
|
|
always@(*)
|
|
begin
|
begin
|
|
|
fct_send = {3{1'b0}};
|
|
|
|
if(send_fct_now)
|
if(send_fct_now)
|
begin
|
begin
|
if(block_sum_fct_send)
|
next_state_fct_send = 3'd2;
|
|
end
|
|
else
|
begin
|
begin
|
|
next_state_fct_send = 3'd0;
|
|
end
|
|
end
|
|
3'd3:
|
|
begin
|
|
if(global_counter_transfer == 4'd2)
|
|
begin
|
|
next_state_fct_send = 3'd4;
|
end
|
end
|
else
|
else
|
begin
|
begin
|
if(fct_flag == 3'd7)
|
next_state_fct_send = 3'd3;
|
|
end
|
|
end
|
|
3'd4:
|
|
begin
|
|
if(fct_sent)
|
begin
|
begin
|
fct_send = 3'd0;
|
next_state_fct_send = 3'd4;
|
end
|
end
|
else
|
else
|
begin
|
begin
|
fct_send = fct_flag + 3'd1;
|
next_state_fct_send = 3'd0;
|
|
|
end
|
end
|
end
|
end
|
|
default:
|
|
begin
|
|
next_state_fct_send = 3'd0;
|
end
|
end
|
|
endcase
|
end
|
end
|
|
|
always@(*)
|
always@(posedge pclk_tx or negedge enable_tx)
|
begin
|
begin
|
|
if(!enable_tx)
|
|
begin
|
|
fct_flag <= 3'd7;
|
|
state_fct_send<= 3'd0;
|
|
end
|
|
else
|
|
begin
|
|
state_fct_send <= next_state_fct_send;
|
|
|
tx_dout = last_tx_dout;
|
case(state_fct_send)
|
|
3'd0:
|
if(enable_null)
|
|
begin
|
begin
|
tx_dout = tx_dout_null;
|
fct_flag <= fct_flag;
|
end
|
end
|
else if(enable_fct)
|
3'd1:
|
begin
|
begin
|
tx_dout = tx_dout_fct;
|
if(global_counter_transfer == 4'd2)
|
|
fct_flag <= fct_flag + 3'd1;
|
|
else
|
|
fct_flag <= fct_flag;
|
end
|
end
|
else if(enable_time_code)
|
3'd2:
|
begin
|
begin
|
tx_dout = tx_dout_timecode;
|
fct_flag <= fct_flag;
|
end
|
end
|
else if(enable_n_char)
|
3'd3:
|
begin
|
begin
|
tx_dout = tx_dout_data;
|
if(global_counter_transfer == 4'd2)
|
|
fct_flag <= fct_flag - 3'd1;
|
|
else
|
|
fct_flag <= fct_flag;
|
end
|
end
|
|
3'd4:
|
|
begin
|
|
fct_flag <= fct_flag;
|
end
|
end
|
|
default:
|
always@(*)
|
|
begin
|
begin
|
|
fct_flag <= fct_flag;
|
|
end
|
|
endcase
|
|
end
|
|
end
|
|
|
|
|
enable_null = hold_null;
|
always@(*)
|
enable_fct = hold_fct;
|
begin
|
enable_n_char = hold_data;
|
next_state_fct_receive = state_fct_receive;
|
enable_time_code = hold_time_code;
|
|
|
|
next_state_tx = state_tx;
|
|
|
|
case(state_tx)
|
case(state_fct_receive)
|
tx_spw_start:
|
3'd0:
|
begin
|
begin
|
if(send_null_tx && enable_tx)
|
if(gotfct_tx)
|
begin
|
begin
|
next_state_tx = tx_spw_null;
|
next_state_fct_receive = 3'd1;
|
end
|
end
|
else
|
else if(char_sent)
|
begin
|
begin
|
next_state_tx = tx_spw_start;
|
next_state_fct_receive = 3'd3;
|
end
|
end
|
|
else
|
|
next_state_fct_receive = 3'd0;
|
end
|
end
|
tx_spw_null:
|
3'd1:
|
begin
|
begin
|
enable_null = 1'b1;
|
if(global_counter_transfer == 4'd2)
|
|
|
if(!hold_null)
|
|
begin
|
begin
|
if(send_null_tx && send_fct_tx && enable_tx)
|
next_state_fct_receive = 3'd2;
|
next_state_tx = tx_spw_null_fct;
|
end
|
else
|
else
|
next_state_tx = tx_spw_null;
|
begin
|
|
next_state_fct_receive = 3'd1;
|
end
|
end
|
|
|
end
|
end
|
tx_spw_null_fct:
|
3'd2:
|
begin
|
begin
|
|
if(gotfct_tx)
|
enable_null = 1'b1;
|
|
|
|
if(send_fct_tx && fct_flag > 0 && !hold_null)
|
|
begin
|
begin
|
next_state_tx = tx_spw_null_fct;
|
next_state_fct_receive = 3'd2;
|
enable_null = 1'b0;
|
|
enable_fct = 1'b1;
|
|
end
|
end
|
else
|
else
|
begin
|
begin
|
enable_fct = 1'b0;
|
next_state_fct_receive = 3'd0;
|
if(send_fct_tx && fct_counter_receive > 6'd0)
|
|
begin
|
|
next_state_tx = tx_spw_full;
|
|
end
|
|
|
|
end
|
end
|
end
|
end
|
tx_spw_full:
|
3'd3:
|
begin
|
begin
|
if(tickin_tx && !ready_tx_timecode && tcode_rdy_trnsp &&!hold_null && !hold_fct && !hold_data)
|
if(global_counter_transfer == 4'd2)
|
begin
|
begin
|
enable_time_code = 1'b1;
|
next_state_fct_receive = 3'd4;
|
end
|
end
|
else if(fct_flag > 3'd0 && !hold_null && !hold_time_code && !hold_data)
|
else
|
begin
|
begin
|
enable_fct = 1'b1;
|
next_state_fct_receive = 3'd3;
|
end
|
end
|
else if((txwrite_tx && !ready_tx_data && data_rdy_trnsp && fct_counter_receive > 6'd0 && !hold_null && !hold_time_code && !hold_fct) == 1'b1 )
|
end
|
|
3'd4:
|
|
begin
|
|
if(char_sent)
|
begin
|
begin
|
enable_n_char = 1'b1;
|
next_state_fct_receive = 3'd4;
|
end
|
end
|
else
|
else
|
begin
|
begin
|
enable_null = 1'b1;
|
next_state_fct_receive = 3'd0;
|
end
|
end
|
end
|
end
|
|
default:
|
|
begin
|
|
next_state_fct_receive = 3'd0;
|
|
end
|
endcase
|
endcase
|
|
|
end
|
end
|
|
|
|
|
|
|
always@(posedge pclk_tx or negedge enable_tx)
|
always@(posedge pclk_tx or negedge enable_tx)
|
begin
|
begin
|
if(!enable_tx)
|
if(!enable_tx)
|
begin
|
begin
|
|
|
timecode_s <= 14'b01110000000000;
|
|
fct_flag <= 3'd7;
|
|
|
|
ready_tx_data <= 1'b0;
|
|
ready_tx_timecode <= 1'b0;
|
|
|
|
hold_null <= 1'b0;
|
|
hold_fct <= 1'b0;
|
|
hold_data <= 1'b0;
|
|
hold_time_code <= 1'b0;
|
|
|
|
last_type <= NULL;
|
|
|
|
global_counter_transfer <= 4'd0;
|
|
txdata_flagctrl_tx_last <= 9'd0;
|
|
tx_data_in <= 9'd0;
|
|
last_timein_control_flag_tx <= 8'd0;
|
|
|
|
fct_counter_receive <= 6'd0;
|
fct_counter_receive <= 6'd0;
|
|
state_fct_receive <= 3'd0;
|
block_sum <= 1'b0;
|
|
block_sum_fct_send <= 1'b0;
|
|
|
|
last_tx_dout <= 1'b0;
|
|
last_tx_sout <= 1'b0;
|
|
|
|
state_tx <= tx_spw_start;
|
|
|
|
tx_dout_e <= 1'b0;
|
|
tx_sout_e <= 1'b0;
|
|
|
|
data_rdy_trnsp <= 1'b0;
|
|
|
|
tx_tcode_in <= 8'd0;
|
|
tcode_rdy_trnsp <= 1'b0;
|
|
|
|
end
|
end
|
else
|
else
|
begin
|
begin
|
|
|
state_tx <= next_state_tx;
|
state_fct_receive <= next_state_fct_receive;
|
|
|
last_tx_dout <= tx_dout;
|
|
last_tx_sout <= tx_sout;
|
|
|
|
tx_dout_e <= last_tx_dout;
|
case(state_fct_receive)
|
tx_sout_e <= last_tx_sout;
|
3'd0:
|
|
|
if(enable_null)
|
|
begin
|
begin
|
|
fct_counter_receive <= fct_counter_receive;
|
if(txwrite_tx && global_counter_transfer == 4'd5)
|
end
|
|
3'd1:
|
begin
|
begin
|
tx_data_in <= data_tx_i;
|
if(global_counter_transfer == 4'd2)
|
data_rdy_trnsp <= 1'b1;
|
begin
|
|
if(fct_counter_receive < 6'd48)
|
|
begin
|
|
fct_counter_receive <= fct_counter_receive + 6'd8;
|
end
|
end
|
else
|
else
|
tx_data_in <= tx_data_in;
|
|
|
|
if(tickin_tx && global_counter_transfer == 4'd5)
|
|
begin
|
begin
|
tx_tcode_in <= timecode_tx_i;
|
fct_counter_receive <= fct_counter_receive + 6'd7;
|
tcode_rdy_trnsp <= 1'b1;
|
end
|
end
|
end
|
else
|
else
|
tx_tcode_in <= tx_tcode_in;
|
fct_counter_receive <= fct_counter_receive;
|
|
end
|
|
3'd2:
|
|
begin
|
|
fct_counter_receive <= fct_counter_receive;
|
|
end
|
|
3'd3:
|
|
begin
|
|
if(global_counter_transfer == 4'd2)
|
|
fct_counter_receive <= fct_counter_receive - 6'd1;
|
|
else
|
|
fct_counter_receive <= fct_counter_receive;
|
|
end
|
|
3'd4:
|
|
begin
|
|
fct_counter_receive <= fct_counter_receive;
|
|
end
|
|
default:
|
|
begin
|
|
fct_counter_receive <= fct_counter_receive;
|
|
end
|
|
endcase
|
|
end
|
|
end
|
|
|
//hold_null <= 1'b0;
|
always@(*)
|
hold_fct <= 1'b0;
|
begin
|
hold_data <= 1'b0;
|
next_state_tx = state_tx;
|
hold_time_code <= 1'b0;
|
|
|
|
//
|
case(state_tx)
|
if(gotfct_tx && !block_sum)
|
tx_spw_start:
|
|
begin
|
|
if(send_null_tx && enable_tx)
|
|
begin
|
|
next_state_tx = tx_spw_null;
|
|
end
|
|
else
|
begin
|
begin
|
fct_counter_receive <= fct_counter;
|
next_state_tx = tx_spw_start;
|
block_sum<= 1'b1;
|
end
|
|
end
|
|
tx_spw_null:
|
|
begin
|
|
if(send_null_tx && send_fct_tx && enable_tx)
|
|
begin
|
|
if(global_counter_transfer == 4'd7)
|
|
next_state_tx = tx_spw_fct;
|
|
end
|
|
else
|
|
next_state_tx = tx_spw_null;
|
end
|
end
|
else if(!gotfct_tx)
|
tx_spw_fct:
|
begin
|
begin
|
block_sum<= 1'b0;
|
if(send_fct_tx && fct_flag > 3'd0)
|
|
begin
|
|
next_state_tx = tx_spw_fct;
|
end
|
end
|
else
|
else
|
block_sum <= block_sum;
|
|
//
|
|
if(send_fct_now && !block_sum_fct_send)
|
|
begin
|
begin
|
fct_flag <= fct_send;
|
if(send_fct_tx && fct_counter_receive > 6'd0)
|
block_sum_fct_send<= 1'b1;
|
begin
|
|
if(global_counter_transfer == 4'd7 || global_counter_transfer == 4'd3)
|
|
begin
|
|
if(tickin_tx && !ready_tx_timecode && tcode_rdy_trnsp)
|
|
begin
|
|
next_state_tx = tx_spw_time_code_c;
|
end
|
end
|
else if(!send_fct_now)
|
else if(fct_flag > 3'd0 && !send_fct_now)
|
begin
|
begin
|
block_sum_fct_send<= 1'b0;
|
next_state_tx = tx_spw_fct_c;
|
|
end
|
|
else if(txwrite_tx && !gotfct_tx && !gotfct_tx && !ready_tx_data && data_rdy_trnsp && fct_counter_receive > 6'd0)
|
|
begin
|
|
next_state_tx = tx_spw_data_c;
|
end
|
end
|
else
|
else
|
block_sum_fct_send <= block_sum_fct_send;
|
begin
|
|
next_state_tx = tx_spw_null_c;
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|
|
tx_spw_null_c:
|
|
begin
|
|
if(global_counter_transfer == 4'd7)
|
|
begin
|
|
if(tickin_tx && !ready_tx_timecode && tcode_rdy_trnsp)
|
|
begin
|
|
next_state_tx = tx_spw_time_code_c;
|
|
end
|
|
else if(fct_flag > 3'd0 && !send_fct_now)
|
|
begin
|
|
next_state_tx = tx_spw_fct_c;
|
|
end
|
|
else if(txwrite_tx && !gotfct_tx && !ready_tx_data && data_rdy_trnsp && fct_counter_receive > 6'd0)
|
|
begin
|
|
next_state_tx = tx_spw_data_c;
|
|
end
|
|
else
|
|
begin
|
|
next_state_tx = tx_spw_null_c;
|
|
end
|
|
end
|
|
else
|
|
begin
|
|
next_state_tx = tx_spw_null_c;
|
|
end
|
|
end
|
|
tx_spw_fct_c:
|
|
begin
|
if(global_counter_transfer == 4'd3)
|
if(global_counter_transfer == 4'd3)
|
begin
|
begin
|
ready_tx_timecode <= 1'b0;
|
if(tickin_tx && !ready_tx_timecode && tcode_rdy_trnsp)
|
ready_tx_data <= 1'b0;
|
begin
|
|
next_state_tx = tx_spw_time_code_c;
|
end
|
end
|
else
|
else
|
begin
|
begin
|
ready_tx_timecode <= ready_tx_timecode;
|
next_state_tx = tx_spw_null_c;
|
ready_tx_data <= ready_tx_data;
|
end
|
end
|
end
|
|
else
|
|
begin
|
|
next_state_tx = tx_spw_fct_c;
|
|
end
|
|
end
|
|
tx_spw_data_c:
|
|
begin
|
|
|
if(global_counter_transfer == 4'd7)
|
if(!tx_data_in[8])
|
begin
|
begin
|
last_type <= NULL;
|
if(global_counter_transfer == 4'd9)
|
hold_null <= 1'b0;
|
begin
|
global_counter_transfer <= 4'd0;
|
if(tickin_tx && !ready_tx_timecode && tcode_rdy_trnsp)
|
|
begin
|
|
next_state_tx = tx_spw_time_code_c;
|
|
end
|
|
else if(fct_flag > 3'd0 && !send_fct_now)
|
|
begin
|
|
next_state_tx = tx_spw_fct_c;
|
end
|
end
|
else
|
else
|
begin
|
begin
|
last_type <= last_type;
|
next_state_tx = tx_spw_null_c;
|
hold_null <= 1'b1;
|
end
|
global_counter_transfer <= global_counter_transfer + 4'd1;
|
|
end
|
end
|
|
else
|
|
next_state_tx = tx_spw_data_c;
|
end
|
end
|
else if(enable_fct)
|
else if(tx_data_in[8])
|
begin
|
begin
|
|
if(global_counter_transfer == 4'd3)
|
hold_null <= 1'b0;
|
begin
|
//hold_fct <= 1'b0;
|
if(tickin_tx && !ready_tx_timecode && tcode_rdy_trnsp)
|
hold_data <= 1'b0;
|
begin
|
hold_time_code <= 1'b0;
|
next_state_tx = tx_spw_time_code_c;
|
|
end
|
|
else if(fct_flag > 3'd0 && !send_fct_now)
|
|
begin
|
|
next_state_tx = tx_spw_fct_c;
|
|
end
|
|
else
|
|
begin
|
|
next_state_tx = tx_spw_null_c;
|
|
end
|
|
end
|
|
else
|
|
next_state_tx = tx_spw_data_c;
|
|
end
|
|
|
|
|
if(gotfct_tx && !block_sum)
|
end
|
|
tx_spw_time_code_c:
|
begin
|
begin
|
fct_counter_receive <= fct_counter;
|
if(global_counter_transfer == 4'd13)
|
block_sum<= 1'b1;
|
begin
|
|
if(fct_flag > 3'd0 && !send_fct_now)
|
|
begin
|
|
next_state_tx = tx_spw_fct_c;
|
end
|
end
|
else if(!gotfct_tx)
|
else if(txwrite_tx && !gotfct_tx && !ready_tx_data && data_rdy_trnsp && fct_counter_receive > 6'd0 )
|
|
begin
|
|
next_state_tx = tx_spw_data_c;
|
|
end
|
|
else
|
begin
|
begin
|
block_sum<= 1'b0;
|
next_state_tx = tx_spw_null_c;
|
|
end
|
end
|
end
|
else
|
else
|
block_sum <= block_sum;
|
begin
|
|
next_state_tx = tx_spw_time_code_c;
|
|
end
|
|
end
|
|
default:
|
|
begin
|
|
next_state_tx = tx_spw_start;
|
|
end
|
|
endcase
|
|
end
|
|
|
ready_tx_data <= ready_tx_data;
|
|
|
|
if(global_counter_transfer == 4'd3)
|
always@(posedge pclk_tx or negedge enable_tx)
|
|
begin
|
|
if(!enable_tx)
|
begin
|
begin
|
|
|
fct_flag <= fct_flag - 3'd1;
|
timecode_s <= 14'b01110000000000;
|
last_type <=FCT;
|
|
|
ready_tx_data <= 1'b0;
|
|
ready_tx_timecode <= 1'b0;
|
|
|
|
last_type <= NULL;
|
|
|
global_counter_transfer <= 4'd0;
|
global_counter_transfer <= 4'd0;
|
hold_fct <= 1'b0;
|
txdata_flagctrl_tx_last <= 9'd0;
|
|
tx_data_in <= 9'd0;
|
|
last_timein_control_flag_tx <= 8'd0;
|
|
|
|
char_sent<= 1'b0;
|
|
fct_sent <= 1'b0;
|
|
|
|
last_tx_dout <= 1'b0;
|
|
last_tx_sout <= 1'b0;
|
|
|
|
state_tx <= tx_spw_start;
|
|
|
|
tx_dout_e <= 1'b0;
|
|
tx_sout_e <= 1'b0;
|
|
|
|
data_rdy_trnsp <= 1'b0;
|
|
|
|
tx_tcode_in <= 8'd0;
|
|
tcode_rdy_trnsp <= 1'b0;
|
|
|
end
|
end
|
else
|
else
|
begin
|
begin
|
|
state_tx <= next_state_tx;
|
|
|
if(send_fct_now && !block_sum_fct_send)
|
case(state_tx)
|
|
tx_spw_start:
|
begin
|
begin
|
fct_flag <= fct_send;
|
|
block_sum_fct_send<= 1'b1;
|
|
end
|
end
|
else if(!send_fct_now)
|
tx_spw_null:
|
begin
|
begin
|
block_sum_fct_send<= 1'b0;
|
|
end
|
|
else
|
|
block_sum_fct_send <= block_sum_fct_send;
|
|
|
|
hold_fct <= 1'b1;
|
last_tx_dout <= tx_dout;
|
global_counter_transfer <= global_counter_transfer + 4'd1;
|
last_tx_sout <= tx_sout;
|
end
|
|
end
|
|
else if(enable_time_code)
|
|
begin
|
|
|
|
if(txwrite_tx && global_counter_transfer == 4'd6)
|
tx_dout_e <= last_tx_dout;
|
|
tx_sout_e <= last_tx_sout;
|
|
|
|
|
|
if(txwrite_tx && global_counter_transfer == 4'd5)
|
begin
|
begin
|
data_rdy_trnsp <= 1'b1;
|
|
tx_data_in <= data_tx_i;
|
tx_data_in <= data_tx_i;
|
|
data_rdy_trnsp <= 1'b1;
|
end
|
end
|
else
|
else
|
tx_data_in <= tx_data_in;
|
tx_data_in <= tx_data_in;
|
|
|
hold_null <= 1'b0;
|
if(tickin_tx && global_counter_transfer == 4'd5)
|
hold_fct <= 1'b0;
|
begin
|
hold_data <= 1'b0;
|
tx_tcode_in <= timecode_tx_i;
|
//hold_time_code <= 1'b0;
|
tcode_rdy_trnsp <= 1'b1;
|
|
end
|
|
else
|
|
tx_tcode_in <= tx_tcode_in;
|
|
|
if(gotfct_tx && !block_sum)
|
if(global_counter_transfer == 4'd3)
|
begin
|
begin
|
fct_counter_receive <= fct_counter;
|
ready_tx_timecode <= 1'b0;
|
block_sum<= 1'b1;
|
ready_tx_data <= 1'b0;
|
end
|
end
|
else if(!gotfct_tx)
|
else
|
|
begin
|
|
ready_tx_timecode <= ready_tx_timecode;
|
|
ready_tx_data <= ready_tx_data;
|
|
end
|
|
|
|
if(global_counter_transfer == 4'd7)
|
begin
|
begin
|
block_sum<= 1'b0;
|
last_type <= NULL;
|
|
global_counter_transfer <= 4'd0;
|
end
|
end
|
else
|
else
|
block_sum <= block_sum;
|
begin
|
|
last_type <= last_type;
|
|
global_counter_transfer <= global_counter_transfer + 4'd1;
|
|
end
|
|
end
|
|
tx_spw_fct:
|
|
begin
|
|
|
if(global_counter_transfer == 4'd13)
|
last_tx_dout <= tx_dout;
|
|
last_tx_sout <= tx_sout;
|
|
|
|
tx_dout_e <= last_tx_dout;
|
|
tx_sout_e <= last_tx_sout;
|
|
|
|
ready_tx_data <= ready_tx_data;
|
|
|
|
if(global_counter_transfer == 4'd3)
|
begin
|
begin
|
hold_time_code <= 1'b0;
|
last_type <=FCT;
|
ready_tx_timecode <= 1'b1;
|
|
global_counter_transfer <= 4'd0;
|
global_counter_transfer <= 4'd0;
|
|
fct_sent <= 1'b0;
|
end
|
end
|
else
|
else
|
begin
|
begin
|
hold_time_code <= 1'b0;
|
if(fct_flag > 3'd0)
|
ready_tx_timecode <= 1'b0;
|
fct_sent <= 1'b1;
|
|
else
|
|
fct_sent <= fct_sent;
|
global_counter_transfer <= global_counter_transfer + 4'd1;
|
global_counter_transfer <= global_counter_transfer + 4'd1;
|
end
|
end
|
|
end
|
|
tx_spw_null_c:
|
|
begin
|
|
|
|
last_tx_dout <= tx_dout;
|
|
last_tx_sout <= tx_sout;
|
|
|
//
|
tx_dout_e <= last_tx_dout;
|
if(send_fct_now && !block_sum_fct_send)
|
tx_sout_e <= last_tx_sout;
|
|
|
|
|
|
if(txwrite_tx && global_counter_transfer == 4'd5)
|
begin
|
begin
|
fct_flag <= fct_send;
|
tx_data_in <= data_tx_i;
|
block_sum_fct_send<= 1'b1;
|
data_rdy_trnsp <= 1'b1;
|
end
|
end
|
else if(!send_fct_now)
|
else
|
|
tx_data_in <= tx_data_in;
|
|
|
|
if(tickin_tx && global_counter_transfer == 4'd5)
|
begin
|
begin
|
block_sum_fct_send<= 1'b0;
|
tx_tcode_in <= timecode_tx_i;
|
|
tcode_rdy_trnsp <= 1'b1;
|
end
|
end
|
else
|
else
|
block_sum_fct_send <= block_sum_fct_send;
|
tx_tcode_in <= tx_tcode_in;
|
|
|
if(global_counter_transfer != 4'd13)
|
|
|
if(global_counter_transfer == 4'd3)
|
|
begin
|
|
char_sent <= 1'b0;
|
|
fct_sent <= 1'b0;
|
|
ready_tx_timecode <= 1'b0;
|
|
ready_tx_data <= 1'b0;
|
|
end
|
|
else
|
begin
|
begin
|
|
ready_tx_timecode <= ready_tx_timecode;
|
|
ready_tx_data <= ready_tx_data;
|
|
end
|
|
|
timecode_s <= {timecode_ss[13:10],2'd2,tx_tcode_in[7:0]};
|
if(global_counter_transfer == 4'd7)
|
|
begin
|
|
last_type <= NULL;
|
|
global_counter_transfer <= 4'd0;
|
end
|
end
|
else
|
else
|
begin
|
begin
|
ready_tx_data <= 1'b0;
|
last_type <= last_type;
|
last_timein_control_flag_tx <= tx_tcode_in;
|
global_counter_transfer <= global_counter_transfer + 4'd1;
|
last_type <= TIMEC;
|
|
end
|
end
|
end
|
end
|
else if(enable_n_char)
|
tx_spw_fct_c:
|
begin
|
begin
|
hold_null <= 1'b0;
|
|
hold_fct <= 1'b0;
|
|
//hold_data <= 1'b0;
|
|
hold_time_code <= 1'b0;
|
|
|
|
//
|
last_tx_dout <= tx_dout;
|
if(send_fct_now && !block_sum_fct_send)
|
last_tx_sout <= tx_sout;
|
|
|
|
tx_dout_e <= last_tx_dout;
|
|
tx_sout_e <= last_tx_sout;
|
|
|
|
ready_tx_data <= ready_tx_data;
|
|
|
|
if(global_counter_transfer == 4'd3)
|
begin
|
begin
|
fct_flag <= fct_send;
|
char_sent <= 1'b0;
|
block_sum_fct_send<= 1'b1;
|
last_type <=FCT;
|
|
fct_sent <= 1'b0;
|
|
global_counter_transfer <= 4'd0;
|
end
|
end
|
else if(!send_fct_now)
|
else
|
begin
|
begin
|
block_sum_fct_send<= 1'b0;
|
if(fct_flag > 3'd0)
|
end
|
fct_sent <= 1'b1;
|
else
|
else
|
block_sum_fct_send <= block_sum_fct_send;
|
fct_sent <= fct_sent;
|
|
|
|
global_counter_transfer <= global_counter_transfer + 4'd1;
|
|
end
|
|
end
|
|
tx_spw_data_c:
|
|
begin
|
|
|
|
last_tx_dout <= tx_dout;
|
|
last_tx_sout <= tx_sout;
|
|
|
|
tx_dout_e <= last_tx_dout;
|
|
tx_sout_e <= last_tx_sout;
|
|
|
|
fct_sent <= 1'b0;
|
|
|
if(!tx_data_in[8])
|
if(!tx_data_in[8])
|
begin
|
begin
|
|
|
if(global_counter_transfer == 4'd9)
|
if(global_counter_transfer == 4'd9)
|
begin
|
begin
|
|
char_sent <= 1'b1;
|
|
|
fct_counter_receive <= fct_counter_receive - 6'd1;
|
|
last_type <= DATA;
|
last_type <= DATA;
|
|
|
hold_data <= 1'b0;
|
|
ready_tx_data <= 1'b1;
|
ready_tx_data <= 1'b1;
|
data_rdy_trnsp <= 1'b0;
|
data_rdy_trnsp <= 1'b0;
|
global_counter_transfer <= 4'd0;
|
global_counter_transfer <= 4'd0;
|
end
|
end
|
else
|
else
|
begin
|
begin
|
if(gotfct_tx && !block_sum)
|
|
begin
|
|
fct_counter_receive <= fct_counter;
|
|
block_sum<= 1'b1;
|
|
end
|
|
else if(!gotfct_tx)
|
|
begin
|
|
block_sum<= 1'b0;
|
|
end
|
|
else
|
|
block_sum <= block_sum;
|
|
|
|
ready_tx_data <= 1'b0;
|
ready_tx_data <= 1'b0;
|
hold_data <= 1'b1;
|
|
ready_tx_timecode <= 1'b0;
|
ready_tx_timecode <= 1'b0;
|
global_counter_transfer <= global_counter_transfer + 4'd1;
|
global_counter_transfer <= global_counter_transfer + 4'd1;
|
end
|
end
|
|
|
if(global_counter_transfer == 4'd4)
|
if(global_counter_transfer == 4'd4)
|
Line 938... |
Line 1120... |
else if(tx_data_in[8])
|
else if(tx_data_in[8])
|
begin
|
begin
|
|
|
if(global_counter_transfer == 4'd3)
|
if(global_counter_transfer == 4'd3)
|
begin
|
begin
|
fct_counter_receive <= fct_counter_receive - 6'd1;
|
char_sent <= 1'b1;
|
|
|
if(tx_data_in[1:0] == 2'b00)
|
if(tx_data_in[1:0] == 2'b00)
|
begin
|
begin
|
last_type <=EOP;
|
last_type <=EOP;
|
end
|
end
|
Line 950... |
Line 1132... |
begin
|
begin
|
last_type <=EEP;
|
last_type <=EEP;
|
end
|
end
|
|
|
global_counter_transfer <= 4'd0;
|
global_counter_transfer <= 4'd0;
|
hold_data <= 1'b0;
|
|
data_rdy_trnsp <= 1'b0;
|
data_rdy_trnsp <= 1'b0;
|
ready_tx_data <= 1'b1;
|
ready_tx_data <= 1'b1;
|
end
|
end
|
else
|
else
|
begin
|
begin
|
txdata_flagctrl_tx_last <= txdata_flagctrl_tx_last;
|
txdata_flagctrl_tx_last <= txdata_flagctrl_tx_last;
|
|
|
if(gotfct_tx && !block_sum)
|
ready_tx_data <= 1'b0;
|
begin
|
ready_tx_timecode <= 1'b0;
|
fct_counter_receive <= fct_counter;
|
global_counter_transfer <= global_counter_transfer + 4'd1;
|
block_sum<= 1'b1;
|
end
|
|
|
|
|
end
|
end
|
else if(!gotfct_tx)
|
|
|
end
|
|
tx_spw_time_code_c:
|
begin
|
begin
|
block_sum<= 1'b0;
|
|
|
if(txwrite_tx && global_counter_transfer == 4'd6)
|
|
begin
|
|
data_rdy_trnsp <= 1'b1;
|
|
tx_data_in <= data_tx_i;
|
end
|
end
|
else
|
else
|
block_sum <= block_sum;
|
tx_data_in <= tx_data_in;
|
|
|
hold_data <= 1'b1;
|
|
ready_tx_data <= 1'b0;
|
fct_sent <= 1'b0;
|
|
|
|
last_tx_dout <= tx_dout;
|
|
last_tx_sout <= tx_sout;
|
|
|
|
tx_dout_e <= last_tx_dout;
|
|
tx_sout_e <= last_tx_sout;
|
|
|
|
if(global_counter_transfer == 4'd13)
|
|
begin
|
|
ready_tx_timecode <= 1'b1;
|
|
global_counter_transfer <= 4'd0;
|
|
end
|
|
else
|
|
begin
|
ready_tx_timecode <= 1'b0;
|
ready_tx_timecode <= 1'b0;
|
global_counter_transfer <= global_counter_transfer + 4'd1;
|
global_counter_transfer <= global_counter_transfer + 4'd1;
|
end
|
end
|
|
|
|
|
end
|
if(global_counter_transfer != 4'd13)
|
|
begin
|
|
|
|
timecode_s <= {timecode_ss[13:10],2'd2,tx_tcode_in[7:0]};
|
|
end
|
|
else
|
|
begin
|
|
ready_tx_data <= 1'b0;
|
|
last_timein_control_flag_tx <= tx_tcode_in;
|
|
last_type <= TIMEC;
|
end
|
end
|
|
|
end
|
end
|
|
default:
|
|
begin
|
|
last_type <= last_type;
|
|
global_counter_transfer <= global_counter_transfer;
|
|
tx_dout_e <= tx_dout_e;
|
|
tx_sout_e <= tx_sout_e;
|
|
end
|
|
endcase
|
|
end
|
end
|
end
|
|
|
endmodule
|
endmodule
|
|
|
No newline at end of file
|
No newline at end of file
|