Line 43... |
Line 43... |
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
//
|
//
|
// CVS Revision History
|
// CVS Revision History
|
//
|
//
|
// $Log: not supported by cvs2svn $
|
// $Log: not supported by cvs2svn $
|
|
// Revision 1.16 2003/02/04 14:34:52 mohor
|
|
// *** empty log message ***
|
|
//
|
// Revision 1.15 2003/01/31 01:13:37 mohor
|
// Revision 1.15 2003/01/31 01:13:37 mohor
|
// backup.
|
// backup.
|
//
|
//
|
// Revision 1.14 2003/01/16 13:36:19 mohor
|
// Revision 1.14 2003/01/16 13:36:19 mohor
|
// Form error supported. When receiving messages, last bit of the end-of-frame
|
// Form error supported. When receiving messages, last bit of the end-of-frame
|
Line 325... |
Line 328... |
|
|
reg priority_lost;
|
reg priority_lost;
|
reg tx_q;
|
reg tx_q;
|
|
|
wire error_frame_ended;
|
wire error_frame_ended;
|
wire bit_error = 0; // FIX ME !!!
|
wire bit_error;
|
wire acknowledge_error;
|
wire acknowledge_error;
|
reg need_to_tx; // When the CAN core has something to transmit and a dominant bit is sampled at the third bit
|
reg need_to_tx; // When the CAN core has something to transmit and a dominant bit is sampled at the third bit
|
// of intermission, it starts reading the identifier (and transmitting its own). // FIX ME !!!
|
// of intermission, it starts reading the identifier (and transmitting its own).
|
wire overload_needed = 0; // When receiver is busy, it needs to send overload frame. Only 2 overload frames are allowed to
|
wire overload_needed = 0; // When receiver is busy, it needs to send overload frame. Only 2 overload frames are allowed to
|
// be send in a row. Counter? FIX ME
|
// be send in a row. This is not implemented because host can not send an overload request. FIX ME !!!!
|
|
|
wire id_ok; // If received ID matches ID set in registers
|
wire id_ok; // If received ID matches ID set in registers
|
wire no_byte0; // There is no byte 0 (RTR bit set to 1 or DLC field equal to 0). Signal used for acceptance filter.
|
wire no_byte0; // There is no byte 0 (RTR bit set to 1 or DLC field equal to 0). Signal used for acceptance filter.
|
wire no_byte1; // There is no byte 1 (RTR bit set to 1 or DLC field equal to 1). Signal used for acceptance filter.
|
wire no_byte1; // There is no byte 1 (RTR bit set to 1 or DLC field equal to 1). Signal used for acceptance filter.
|
reg [3:0] data_cnt; // Counting the data bytes that are written to FIFO
|
reg [3:0] data_cnt; // Counting the data bytes that are written to FIFO
|
Line 353... |
Line 356... |
wire reset_wr_fifo;
|
wire reset_wr_fifo;
|
wire no_error;
|
wire no_error;
|
|
|
|
|
assign go_rx_idle = sample_point & sampled_bit & rx_inter & (bit_cnt == 2); // Look the following line for TX
|
assign go_rx_idle = sample_point & sampled_bit & rx_inter & (bit_cnt == 2); // Look the following line for TX
|
//assign go_rx_id1 = sample_point & (~sampled_bit) & (rx_idle | rx_inter & (bit_cnt == 2) & need_to_tx);
|
|
assign go_rx_id1 = sample_point & (~sampled_bit) & (rx_idle | rx_inter & (bit_cnt == 2));
|
assign go_rx_id1 = sample_point & (~sampled_bit) & (rx_idle | rx_inter & (bit_cnt == 2));
|
assign go_rx_rtr1 = (~bit_de_stuff) & sample_point & rx_id1 & (bit_cnt == 10);
|
assign go_rx_rtr1 = (~bit_de_stuff) & sample_point & rx_id1 & (bit_cnt == 10);
|
assign go_rx_ide = (~bit_de_stuff) & sample_point & rx_rtr1;
|
assign go_rx_ide = (~bit_de_stuff) & sample_point & rx_rtr1;
|
assign go_rx_id2 = (~bit_de_stuff) & sample_point & rx_ide & sampled_bit;
|
assign go_rx_id2 = (~bit_de_stuff) & sample_point & rx_ide & sampled_bit;
|
assign go_rx_rtr2 = (~bit_de_stuff) & sample_point & rx_id2 & (bit_cnt == 17);
|
assign go_rx_rtr2 = (~bit_de_stuff) & sample_point & rx_id2 & (bit_cnt == 17);
|
Line 390... |
Line 392... |
|
|
assign remote_rq = ((~ide) & rtr1) | (ide & rtr2);
|
assign remote_rq = ((~ide) & rtr1) | (ide & rtr2);
|
assign limited_data_len = (data_len < 8)? data_len : 4'h8;
|
assign limited_data_len = (data_len < 8)? data_len : 4'h8;
|
|
|
assign acknowledge_error = rx_ack & sample_point & sampled_bit & tx_state;
|
assign acknowledge_error = rx_ack & sample_point & sampled_bit & tx_state;
|
|
assign bit_error = tx_state & sample_point & tx & (~sampled_bit) & (~rx_ack) & (~rx_id1) & (~rx_rtr1) & (~rx_ide) & (~rx_id2) & (~rx_rtr2);
|
|
|
|
|
|
|
|
|
// Rx idle state
|
// Rx idle state
|
always @ (posedge clk or posedge rst)
|
always @ (posedge clk or posedge rst)
|
Line 1000... |
Line 1004... |
|
|
|
|
);
|
);
|
|
|
|
|
|
|
// transmitting signals that core is a transmitter. No synchronization is done meanwhile.
|
|
always @ (posedge clk or posedge rst)
|
|
begin
|
|
if (rst)
|
|
transmitting <= 1'b0;
|
|
else if (go_rx_idle | reset_mode | priority_lost)
|
|
transmitting <=#Tp 1'b0;
|
|
else if (~no_error | go_tx)
|
|
transmitting <=#Tp 1'b1;
|
|
end
|
|
|
|
|
|
|
|
// Transmitting error frame. The same counters are used for sending overload frame, too.
|
// Transmitting error frame. The same counters are used for sending overload frame, too.
|
always @ (posedge clk or posedge rst)
|
always @ (posedge clk or posedge rst)
|
begin
|
begin
|
if (rst)
|
if (rst)
|
error_frame <= 1'b0;
|
error_frame <= 1'b0;
|
Line 1210... |
Line 1200... |
else if (go_early_tx | (tx_point & tx_state & (~bit_de_stuff_tx)))
|
else if (go_early_tx | (tx_point & tx_state & (~bit_de_stuff_tx)))
|
tx_pointer <=#Tp tx_pointer + 1'b1;
|
tx_pointer <=#Tp tx_pointer + 1'b1;
|
end
|
end
|
|
|
|
|
wire rst_need_to_tx = go_rx_inter & (~error_frame & (~priority_lost)); // FIX ME !!! When there is no error until the end-of-frame, tx is ok (finished).
|
wire rst_need_to_tx = go_rx_inter & (~error_frame) & (~priority_lost);
|
always @ (posedge clk or posedge rst)
|
always @ (posedge clk or posedge rst)
|
begin
|
begin
|
if (rst)
|
if (rst)
|
need_to_tx <= 1'b0;
|
need_to_tx <= 1'b0;
|
else if (rst_need_to_tx)
|
else if (rst_need_to_tx)
|
Line 1240... |
Line 1230... |
tx_state <=#Tp 1'b1;
|
tx_state <=#Tp 1'b1;
|
end
|
end
|
|
|
|
|
|
|
|
// transmitting signals that core is a transmitter. No synchronization is done meanwhile.
|
|
always @ (posedge clk or posedge rst)
|
|
begin
|
|
if (rst)
|
|
transmitting <= 1'b0;
|
|
else if (go_rx_idle | reset_mode | priority_lost) // FIX ME !!! This line might not be ok.
|
|
transmitting <=#Tp 1'b0;
|
|
else if (~no_error | go_tx)
|
|
transmitting <=#Tp 1'b1;
|
|
end
|
|
|
|
|
|
|
always @ (posedge clk or posedge rst)
|
always @ (posedge clk or posedge rst)
|
begin
|
begin
|
if (rst)
|
if (rst)
|
finish_msg <= 1'b0;
|
finish_msg <= 1'b0;
|
else if (go_rx_idle | error_frame | reset_mode)
|
else if (go_rx_idle | error_frame | reset_mode)
|