OpenCores
URL https://opencores.org/ocsvn/spacewiresystemc/spacewiresystemc/trunk

Subversion Repositories spacewiresystemc

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /spacewiresystemc
    from Rev 36 to Rev 37
    Reverse comparison

Rev 36 → Rev 37

/trunk/rtl/RTL_VB/fifo_rx.v
51,11 → 51,96
reg [AWIDTH-1:0] wr_ptr;
reg [AWIDTH-1:0] rd_ptr;
 
reg block_read;
reg block_write;
 
reg [AWIDTH-1:0] credit_counter;
 
reg [1:0] state_data_write;
reg [1:0] next_state_data_write;
 
reg [1:0] state_data_read;
reg [1:0] next_state_data_read;
 
 
/****************************************/
 
always@(*)
begin
next_state_data_write = state_data_write;
 
case(state_data_write)
2'd0:
begin
if(wr_en && !f_full)
begin
next_state_data_write = 2'd1;
end
else
begin
next_state_data_write = 2'd0;
end
end
2'd1:
begin
if(wr_en)
begin
next_state_data_write = 2'd1;
end
else
begin
next_state_data_write = 2'd2;
end
end
2'd2:
begin
next_state_data_write = 2'd0;
end
default:
begin
next_state_data_write = 2'd0;
end
endcase
end
 
/****************************************/
 
always@(*)
begin
next_state_data_read = state_data_read;
 
case(state_data_read)
2'd0:
begin
if(rd_en && !f_empty)
begin
next_state_data_read = 2'd1;
end
else
begin
next_state_data_read = 2'd0;
end
end
2'd1:
begin
if(rd_en)
begin
next_state_data_read = 2'd1;
end
else
begin
next_state_data_read = 2'd2;
end
end
2'd2:
begin
next_state_data_read = 2'd0;
end
default:
begin
next_state_data_read = 2'd0;
end
endcase
end
 
 
//Write pointer
always@(posedge clock or negedge reset)
begin
132,30 → 217,41
mem[61] <= {(DWIDTH){1'b0}};
mem[62] <= {(DWIDTH){1'b0}};
mem[63] <= {(DWIDTH){1'b0}};
block_write <= 1'b0;
 
overflow_credit_error<=1'b0;
state_data_write <= 2'd0;
end
else
begin
if(block_write)
 
state_data_write <= next_state_data_write;
 
case(state_data_write)
2'd0:
begin
if(!wr_en)
begin
block_write <= 1'b0;
wr_ptr <= wr_ptr + 6'd1;
end
mem[wr_ptr]<=data_in;
end
else if (wr_en && !f_full)
2'd1:
begin
block_write <= 1'b1;
mem[wr_ptr]<=data_in;
mem[wr_ptr]<=mem[wr_ptr];
end
 
2'd2:
begin
wr_ptr <= wr_ptr + 6'd1;
end
default:
begin
mem[wr_ptr]<=mem[wr_ptr];
wr_ptr <= wr_ptr;
end
endcase
if(wr_en && credit_counter > 6'd55)
begin
overflow_credit_error<=1'b1;
overflow_credit_error <= 1'b1;
end
else
overflow_credit_error <= overflow_credit_error;
end
end
 
173,39 → 269,37
else
begin
 
if((wr_en && !f_full && !block_write) && (rd_en && !f_empty && !block_read))
if (state_data_write == 2'd2)
begin
if(rd_ptr == 6'd7 || rd_ptr == 6'd15 || rd_ptr == 6'd23 || rd_ptr == 6'd31 || rd_ptr == 6'd39 || rd_ptr == 6'd47 || rd_ptr == 6'd55 || rd_ptr == 6'd63)
credit_counter <= credit_counter - 6'd1 + 6'd8;
else
credit_counter <= credit_counter - 6'd1;
end
else if (wr_en && !f_full && !block_write)
begin
credit_counter <= credit_counter - 6'd1;
end
else if(rd_en && !f_empty && !block_read)
else if(state_data_read == 2'd2)
begin
if(rd_ptr == 6'd7 || rd_ptr == 6'd15 || rd_ptr == 6'd23 || rd_ptr == 6'd31 || rd_ptr == 6'd39 || rd_ptr == 6'd47 || rd_ptr == 6'd55 || rd_ptr == 6'd63)
begin
credit_counter <= credit_counter + 6'd8;
begin
if(credit_counter < 6'd48)
credit_counter <= credit_counter + 6'd8;
else
credit_counter <= credit_counter + 6'd7;
end
end
else
credit_counter <= credit_counter;
 
if((wr_en && !f_full && !block_write) && (rd_en && !f_empty && !block_read))
if (state_data_write == 2'd2)
begin
counter <= counter;
if(counter == 6'd63)
counter <= counter;
else
counter <= counter + 6'd1;
end
else if (wr_en && !f_full && !block_write)
else if(state_data_read == 2'd2)
begin
counter <= counter + 6'd1;
if(counter == 6'd0)
counter <= counter;
else
counter <= counter - 6'd1;
end
else if(rd_en && !f_empty && !block_read)
begin
counter <= counter - 6'd1;
end
else
begin
counter <= counter;
239,36 → 333,54
rd_ptr <= {(AWIDTH){1'b0}};
data_out <= 9'd0;
open_slot_fct<= 1'b0;
block_read <= 1'b0;
state_data_read <= 2'd0;
end
else
begin
state_data_read <= next_state_data_read;
 
if(rd_ptr == 6'd7 || rd_ptr == 6'd15 || rd_ptr == 6'd23 || rd_ptr == 6'd31 || rd_ptr == 6'd39 || rd_ptr == 6'd47 || rd_ptr == 6'd55 || rd_ptr == 6'd63)
case(state_data_read)
2'd0:
begin
open_slot_fct<= 1'b1;
if(rd_en)
begin
data_out <= data_out;
open_slot_fct<= open_slot_fct;
rd_ptr <= rd_ptr+ 6'd1;
end
else
begin
open_slot_fct<= open_slot_fct;
data_out <= mem[rd_ptr];
end
end
else
2'd1:
begin
open_slot_fct<= 1'b0;
end
 
if(block_read)
begin
if(!rd_en)
if(rd_ptr == 6'd7 || rd_ptr == 6'd15 || rd_ptr == 6'd23 || rd_ptr == 6'd31 || rd_ptr == 6'd39 || rd_ptr == 6'd47 || rd_ptr == 6'd55 || rd_ptr == 6'd63)
begin
block_read<= 1'b0;
open_slot_fct<= 1'b1;
end
end
else
if(rd_en && !f_empty)
else
begin
open_slot_fct<= 1'b0;
end
 
data_out <= mem[rd_ptr];
end
2'd2:
begin
block_read<= 1'b1;
rd_ptr <= rd_ptr+ 6'd1;
open_slot_fct<= open_slot_fct;
data_out <= data_out;
end
data_out <= mem[rd_ptr];
default:
begin
rd_ptr <= rd_ptr;
data_out <= data_out;
end
endcase
 
 
end
end
 
/trunk/rtl/RTL_VB/fifo_tx.v
49,9 → 49,92
reg [AWIDTH-1:0] wr_ptr;
reg [AWIDTH-1:0] rd_ptr;
 
reg block_read;
reg block_write;
reg [1:0] state_data_write;
reg [1:0] next_state_data_write;
 
reg [1:0] state_data_read;
reg [1:0] next_state_data_read;
/****************************************/
 
always@(*)
begin
next_state_data_write = state_data_write;
 
case(state_data_write)
2'd0:
begin
if(wr_en && !f_full)
begin
next_state_data_write = 2'd1;
end
else
begin
next_state_data_write = 2'd0;
end
end
2'd1:
begin
if(wr_en)
begin
next_state_data_write = 2'd1;
end
else
begin
next_state_data_write = 2'd2;
end
end
2'd2:
begin
next_state_data_write = 2'd0;
end
default:
begin
next_state_data_write = 2'd0;
end
endcase
end
 
/****************************************/
 
always@(*)
begin
next_state_data_read = state_data_read;
 
case(state_data_read)
2'd0:
begin
if(rd_en && !f_empty)
begin
next_state_data_read = 2'd1;
end
else
begin
next_state_data_read = 2'd0;
end
end
2'd1:
begin
if(rd_en)
begin
next_state_data_read = 2'd1;
end
else
begin
next_state_data_read = 2'd2;
end
end
2'd2:
begin
next_state_data_read = 2'd0;
end
default:
begin
next_state_data_read = 2'd0;
end
endcase
end
 
//Write pointer
always@(posedge clock or negedge reset)
begin
129,118 → 212,137
mem[63] <= {(DWIDTH){1'b0}};
 
wr_ptr <= {(AWIDTH){1'b0}};
block_write <= 1'b0;
state_data_write <= 2'd0;
end
else
begin
if(block_write)
begin
if(!wr_en)
begin
block_write <= 1'b0;
wr_ptr <= wr_ptr + 6'd1;
end
end
else if (wr_en && !f_full)
begin
block_write <= 1'b1;
mem[wr_ptr]<=data_in;
end
end
end
 
//FULL - EMPTY COUNTER
state_data_write <= next_state_data_write;
 
always@(posedge clock or negedge reset)
begin
if (!reset)
begin
f_full <= 1'b0;
f_empty <= 1'b1;
counter <= {(AWIDTH){1'b0}};
end
else
begin
 
if((wr_en && !f_full && !block_write) && (rd_en && !f_empty && !block_read))
case(state_data_write)
2'd0:
begin
counter <= counter;
mem[wr_ptr]<=data_in;
end
else if (wr_en && !f_full && !block_write)
2'd1:
begin
counter <= counter + 6'd1;
mem[wr_ptr]<=mem[wr_ptr];
end
else if(rd_en && !f_empty && !block_read)
2'd2:
begin
counter <= counter - 6'd1;
wr_ptr <= wr_ptr + 6'd1;
end
else
default:
begin
counter <= counter;
mem[wr_ptr]<=mem[wr_ptr];
wr_ptr <= wr_ptr;
end
endcase
end
end
 
//FULL - EMPTY COUNTER
always@(posedge clock or negedge reset)
begin
if (!reset)
begin
f_full <= 1'b0;
f_empty <= 1'b1;
counter <= {(AWIDTH){1'b0}};
end
else
begin
 
if (state_data_write == 2'd2)
begin
if(counter == 6'd63)
begin
f_full <= 1'b1;
end
counter <= counter;
else
begin
f_full <= 1'b0;
end
 
counter <= counter + 6'd1;
end
else if(state_data_read == 2'd2)
begin
if(counter == 6'd0)
begin
f_empty <= 1'b1;
end
counter <= counter;
else
begin
f_empty <= 1'b0;
end
counter <= counter - 6'd1;
end
else
begin
counter <= counter;
end
 
if(counter == 6'd63)
begin
f_full <= 1'b1;
end
end
else
begin
f_full <= 1'b0;
end
 
//Read pointer
always@(posedge clock or negedge reset)
begin
if (!reset)
if(counter == 6'd0)
begin
rd_ptr <= {(AWIDTH){1'b0}};
data_out <= 9'd0;
write_tx <= 1'b0;
block_read <= 1'b0;
f_empty <= 1'b1;
end
else
begin
f_empty <= 1'b0;
end
end
end
 
if(block_read)
begin
if(!rd_en)
begin
block_read<= 1'b0;
end
end
else if(rd_en && !f_empty)
begin
block_read<= 1'b1;
rd_ptr <= rd_ptr+ 6'd1;
end
//Read pointer
always@(posedge clock or negedge reset)
begin
if (!reset)
begin
rd_ptr <= {(AWIDTH){1'b0}};
data_out <= 9'd0;
write_tx <= 1'b0;
state_data_read <= 2'd0;
end
else
begin
state_data_read <= next_state_data_read;
 
data_out <= mem[rd_ptr];
 
case(state_data_read)
2'd0:
begin
if(rd_en)
begin
write_tx<= 1'b0;
data_out <= data_out;
rd_ptr <= rd_ptr+ 6'd1;
end
else if(counter > 6'd0)
else
begin
write_tx<= 1'b1;
data_out <= mem[rd_ptr];
if(counter > 6'd0)
begin
write_tx<= 1'b1;
end
else
write_tx<= 1'b0;
end
else
write_tx<= write_tx;
 
end
2'd1:
begin
write_tx<= 1'b0;
data_out <= mem[rd_ptr];
end
2'd2:
begin
write_tx<= 1'b0;
data_out <= data_out;
end
default:
begin
rd_ptr <= rd_ptr;
data_out <= data_out;
end
endcase
end
end
 
endmodule
/trunk/rtl/RTL_VB/fsm_spw.v
322,7 → 322,7
if(after850ns < 12'd85 && state_fsm == run)
after850ns <= after850ns + 12'd1;
else
after850ns <= 12'd0;
after850ns <= after850ns;
 
end
end
/trunk/rtl/RTL_VB/rx_spw.v
39,7 → 39,7
 
input rx_resetn,
 
output reg rx_error,
output rx_error,
 
output reg rx_got_bit,
output reg rx_got_null,
63,6 → 63,9
wire posedge_clk;
wire negedge_clk;
 
reg [1:0] state_data_process;
reg [1:0] next_state_data_process;
 
reg bit_c_0;//N
reg bit_c_1;//P
reg bit_c_2;//N
80,15 → 83,15
reg bit_d_9;//P
 
reg is_control;
//reg is_data;
reg parity_received;
 
reg last_is_control;
reg last_is_data;
reg last_is_timec;
 
reg last_was_control;
reg last_was_data;
reg last_was_timec;
//reg last_was_control;
//reg last_was_data;
//reg last_was_timec;
 
reg [3:0] control;
reg [3:0] control_r;
97,7 → 100,7
reg [9:0] timecode;
 
reg [3:0] control_l_r;
reg [9:0] data_l_r;
//reg [9:0] data_l_r;
 
reg [9:0] dta_timec;
reg [9:0] dta_timec_p;
105,6 → 108,12
reg rx_data_take;
reg rx_data_take_0;
 
reg rx_got_fct_take;
reg rx_got_fct_take_0;
reg rx_got_fct_take_1;
reg rx_got_fct_take_2;
reg rx_got_fct_take_3;
 
reg ready_control;
reg ready_data;
 
114,6 → 123,12
reg ready_control_p_r;
reg ready_data_p_r;
 
reg parity_rec_c;
reg parity_rec_d;
 
reg rx_error_c;
reg rx_error_d;
 
reg posedge_p;
//CLOCK RECOVERY
122,6 → 137,8
 
assign rx_time_out = timecode[7:0];
 
assign rx_error = rx_error_c | rx_error_d;
 
always@(*)
begin
 
258,17 → 275,32
 
if(!rx_resetn)
begin
rx_got_fct <= 1'b0;
rx_got_fct <= 1'b0;
rx_got_fct_take <= 1'b0;
rx_got_fct_take_0 <= 1'b0;
rx_got_fct_take_1 <= 1'b0;
rx_got_fct_take_2 <= 1'b0;
rx_got_fct_take_3 <= 1'b0;
end
else
begin
if(control_l_r[2:0] != 3'd7 && control[2:0] == 3'd4 && (ready_control_p_r))
begin
rx_got_fct <= 1'b1;
rx_got_fct_take <= 1'b1;
rx_got_fct_take_0 <= rx_got_fct_take;
rx_got_fct_take_1 <= rx_got_fct_take_0;
rx_got_fct_take_2 <= rx_got_fct_take_1;
rx_got_fct_take_3 <= rx_got_fct_take_2;
rx_got_fct <= rx_got_fct_take | rx_got_fct_take_0 | rx_got_fct_take_1 | rx_got_fct_take_2 | rx_got_fct_take_3;
end
else
begin
rx_got_fct <= 1'b0;
rx_got_fct_take <= 1'b0;
rx_got_fct_take_0 <= rx_got_fct_take;
rx_got_fct_take_1 <= rx_got_fct_take_0;
rx_got_fct_take_2 <= rx_got_fct_take_1;
rx_got_fct_take_3 <= rx_got_fct_take_2;
rx_got_fct <= rx_got_fct_take | rx_got_fct_take_0 | rx_got_fct_take_1 | rx_got_fct_take_2 | rx_got_fct_take_3;
end
end
end
276,95 → 308,8
always@(posedge negedge_clk or negedge rx_resetn)
begin
 
if(!rx_resetn)
begin
rx_error <= 1'b0;
end
else
begin
if(last_is_control == 1'b1)
begin
if(last_was_control == 1'b1)
begin
if(!(control[2]^control_l_r[0]^control_l_r[1]) != control[3])
begin
rx_error <= 1'b1;
end
else
begin
rx_error <= 1'b0;
end
end
else if(last_was_timec == 1'b1)
begin
if(!(control[2]^timecode[0]^timecode[1]^timecode[2]^timecode[3]^timecode[4]^timecode[5]^timecode[6]^timecode[7]) != control[3])
begin
rx_error <= 1'b1;
end
else
begin
rx_error <= 1'b0;
end
end
else if(last_was_data == 1'b1)
begin
if(!(control[2]^data[0]^data[1]^data[2]^data[3]^data[4]^data[5]^data[6]^data[7]) != control[3])
begin
rx_error <= 1'b1;
end
else
begin
rx_error <= 1'b0;
end
end
end
else if(last_is_data == 1'b1)
begin
if(last_was_control == 1'b1)
begin
if(!(data[8]^control[1]^control[0]) != data[9])
begin
rx_error <= 1'b1;
end
else
begin
rx_error <= 1'b0;
end
end
else if(last_was_timec == 1'b1)
begin
if(!(data[8]^timecode[0]^timecode[1]^timecode[2]^timecode[3]^timecode[4]^timecode[5]^timecode[6]^timecode[7]) != data[9])
begin
rx_error <= 1'b1;
end
else
begin
rx_error <= 1'b0;
end
end
else if(last_was_data == 1'b1)
begin
if(!(data[8]^data[0]^data_l_r[1]^data_l_r[2]^data_l_r[3]^data_l_r[4]^data_l_r[5]^data_l_r[6]^data_l_r[7]) != data[9])
begin
rx_error <= 1'b1;
end
else
begin
rx_error <= 1'b0;
end
end
end
 
end
end
 
always@(posedge negedge_clk or negedge rx_resetn)
begin
 
if(!rx_resetn)
begin
rx_got_null <= 1'b0;
rx_got_nchar <= 1'b0;
rx_got_time_code <= 1'b0;
413,6 → 358,8
begin
if(is_control)
ready_control_p_r <= 1'b1;
else
ready_control_p_r <= 1'b0;
end
else
begin
423,6 → 370,8
begin
if(!is_control)
ready_data_p_r <= 1'b1;
else
ready_data_p_r <= 1'b0;
end
else
begin
441,11 → 390,12
if(!rx_resetn)
begin
control_r <= 4'd0;
parity_rec_c <= 1'b0;
end
else
begin
//if(is_control)
control_r <= {bit_c_3,bit_c_2,bit_c_1,bit_c_0};
control_r <= {bit_c_3,bit_c_2,bit_c_1,bit_c_0};
parity_rec_c <= bit_c_3;
end
end
 
454,11 → 404,11
if(!rx_resetn)
begin
control_p_r <= 4'd0;
end
else
begin
//if(is_control)
control_p_r <= control_r;
control_p_r <= control_r;
end
end
 
469,11 → 419,12
if(!rx_resetn)
begin
dta_timec <= 10'd0;
parity_rec_d <= 1'b0;
end
else
begin
//if(!is_control)
dta_timec <= {bit_d_9,bit_d_8,bit_d_0,bit_d_1,bit_d_2,bit_d_3,bit_d_4,bit_d_5,bit_d_6,bit_d_7};
dta_timec <= {bit_d_9,bit_d_8,bit_d_0,bit_d_1,bit_d_2,bit_d_3,bit_d_4,bit_d_5,bit_d_6,bit_d_7};
parity_rec_d <= bit_d_9;
end
end
 
486,11 → 437,52
end
else
begin
//if(!is_control)
dta_timec_p <= dta_timec;
dta_timec_p <= dta_timec;
end
end
 
always@(*)
begin
 
rx_error_d = 1'b0;
 
if(last_is_control && ready_data_p)
begin
if(!(dta_timec[8]^control[0]^control[1]) != parity_rec_d)
begin
rx_error_d = 1'b1;
end
end
else if(last_is_data && ready_data_p)
begin
if(!(dta_timec[8]^data[7]^data[6]^data[5]^data[4]^data[3]^data[2]^data[1]^data[0]) != parity_rec_d)
begin
rx_error_d = 1'b1;
end
end
end
 
always@(*)
begin
 
rx_error_c = 1'b0;
 
if(last_is_control && ready_control_p)
begin
if(!(control_r[2]^control[0]^control[1]) != parity_rec_c)
begin
rx_error_c = 1'b1;
end
end
else if(last_is_data && ready_control_p)
begin
if(!(control_r[2]^data[7]^data[6]^data[5]^data[4]^data[3]^data[2]^data[1]^data[0]) != parity_rec_c)
begin
rx_error_c = 1'b1;
end
end
end
 
always@(posedge negedge_clk or negedge rx_resetn)
begin
 
558,104 → 550,170
end
end
 
always@(posedge posedge_clk or negedge rx_resetn )
always@(*)
begin
 
next_state_data_process = state_data_process;
 
case(state_data_process)
2'd0:
begin
if(ready_control_p_r || ready_data_p_r)
begin
next_state_data_process = 2'd1;
end
else
begin
next_state_data_process = 2'd0;
end
end
2'd1:
begin
next_state_data_process = 2'd0;
end
default:
begin
next_state_data_process = 2'd0;
end
endcase
end
 
 
always@(posedge negedge_clk or negedge rx_resetn )
begin
 
if(!rx_resetn)
begin
control_l_r <= 4'd0;
control <= 4'd0;
data <= 10'd0;
//data_l_r <= 10'd0;
 
control_l_r <= 4'd0;
control <= 4'd0;
data <= 10'd0;
data_l_r <= 10'd0;
rx_data_flag <= 9'd0;
rx_data_take <= 1'b0;
last_is_control <= 1'b0;
last_is_data <= 1'b0;
last_is_timec <= 1'b0;
 
//last_was_control <= 1'b0;
//last_was_data <= 1'b0;
//last_was_timec <= 1'b0;
 
timecode <= 10'd0;
rx_tick_out <= 1'b0;
rx_data_flag <= 9'd0;
rx_data_take <= 1'b0;
 
last_is_control <= 1'b0;
last_is_data <= 1'b0;
last_is_timec <= 1'b0;
timecode <= 10'd0;
rx_tick_out <= 1'b0;
 
last_was_control <= 1'b0;
last_was_data <= 1'b0;
last_was_timec <= 1'b0;
state_data_process <= 2'd0;
end
else
begin
 
if(ready_control_p_r)
begin
control <= control_p_r;
control_l_r <= control;
state_data_process <= next_state_data_process;
 
last_is_control <= 1'b1;
last_is_data <= 1'b0;
last_is_timec <= 1'b0;
last_was_control <= last_is_control;
last_was_data <= last_is_data ;
last_was_timec <= last_is_timec;
end
else if(ready_data_p_r)
case(state_data_process)
2'd0:
begin
 
if(control[2:0] != 3'd7)
if(ready_control_p_r)
begin
rx_data_flag <= {dta_timec_p[8],dta_timec_p[7],dta_timec_p[6],dta_timec_p[5],dta_timec_p[4],dta_timec_p[3],dta_timec_p[2],dta_timec_p[1],dta_timec_p[0]};
data <= {dta_timec_p[9],dta_timec_p[8],dta_timec_p[7],dta_timec_p[6],dta_timec_p[5],dta_timec_p[4],dta_timec_p[3],dta_timec_p[2],dta_timec_p[1],dta_timec_p[0]};
data_l_r <= data;
last_is_control <=1'b0;
last_is_data <=1'b1;
last_is_timec <=1'b0;
last_was_control <= last_is_control;
last_was_data <= last_is_data ;
last_was_timec <= last_is_timec;
control <= control_p_r;
control_l_r <= control;
 
last_is_control <= 1'b1;
last_is_data <= 1'b0;
last_is_timec <= 1'b0;
//last_was_control <= last_is_control;
//last_was_data <= last_is_data ;
//last_was_timec <= last_is_timec;
 
rx_data_take <= 1'b0;
rx_tick_out <= 1'b0;
 
end
else if(control[2:0] == 3'd7)
else if(ready_data_p_r)
begin
timecode <= dta_timec;
last_is_control <= 1'b0;
last_is_data <= 1'b0;
last_is_timec <= 1'b1;
last_was_control <= last_is_control;
last_was_data <= last_is_data ;
last_was_timec <= last_is_timec;
if(control[2:0] != 3'd7)
begin
data <= {dta_timec_p[9],dta_timec_p[8],dta_timec_p[7],dta_timec_p[6],dta_timec_p[5],dta_timec_p[4],dta_timec_p[3],dta_timec_p[2],dta_timec_p[1],dta_timec_p[0]};
//data_l_r <= data;
last_is_control <=1'b0;
last_is_data <=1'b1;
last_is_timec <=1'b0;
//last_was_control <= last_is_control;
//last_was_data <= last_is_data ;
//last_was_timec <= last_is_timec;
end
else if(control[2:0] == 3'd7)
begin
last_is_control <= 1'b0;
last_is_data <= 1'b0;
last_is_timec <= 1'b1;
//last_was_control <= last_is_control;
//last_was_data <= last_is_data ;
//last_was_timec <= last_is_timec;
end
 
rx_data_take <= 1'b0;
rx_tick_out <= 1'b0;
end
else
begin
timecode <= timecode;
end
end
else if(last_is_timec == 1'b1)
2'd1:
begin
rx_data_take <= 1'b0;
rx_tick_out <= 1'b1;
end
else if(last_is_data == 1'b1)
begin
 
rx_tick_out <= 1'b0;
rx_data_take <= 1'b1;
end
else if(last_is_control == 1'b1)
begin
 
if(control[2:0] == 3'd6)
if(last_is_timec == 1'b1)
begin
rx_data_flag <= 9'd257;
rx_data_take <= 1'b1;
timecode <= dta_timec;
rx_tick_out <= 1'b1;
end
else if(control[2:0] == 3'd5)
else if(last_is_data == 1'b1)
begin
rx_data_flag <= 9'd256;
rx_data_flag <= {data[8],data[7],data[6],data[5],data[4],data[3],data[2],data[1],data[0]};
rx_data_take <= 1'b1;
end
else if(last_is_control == 1'b1)
begin
if(control[2:0] == 3'd6)
begin
rx_data_flag <= 9'd257;
rx_data_take <= 1'b1;
end
else if(control[2:0] == 3'd5)
begin
rx_data_flag <= 9'd256;
rx_data_take <= 1'b1;
end
else
begin
rx_data_take <= rx_data_take;
rx_tick_out <= rx_tick_out;
end
end
else
begin
rx_data_take <= 1'b0;
 
rx_data_flag <= rx_data_flag;
rx_data_take <= rx_data_take;
 
timecode <= timecode;
rx_tick_out <= rx_tick_out;
end
 
rx_tick_out <= 1'b0;
end
default:
begin
rx_data_flag <= rx_data_flag;
rx_data_take <= rx_data_take;
 
timecode <= timecode;
rx_tick_out <= rx_tick_out;
end
endcase
end
end
 
/trunk/rtl/RTL_VB/spw_ulight_con_top_x.v
89,7 → 89,7
wire [8:0] top_tx_data_w;
wire tx_reset_n;
 
assign tx_reset_n = (top_fsm != 6'd16 | !reset_spw_n_b)?1'b0:1'b1;
assign tx_reset_n = (!reset_spw_n_b)?1'b0:1'b1;
 
//assign time_out = time_out_w;
assign datarx_flag = datarx_flag_axi;
/trunk/rtl/RTL_VB/tx_spw.v
58,10 → 58,13
 
);
 
localparam [2:0] tx_spw_start = 3'b000,
tx_spw_null = 3'b001,
tx_spw_null_fct = 3'b010,
tx_spw_full = 3'b100;
localparam [6:0] tx_spw_start = 7'b0000000,
tx_spw_null = 7'b0000001,
tx_spw_fct = 7'b0000010,
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,
FCT = 6'b000010,
79,9 → 82,15
 
 
 
reg [2:0] state_tx;
reg [2:0] next_state_tx;
reg [6:0] 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 [5:0] last_type;
92,22 → 101,19
reg [7:0] tx_tcode_in;
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_flag;
 
reg [5:0] fct_counter;
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_sout;
 
119,347 → 125,332
reg tx_dout_timecode;
reg tx_dout_data;
 
reg block_sum;
reg block_sum_fct_send;
 
reg [3:0] global_counter_transfer;
 
always@(*)
begin
tx_dout_null = last_tx_dout;
 
if(enable_null)
begin
if(last_type == NULL && global_counter_transfer[3:0] == 4'd0)
begin
tx_dout_null = !(null_s[6]^null_s[0]^null_s[1]);
end
else if(last_type == FCT && global_counter_transfer[3:0] == 4'd0)
begin
tx_dout_null = !(null_s[6]^fct_s[0]^fct_s[1]);
end
else if(last_type == EOP && global_counter_transfer[3:0] == 4'd0)
begin
tx_dout_null = !(null_s[6]^eop_s[0]^eop_s[1]);
end
else if(last_type == EEP && global_counter_transfer[3:0] == 4'd0)
begin
tx_dout_null = !(null_s[6]^eep_s[0]^eep_s[1]);
end
else if(last_type == DATA && global_counter_transfer[3:0] == 4'd0)
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]);
end
else if(last_type == TIMEC && global_counter_transfer[3:0] == 4'd0)
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]);
end
else if(global_counter_transfer[3:0] == 4'd1)
begin
tx_dout_null = null_s[6];
end
else if(global_counter_transfer[3:0] == 4'd2)
begin
tx_dout_null = null_s[5];
end
else if(global_counter_transfer[3:0] == 4'd3)
begin
tx_dout_null = null_s[4];
end
else if(global_counter_transfer[3:0] == 4'd4)
begin
tx_dout_null = null_s[3];
end
else if(global_counter_transfer[3:0] == 4'd5)
begin
tx_dout_null = null_s[2];
end
else if(global_counter_transfer[3:0] == 4'd6)
begin
tx_dout_null = null_s[1];
end
else if(global_counter_transfer[3:0] == 4'd7)
begin
tx_dout_null = null_s[0];
end
end
end
 
 
always@(*)
begin
tx_dout = last_tx_dout;
 
tx_dout_fct = last_tx_dout;
if(enable_fct)
begin
 
if(last_type == NULL && global_counter_transfer[3:0] == 4'd0)
begin
tx_dout_fct = !(fct_s[2]^null_s[0]^null_s[1]);
end
else if(last_type == FCT && global_counter_transfer[3:0] == 4'd0)
begin
tx_dout_fct = !(fct_s[2]^fct_s[0]^fct_s[1]);
end
else if(last_type == EOP && global_counter_transfer[3:0] == 4'd0)
begin
tx_dout_fct = !(fct_s[2]^eop_s[0]^eop_s[1]);
end
else if(last_type == EEP && global_counter_transfer[3:0] == 4'd0)
begin
tx_dout_fct = !(fct_s[2]^eep_s[0]^eep_s[1]);
end
else if (last_type == DATA && global_counter_transfer[3:0] == 4'd0)
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]);
end
else if(last_type == TIMEC && global_counter_transfer[3:0] == 4'd0)
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]);
end
else if(global_counter_transfer[3:0] == 4'd1)
begin
tx_dout_fct = fct_s[2];
end
else if(global_counter_transfer[3:0] == 4'd2)
begin
tx_dout_fct = fct_s[1];
end
else if(global_counter_transfer[3:0] == 4'd3)
begin
tx_dout_fct = fct_s[0];
end
 
end
case(state_tx)
tx_spw_start:
begin
end
tx_spw_null,tx_spw_null_c:
begin
if(last_type == NULL && global_counter_transfer[3:0] == 4'd0)
begin
tx_dout = !(null_s[6]^null_s[0]^null_s[1]);
end
else if(last_type == FCT && global_counter_transfer[3:0] == 4'd0)
begin
tx_dout = !(null_s[6]^fct_s[0]^fct_s[1]);
end
else if(last_type == EOP && global_counter_transfer[3:0] == 4'd0)
begin
tx_dout = !(null_s[6]^eop_s[0]^eop_s[1]);
end
else if(last_type == EEP && global_counter_transfer[3:0] == 4'd0)
begin
tx_dout = !(null_s[6]^eep_s[0]^eep_s[1]);
end
else if(last_type == DATA && global_counter_transfer[3:0] == 4'd0)
begin
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
else if(last_type == TIMEC && global_counter_transfer[3:0] == 4'd0)
begin
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
else if(global_counter_transfer[3:0] == 4'd1)
begin
tx_dout = null_s[6];
end
else if(global_counter_transfer[3:0] == 4'd2)
begin
tx_dout = null_s[5];
end
else if(global_counter_transfer[3:0] == 4'd3)
begin
tx_dout = null_s[4];
end
else if(global_counter_transfer[3:0] == 4'd4)
begin
tx_dout = null_s[3];
end
else if(global_counter_transfer[3:0] == 4'd5)
begin
tx_dout = null_s[2];
end
else if(global_counter_transfer[3:0] == 4'd6)
begin
tx_dout = null_s[1];
end
else if(global_counter_transfer[3:0] == 4'd7)
begin
tx_dout = null_s[0];
end
end
tx_spw_fct,tx_spw_fct_c:
begin
if(last_type == NULL && global_counter_transfer[3:0] == 4'd0)
begin
tx_dout = !(fct_s[2]^null_s[0]^null_s[1]);
end
else if(last_type == FCT && global_counter_transfer[3:0] == 4'd0)
begin
tx_dout = !(fct_s[2]^fct_s[0]^fct_s[1]);
end
else if(last_type == EOP && global_counter_transfer[3:0] == 4'd0)
begin
tx_dout = !(fct_s[2]^eop_s[0]^eop_s[1]);
end
else if(last_type == EEP && global_counter_transfer[3:0] == 4'd0)
begin
tx_dout = !(fct_s[2]^eep_s[0]^eep_s[1]);
end
else if (last_type == DATA && global_counter_transfer[3:0] == 4'd0)
begin
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
else if(last_type == TIMEC && global_counter_transfer[3:0] == 4'd0)
begin
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
else if(global_counter_transfer[3:0] == 4'd1)
begin
tx_dout = fct_s[2];
end
else if(global_counter_transfer[3:0] == 4'd2)
begin
tx_dout = fct_s[1];
end
else if(global_counter_transfer[3:0] == 4'd3)
begin
tx_dout = fct_s[0];
end
end
tx_spw_data_c:
begin
if(!tx_data_in[8] && last_type == NULL && global_counter_transfer[3:0] == 4'd0)
begin
tx_dout = !(tx_data_in[8]^null_s[0]^null_s[1]);
end
else if(!tx_data_in[8] && last_type == FCT && global_counter_transfer[3:0] == 4'd0)
begin
tx_dout = !(tx_data_in[8]^fct_s[0]^fct_s[1]);
end
else if(!tx_data_in[8] && last_type == EOP && global_counter_transfer[3:0] == 4'd0)
begin
tx_dout = !(tx_data_in[8]^eop_s[0]^eop_s[1]);
end
else if(!tx_data_in[8] && last_type == EEP && global_counter_transfer[3:0] == 4'd0)
begin
tx_dout = !(tx_data_in[8]^eep_s[0]^eep_s[1]);
end
else if(!tx_data_in[8] && last_type == DATA && global_counter_transfer[3:0] == 4'd0)
begin
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
else if(!tx_data_in[8] && last_type == TIMEC && global_counter_transfer[3:0] == 4'd0)
begin
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
else if(tx_data_in[8] && tx_data_in[1:0] == 2'b00 && last_type == NULL && global_counter_transfer[3:0] == 4'd0)
begin
tx_dout = !(eop_s[2]^null_s[0]^null_s[1]);
end
else if(tx_data_in[8] && tx_data_in[1:0] == 2'b00 && last_type == FCT && global_counter_transfer[3:0] == 4'd0)
begin
tx_dout = !(eop_s[2]^fct_s[0]^fct_s[1]);
end
else if(tx_data_in[8] && tx_data_in[1:0] == 2'b00 && last_type == EOP && global_counter_transfer[3:0] == 4'd0)
begin
tx_dout = !(eop_s[2]^eop_s[0]^eop_s[1]);
end
else if(tx_data_in[8] && tx_data_in[1:0] == 2'b00 && last_type == EEP && global_counter_transfer[3:0] == 4'd0)
begin
tx_dout = !(eop_s[2]^eep_s[0]^eep_s[1]);
end
else if(tx_data_in[8] && tx_data_in[1:0] == 2'b00 && last_type == DATA && global_counter_transfer[3:0] == 4'd0)
begin
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
else if(tx_data_in[8] && tx_data_in[1:0] == 2'b00 && last_type == TIMEC && global_counter_transfer[3:0] == 4'd0)
begin
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
else if(tx_data_in[8] && tx_data_in[1:0] == 2'b01 && last_type == NULL && global_counter_transfer[3:0] == 4'd0)
begin
tx_dout = !(eep_s[2]^null_s[0]^null_s[1]);
end
else if(tx_data_in[8] && tx_data_in[1:0] == 2'b01 && last_type == FCT && global_counter_transfer[3:0] == 4'd0)
begin
tx_dout = !(eep_s[2]^fct_s[0]^fct_s[1]);
end
else if(tx_data_in[8] && tx_data_in[1:0] == 2'b01 && last_type == EOP && global_counter_transfer[3:0] == 4'd0)
begin
tx_dout = !(eep_s[2]^eop_s[0]^eop_s[1]);
end
else if(tx_data_in[8] && tx_data_in[1:0] == 2'b01 && last_type == EEP && global_counter_transfer[3:0] == 4'd0)
begin
tx_dout = !(eep_s[2]^eep_s[0]^eep_s[1]);
end
else if(tx_data_in[8] && tx_data_in[1:0] == 2'b01 && last_type == DATA && global_counter_transfer[3:0] == 4'd0)
begin
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
else if(tx_data_in[8] && tx_data_in[1:0] == 2'b01 && last_type == TIMEC && global_counter_transfer[3:0] == 4'd0)
begin
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
else if(!tx_data_in[8] && global_counter_transfer[3:0] == 4'd1)
begin
tx_dout = tx_data_in[8];
end
else if(!tx_data_in[8] && global_counter_transfer[3:0] == 4'd2)
begin
tx_dout = tx_data_in[0];
end
else if(!tx_data_in[8] && global_counter_transfer[3:0] == 4'd3)
begin
tx_dout = tx_data_in[1];
end
else if(!tx_data_in[8] && global_counter_transfer[3:0] == 4'd4)
begin
tx_dout = tx_data_in[2];
end
else if(!tx_data_in[8] && global_counter_transfer[3:0] == 4'd5)
begin
tx_dout = tx_data_in[3];
end
else if(!tx_data_in[8] && global_counter_transfer[3:0] == 4'd6)
begin
tx_dout = tx_data_in[4];
end
else if(!tx_data_in[8] && global_counter_transfer[3:0] == 4'd7)
begin
tx_dout = tx_data_in[5];
end
else if(!tx_data_in[8] && global_counter_transfer[3:0] == 4'd8)
begin
tx_dout = tx_data_in[6];
end
else if(!tx_data_in[8] && global_counter_transfer[3:0] == 4'd9)
begin
tx_dout = tx_data_in[7];
end
else if(tx_data_in[8] && tx_data_in[1:0] == 2'b01 && global_counter_transfer[3:0] == 4'd1)
begin
tx_dout = eep_s[2];
end
else if( tx_data_in[8] && tx_data_in[1:0] == 2'b01 && global_counter_transfer[3:0] == 4'd2)
begin
tx_dout = eep_s[1];
end
else if(tx_data_in[8] && tx_data_in[1:0] == 2'b01 && global_counter_transfer[3:0] == 4'd3)
begin
tx_dout = eep_s[0];
end
else if(tx_data_in[8] && tx_data_in[1:0] == 2'b00 && global_counter_transfer[3:0] == 4'd1)
begin
tx_dout = eop_s[2];
end
else if(tx_data_in[8] && tx_data_in[1:0] == 2'b00 && global_counter_transfer[3:0] == 4'd2)
begin
tx_dout = eop_s[1];
end
else if(tx_data_in[8] && tx_data_in[1:0] == 2'b00 && global_counter_transfer[3:0] == 4'd3)
begin
tx_dout = eop_s[0];
end
end
tx_spw_time_code_c:
begin
if(last_type == NULL && global_counter_transfer[3:0] == 4'd0)
begin
tx_dout = !(timecode_s[12]^null_s[0]^null_s[1]);
end
else if(last_type == FCT && global_counter_transfer[3:0] == 4'd0)
begin
tx_dout = !(timecode_s[12]^fct_s[0]^fct_s[1]);
end
else if (last_type == EOP && global_counter_transfer[3:0] == 4'd0)
begin
tx_dout = !(timecode_s[12]^eop_s[0]^eop_s[1]);
end
else if( last_type == EEP && global_counter_transfer[3:0] == 4'd0)
begin
tx_dout = !(timecode_s[12]^eep_s[0]^eep_s[1]);
end
else if( last_type == DATA && global_counter_transfer[3:0] == 4'd0)
begin
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
else if( last_type == TIMEC && global_counter_transfer[3:0] == 4'd0)
begin
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
else if( global_counter_transfer[3:0] == 4'd1)
begin
tx_dout = timecode_s[12];
end
else if( global_counter_transfer[3:0] == 4'd2)
begin
tx_dout = timecode_s[11];
end
else if( global_counter_transfer[3:0] == 4'd3)
begin
tx_dout = timecode_s[10];
end
else if( global_counter_transfer[3:0] == 4'd4)
begin
tx_dout = timecode_s[9];
end
else if( global_counter_transfer[3:0] == 4'd5)
begin
tx_dout = timecode_s[8];
end
else if( global_counter_transfer[3:0] == 4'd6)
begin
tx_dout = timecode_s[0];
end
else if( global_counter_transfer[3:0] == 4'd7)
begin
tx_dout = timecode_s[1];
end
else if( global_counter_transfer[3:0] == 4'd8)
begin
tx_dout = timecode_s[2];
end
else if(global_counter_transfer[3:0] == 4'd9)
begin
tx_dout = timecode_s[3];
end
else if(global_counter_transfer[3:0] == 4'd10)
begin
tx_dout = timecode_s[4];
end
else if(global_counter_transfer[3:0] == 4'd11)
begin
tx_dout = timecode_s[5];
end
else if( global_counter_transfer[3:0] == 4'd12)
begin
tx_dout = timecode_s[6];
end
else if(global_counter_transfer[3:0] == 4'd13)
begin
tx_dout = timecode_s[7];
end
end
default:
begin
end
endcase
end
 
always@(*)
begin
tx_dout_timecode = last_tx_dout;
 
if(enable_time_code)
begin
if(last_type == NULL && global_counter_transfer[3:0] == 4'd0)
begin
tx_dout_timecode = !(timecode_s[12]^null_s[0]^null_s[1]);
end
else if(last_type == FCT && global_counter_transfer[3:0] == 4'd0)
begin
tx_dout_timecode = !(timecode_s[12]^fct_s[0]^fct_s[1]);
end
else if (last_type == EOP && global_counter_transfer[3:0] == 4'd0)
begin
tx_dout_timecode = !(timecode_s[12]^eop_s[0]^eop_s[1]);
end
else if( last_type == EEP && global_counter_transfer[3:0] == 4'd0)
begin
tx_dout_timecode = !(timecode_s[12]^eep_s[0]^eep_s[1]);
end
else if( last_type == DATA && global_counter_transfer[3:0] == 4'd0)
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]);
end
else if( last_type == TIMEC && global_counter_transfer[3:0] == 4'd0)
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]);
end
else if( global_counter_transfer[3:0] == 4'd1)
begin
tx_dout_timecode = timecode_s[12];
end
else if( global_counter_transfer[3:0] == 4'd2)
begin
tx_dout_timecode = timecode_s[11];
end
else if( global_counter_transfer[3:0] == 4'd3)
begin
tx_dout_timecode = timecode_s[10];
end
else if( global_counter_transfer[3:0] == 4'd4)
begin
tx_dout_timecode = timecode_s[9];
end
else if( global_counter_transfer[3:0] == 4'd5)
begin
tx_dout_timecode = timecode_s[8];
end
else if( global_counter_transfer[3:0] == 4'd6)
begin
tx_dout_timecode = timecode_s[0];
end
else if( global_counter_transfer[3:0] == 4'd7)
begin
tx_dout_timecode = timecode_s[1];
end
else if( global_counter_transfer[3:0] == 4'd8)
begin
tx_dout_timecode = timecode_s[2];
end
else if(global_counter_transfer[3:0] == 4'd9)
begin
tx_dout_timecode = timecode_s[3];
end
else if(global_counter_transfer[3:0] == 4'd10)
begin
tx_dout_timecode = timecode_s[4];
end
else if(global_counter_transfer[3:0] == 4'd11)
begin
tx_dout_timecode = timecode_s[5];
end
else if( global_counter_transfer[3:0] == 4'd12)
begin
tx_dout_timecode = timecode_s[6];
end
else if(global_counter_transfer[3:0] == 4'd13)
begin
tx_dout_timecode = timecode_s[7];
end
end
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
tx_dout_data = !(tx_data_in[8]^null_s[0]^null_s[1]);
end
else if(!tx_data_in[8] && last_type == FCT && global_counter_transfer[3:0] == 4'd0)
begin
tx_dout_data = !(tx_data_in[8]^fct_s[0]^fct_s[1]);
end
else if(!tx_data_in[8] && last_type == EOP && global_counter_transfer[3:0] == 4'd0)
begin
tx_dout_data = !(tx_data_in[8]^eop_s[0]^eop_s[1]);
end
else if(!tx_data_in[8] && last_type == EEP && global_counter_transfer[3:0] == 4'd0)
begin
tx_dout_data = !(tx_data_in[8]^eep_s[0]^eep_s[1]);
end
else if(!tx_data_in[8] && last_type == DATA && global_counter_transfer[3:0] == 4'd0)
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]);
end
else if(!tx_data_in[8] && last_type == TIMEC && global_counter_transfer[3:0] == 4'd0)
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]);
end
else if(tx_data_in[8] && tx_data_in[1:0] == 2'b00 && last_type == NULL && global_counter_transfer[3:0] == 4'd0)
begin
tx_dout_data = !(eop_s[2]^null_s[0]^null_s[1]);
end
else if(tx_data_in[8] && tx_data_in[1:0] == 2'b00 && last_type == FCT && global_counter_transfer[3:0] == 4'd0)
begin
tx_dout_data = !(eop_s[2]^fct_s[0]^fct_s[1]);
end
else if(tx_data_in[8] && tx_data_in[1:0] == 2'b00 && last_type == EOP && global_counter_transfer[3:0] == 4'd0)
begin
tx_dout_data = !(eop_s[2]^eop_s[0]^eop_s[1]);
end
else if(tx_data_in[8] && tx_data_in[1:0] == 2'b00 && last_type == EEP && global_counter_transfer[3:0] == 4'd0)
begin
tx_dout_data = !(eop_s[2]^eep_s[0]^eep_s[1]);
end
else if(tx_data_in[8] && tx_data_in[1:0] == 2'b00 && last_type == DATA && global_counter_transfer[3:0] == 4'd0)
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]);
end
else if(tx_data_in[8] && tx_data_in[1:0] == 2'b00 && last_type == TIMEC && global_counter_transfer[3:0] == 4'd0)
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]);
end
else if(tx_data_in[8] && tx_data_in[1:0] == 2'b01 && last_type == NULL && global_counter_transfer[3:0] == 4'd0)
begin
tx_dout_data = !(eep_s[2]^null_s[0]^null_s[1]);
end
else if(tx_data_in[8] && tx_data_in[1:0] == 2'b01 && last_type == FCT && global_counter_transfer[3:0] == 4'd0)
begin
tx_dout_data = !(eep_s[2]^fct_s[0]^fct_s[1]);
end
else if(tx_data_in[8] && tx_data_in[1:0] == 2'b01 && last_type == EOP && global_counter_transfer[3:0] == 4'd0)
begin
tx_dout_data = !(eep_s[2]^eop_s[0]^eop_s[1]);
end
else if(tx_data_in[8] && tx_data_in[1:0] == 2'b01 && last_type == EEP && global_counter_transfer[3:0] == 4'd0)
begin
tx_dout_data = !(eep_s[2]^eep_s[0]^eep_s[1]);
end
else if(tx_data_in[8] && tx_data_in[1:0] == 2'b01 && last_type == DATA && global_counter_transfer[3:0] == 4'd0)
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]);
end
else if(tx_data_in[8] && tx_data_in[1:0] == 2'b01 && last_type == TIMEC && global_counter_transfer[3:0] == 4'd0)
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]);
end
else if(!tx_data_in[8] && global_counter_transfer[3:0] == 4'd1)
begin
tx_dout_data = tx_data_in[8];
end
else if(!tx_data_in[8] && global_counter_transfer[3:0] == 4'd2)
begin
tx_dout_data = tx_data_in[0];
end
else if(!tx_data_in[8] && global_counter_transfer[3:0] == 4'd3)
begin
tx_dout_data = tx_data_in[1];
end
else if(!tx_data_in[8] && global_counter_transfer[3:0] == 4'd4)
begin
tx_dout_data = tx_data_in[2];
end
else if(!tx_data_in[8] && global_counter_transfer[3:0] == 4'd5)
begin
tx_dout_data = tx_data_in[3];
end
else if(!tx_data_in[8] && global_counter_transfer[3:0] == 4'd6)
begin
tx_dout_data = tx_data_in[4];
end
else if(!tx_data_in[8] && global_counter_transfer[3:0] == 4'd7)
begin
tx_dout_data = tx_data_in[5];
end
else if(!tx_data_in[8] && global_counter_transfer[3:0] == 4'd8)
begin
tx_dout_data = tx_data_in[6];
end
else if(!tx_data_in[8] && global_counter_transfer[3:0] == 4'd9)
begin
tx_dout_data = tx_data_in[7];
end
else if(tx_data_in[8] && tx_data_in[1:0] == 2'b01 && global_counter_transfer[3:0] == 4'd1)
begin
tx_dout_data = eep_s[2];
end
else if( tx_data_in[8] && tx_data_in[1:0] == 2'b01 && global_counter_transfer[3:0] == 4'd2)
begin
tx_dout_data = eep_s[1];
end
else if(tx_data_in[8] && tx_data_in[1:0] == 2'b01 && global_counter_transfer[3:0] == 4'd3)
begin
tx_dout_data = eep_s[0];
end
else if(tx_data_in[8] && tx_data_in[1:0] == 2'b00 && global_counter_transfer[3:0] == 4'd1)
begin
tx_dout_data = eop_s[2];
end
else if(tx_data_in[8] && tx_data_in[1:0] == 2'b00 && global_counter_transfer[3:0] == 4'd2)
begin
tx_dout_data = eop_s[1];
end
else if(tx_data_in[8] && tx_data_in[1:0] == 2'b00 && global_counter_transfer[3:0] == 4'd3)
begin
tx_dout_data = eop_s[0];
end
end
end
//strobe
always@(*)
begin
466,11 → 457,11
 
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
tx_sout = !last_tx_sout;
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
tx_sout = last_tx_sout;
end
478,88 → 469,248
 
always@(*)
begin
fct_counter = 6'd0;
next_state_fct_send = state_fct_send;
 
if(gotfct_tx)
case(state_fct_send)
3'd0:
begin
if(block_sum)
if(send_fct_now)
begin
 
next_state_fct_send = 3'd1;
end
else
else if(fct_sent)
begin
if(fct_counter_receive < 6'd48)
begin
fct_counter = fct_counter_receive + 6'd8;
end
else
begin
fct_counter = fct_counter_receive + 6'd7;
end
next_state_fct_send = 3'd3;
end
else
next_state_fct_send = 3'd0;
end
3'd1:
begin
if(global_counter_transfer == 4'd2)
begin
next_state_fct_send = 3'd2;
end
else
begin
next_state_fct_send = 3'd1;
end
end
3'd2:
begin
if(send_fct_now)
begin
next_state_fct_send = 3'd2;
end
else
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
else
begin
next_state_fct_send = 3'd3;
end
end
3'd4:
begin
if(fct_sent)
begin
next_state_fct_send = 3'd4;
end
else
begin
next_state_fct_send = 3'd0;
end
end
default:
begin
next_state_fct_send = 3'd0;
end
endcase
end
 
//slots open in our side
always@(*)
always@(posedge pclk_tx or negedge enable_tx)
begin
if(!enable_tx)
begin
fct_flag <= 3'd7;
state_fct_send<= 3'd0;
end
else
begin
state_fct_send <= next_state_fct_send;
 
fct_send = {3{1'b0}};
 
if(send_fct_now)
begin
if(block_sum_fct_send)
case(state_fct_send)
3'd0:
begin
 
fct_flag <= fct_flag;
end
else
3'd1:
begin
if(fct_flag == 3'd7)
begin
fct_send = 3'd0;
end
if(global_counter_transfer == 4'd2)
fct_flag <= fct_flag + 3'd1;
else
begin
fct_send = fct_flag + 3'd1;
end
fct_flag <= fct_flag;
end
3'd2:
begin
fct_flag <= fct_flag;
end
3'd3:
begin
if(global_counter_transfer == 4'd2)
fct_flag <= fct_flag - 3'd1;
else
fct_flag <= fct_flag;
end
3'd4:
begin
fct_flag <= fct_flag;
end
default:
begin
fct_flag <= fct_flag;
end
endcase
end
end
 
 
always@(*)
begin
next_state_fct_receive = state_fct_receive;
 
tx_dout = last_tx_dout;
 
if(enable_null)
case(state_fct_receive)
3'd0:
begin
tx_dout = tx_dout_null;
if(gotfct_tx)
begin
next_state_fct_receive = 3'd1;
end
else if(char_sent)
begin
next_state_fct_receive = 3'd3;
end
else
next_state_fct_receive = 3'd0;
end
else if(enable_fct)
3'd1:
begin
tx_dout = tx_dout_fct;
if(global_counter_transfer == 4'd2)
begin
next_state_fct_receive = 3'd2;
end
else
begin
next_state_fct_receive = 3'd1;
end
end
else if(enable_time_code)
3'd2:
begin
tx_dout = tx_dout_timecode;
if(gotfct_tx)
begin
next_state_fct_receive = 3'd2;
end
else
begin
next_state_fct_receive = 3'd0;
end
end
else if(enable_n_char)
3'd3:
begin
tx_dout = tx_dout_data;
if(global_counter_transfer == 4'd2)
begin
next_state_fct_receive = 3'd4;
end
else
begin
next_state_fct_receive = 3'd3;
end
end
3'd4:
begin
if(char_sent)
begin
next_state_fct_receive = 3'd4;
end
else
begin
next_state_fct_receive = 3'd0;
end
end
default:
begin
next_state_fct_receive = 3'd0;
end
endcase
end
 
always@(*)
 
always@(posedge pclk_tx or negedge enable_tx)
begin
if(!enable_tx)
begin
fct_counter_receive<= 6'd0;
state_fct_receive <= 3'd0;
end
else
begin
 
state_fct_receive <= next_state_fct_receive;
 
enable_null = hold_null;
enable_fct = hold_fct;
enable_n_char = hold_data;
enable_time_code = hold_time_code;
case(state_fct_receive)
3'd0:
begin
fct_counter_receive <= fct_counter_receive;
end
3'd1:
begin
if(global_counter_transfer == 4'd2)
begin
if(fct_counter_receive < 6'd48)
begin
fct_counter_receive <= fct_counter_receive + 6'd8;
end
else
begin
fct_counter_receive <= fct_counter_receive + 6'd7;
end
end
else
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
 
always@(*)
begin
next_state_tx = state_tx;
 
case(state_tx)
576,63 → 727,166
end
tx_spw_null:
begin
enable_null = 1'b1;
 
if(!hold_null)
if(send_null_tx && send_fct_tx && enable_tx)
begin
if(send_null_tx && send_fct_tx && enable_tx)
next_state_tx = tx_spw_null_fct;
else
next_state_tx = tx_spw_null;
if(global_counter_transfer == 4'd7)
next_state_tx = tx_spw_fct;
end
 
else
next_state_tx = tx_spw_null;
end
tx_spw_null_fct:
tx_spw_fct:
begin
 
enable_null = 1'b1;
 
if(send_fct_tx && fct_flag > 0 && !hold_null)
if(send_fct_tx && fct_flag > 3'd0)
begin
next_state_tx = tx_spw_null_fct;
enable_null = 1'b0;
enable_fct = 1'b1;
next_state_tx = tx_spw_fct;
end
else
begin
enable_fct = 1'b0;
if(send_fct_tx && fct_counter_receive > 6'd0)
begin
next_state_tx = tx_spw_full;
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
else if(fct_flag > 3'd0 && !send_fct_now)
begin
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
else
begin
next_state_tx = tx_spw_null_c;
end
end
end
 
end
end
tx_spw_full:
tx_spw_null_c:
begin
if(tickin_tx && !ready_tx_timecode && tcode_rdy_trnsp &&!hold_null && !hold_fct && !hold_data)
if(global_counter_transfer == 4'd7)
begin
enable_time_code = 1'b1;
end
else if(fct_flag > 3'd0 && !hold_null && !hold_time_code && !hold_data)
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
enable_fct = 1'b1;
next_state_tx = tx_spw_null_c;
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
tx_spw_fct_c:
begin
if(global_counter_transfer == 4'd3)
begin
enable_n_char = 1'b1;
if(tickin_tx && !ready_tx_timecode && tcode_rdy_trnsp)
begin
next_state_tx = tx_spw_time_code_c;
end
else
begin
next_state_tx = tx_spw_null_c;
end
end
else
else
begin
enable_null = 1'b1;
next_state_tx = tx_spw_fct_c;
end
end
tx_spw_data_c:
begin
 
if(!tx_data_in[8])
begin
if(global_counter_transfer == 4'd9)
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
begin
next_state_tx = tx_spw_null_c;
end
end
else
next_state_tx = tx_spw_data_c;
end
else if(tx_data_in[8])
begin
if(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
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
 
end
tx_spw_time_code_c:
begin
if(global_counter_transfer == 4'd13)
begin
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_time_code_c;
end
end
default:
begin
next_state_tx = tx_spw_start;
end
endcase
 
end
 
 
 
always@(posedge pclk_tx or negedge enable_tx)
begin
if(!enable_tx)
639,16 → 893,10
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;
656,10 → 904,8
tx_data_in <= 9'd0;
last_timein_control_flag_tx <= 8'd0;
 
fct_counter_receive <= 6'd0;
block_sum <= 1'b0;
block_sum_fct_send <= 1'b0;
char_sent<= 1'b0;
fct_sent <= 1'b0;
 
last_tx_dout <= 1'b0;
last_tx_sout <= 1'b0;
677,18 → 923,22
end
else
begin
 
state_tx <= next_state_tx;
 
last_tx_dout <= tx_dout;
last_tx_sout <= tx_sout;
case(state_tx)
tx_spw_start:
begin
end
tx_spw_null:
begin
 
tx_dout_e <= last_tx_dout;
tx_sout_e <= last_tx_sout;
last_tx_dout <= tx_dout;
last_tx_sout <= tx_sout;
 
if(enable_null)
begin
tx_dout_e <= last_tx_dout;
tx_sout_e <= last_tx_sout;
 
 
if(txwrite_tx && global_counter_transfer == 4'd5)
begin
tx_data_in <= data_tx_i;
705,37 → 955,6
else
tx_tcode_in <= tx_tcode_in;
 
 
//hold_null <= 1'b0;
hold_fct <= 1'b0;
hold_data <= 1'b0;
hold_time_code <= 1'b0;
 
//
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;
//
if(send_fct_now && !block_sum_fct_send)
begin
fct_flag <= fct_send;
block_sum_fct_send<= 1'b1;
end
else if(!send_fct_now)
begin
block_sum_fct_send<= 1'b0;
end
else
block_sum_fct_send <= block_sum_fct_send;
 
if(global_counter_transfer == 4'd3)
begin
ready_tx_timecode <= 1'b0;
750,162 → 969,138
if(global_counter_transfer == 4'd7)
begin
last_type <= NULL;
hold_null <= 1'b0;
global_counter_transfer <= 4'd0;
end
else
begin
last_type <= last_type;
hold_null <= 1'b1;
global_counter_transfer <= global_counter_transfer + 4'd1;
end
end
else if(enable_fct)
tx_spw_fct:
begin
 
hold_null <= 1'b0;
//hold_fct <= 1'b0;
hold_data <= 1'b0;
hold_time_code <= 1'b0;
last_tx_dout <= tx_dout;
last_tx_sout <= tx_sout;
 
 
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;
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
fct_flag <= fct_flag - 3'd1;
last_type <=FCT;
global_counter_transfer <= 4'd0;
hold_fct <= 1'b0;
fct_sent <= 1'b0;
end
else
begin
 
if(send_fct_now && !block_sum_fct_send)
begin
fct_flag <= fct_send;
block_sum_fct_send<= 1'b1;
end
else if(!send_fct_now)
begin
block_sum_fct_send<= 1'b0;
end
if(fct_flag > 3'd0)
fct_sent <= 1'b1;
else
block_sum_fct_send <= block_sum_fct_send;
 
hold_fct <= 1'b1;
fct_sent <= fct_sent;
global_counter_transfer <= global_counter_transfer + 4'd1;
end
end
else if(enable_time_code)
tx_spw_null_c:
begin
 
if(txwrite_tx && global_counter_transfer == 4'd6)
last_tx_dout <= tx_dout;
last_tx_sout <= tx_sout;
 
tx_dout_e <= last_tx_dout;
tx_sout_e <= last_tx_sout;
 
 
if(txwrite_tx && global_counter_transfer == 4'd5)
begin
tx_data_in <= data_tx_i;
data_rdy_trnsp <= 1'b1;
tx_data_in <= data_tx_i;
end
else
tx_data_in <= tx_data_in;
 
hold_null <= 1'b0;
hold_fct <= 1'b0;
hold_data <= 1'b0;
//hold_time_code <= 1'b0;
if(gotfct_tx && !block_sum)
if(tickin_tx && global_counter_transfer == 4'd5)
begin
fct_counter_receive <= fct_counter;
block_sum<= 1'b1;
tx_tcode_in <= timecode_tx_i;
tcode_rdy_trnsp <= 1'b1;
end
else if(!gotfct_tx)
begin
block_sum<= 1'b0;
end
else
block_sum <= block_sum;
tx_tcode_in <= tx_tcode_in;
 
if(global_counter_transfer == 4'd13)
 
if(global_counter_transfer == 4'd3)
begin
hold_time_code <= 1'b0;
ready_tx_timecode <= 1'b1;
global_counter_transfer <= 4'd0;
char_sent <= 1'b0;
fct_sent <= 1'b0;
ready_tx_timecode <= 1'b0;
ready_tx_data <= 1'b0;
end
else
begin
hold_time_code <= 1'b0;
ready_tx_timecode <= 1'b0;
global_counter_transfer <= global_counter_transfer + 4'd1;
ready_tx_timecode <= ready_tx_timecode;
ready_tx_data <= ready_tx_data;
end
 
//
if(send_fct_now && !block_sum_fct_send)
if(global_counter_transfer == 4'd7)
begin
fct_flag <= fct_send;
block_sum_fct_send<= 1'b1;
last_type <= NULL;
global_counter_transfer <= 4'd0;
end
else if(!send_fct_now)
else
begin
block_sum_fct_send<= 1'b0;
last_type <= last_type;
global_counter_transfer <= global_counter_transfer + 4'd1;
end
else
block_sum_fct_send <= block_sum_fct_send;
end
tx_spw_fct_c:
begin
 
if(global_counter_transfer != 4'd13)
begin
timecode_s <= {timecode_ss[13:10],2'd2,tx_tcode_in[7:0]};
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
char_sent <= 1'b0;
last_type <=FCT;
fct_sent <= 1'b0;
global_counter_transfer <= 4'd0;
end
else
begin
ready_tx_data <= 1'b0;
last_timein_control_flag_tx <= tx_tcode_in;
last_type <= TIMEC;
if(fct_flag > 3'd0)
fct_sent <= 1'b1;
else
fct_sent <= fct_sent;
 
global_counter_transfer <= global_counter_transfer + 4'd1;
end
end
else if(enable_n_char)
tx_spw_data_c:
begin
hold_null <= 1'b0;
hold_fct <= 1'b0;
//hold_data <= 1'b0;
hold_time_code <= 1'b0;
//
if(send_fct_now && !block_sum_fct_send)
begin
fct_flag <= fct_send;
block_sum_fct_send<= 1'b1;
end
else if(!send_fct_now)
begin
block_sum_fct_send<= 1'b0;
end
else
block_sum_fct_send <= block_sum_fct_send;
 
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])
begin
 
if(global_counter_transfer == 4'd9)
begin
fct_counter_receive <= fct_counter_receive - 6'd1;
char_sent <= 1'b1;
 
last_type <= DATA;
 
hold_data <= 1'b0;
ready_tx_data <= 1'b1;
data_rdy_trnsp <= 1'b0;
global_counter_transfer <= 4'd0;
912,20 → 1107,7
end
else
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;
hold_data <= 1'b1;
ready_tx_timecode <= 1'b0;
global_counter_transfer <= global_counter_transfer + 4'd1;
end
940,7 → 1122,7
 
if(global_counter_transfer == 4'd3)
begin
fct_counter_receive <= fct_counter_receive - 6'd1;
char_sent <= 1'b1;
 
if(tx_data_in[1:0] == 2'b00)
begin
952,7 → 1134,6
end
 
global_counter_transfer <= 4'd0;
hold_data <= 1'b0;
data_rdy_trnsp <= 1'b0;
ready_tx_data <= 1'b1;
end
960,19 → 1141,6
begin
txdata_flagctrl_tx_last <= txdata_flagctrl_tx_last;
 
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;
 
hold_data <= 1'b1;
ready_tx_data <= 1'b0;
ready_tx_timecode <= 1'b0;
global_counter_transfer <= global_counter_transfer + 4'd1;
982,7 → 1150,59
end
 
end
tx_spw_time_code_c:
begin
 
if(txwrite_tx && global_counter_transfer == 4'd6)
begin
data_rdy_trnsp <= 1'b1;
tx_data_in <= data_tx_i;
end
else
tx_data_in <= tx_data_in;
 
 
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;
global_counter_transfer <= global_counter_transfer + 4'd1;
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
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
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.