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

Subversion Repositories can

[/] [can/] [trunk/] [rtl/] [verilog/] [can_bsp.v] - Diff between revs 125 and 126

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 125 Rev 126
Line 48... Line 48...
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
//
//
// CVS Revision History
// CVS Revision History
//
//
// $Log: not supported by cvs2svn $
// $Log: not supported by cvs2svn $
 
// Revision 1.43  2003/09/25 18:55:49  mohor
 
// Synchronization changed, error counters fixed.
 
//
// Revision 1.42  2003/08/29 07:01:14  mohor
// Revision 1.42  2003/08/29 07:01:14  mohor
// When detecting bus-free, signal bus_free_cnt_en was cleared to zero
// When detecting bus-free, signal bus_free_cnt_en was cleared to zero
// although the last sampled bit was zero instead of one.
// although the last sampled bit was zero instead of one.
//
//
// Revision 1.41  2003/07/18 15:23:31  tadejm
// Revision 1.41  2003/07/18 15:23:31  tadejm
Line 257... Line 260...
  rx_idle,
  rx_idle,
  transmitting,
  transmitting,
  transmitter,
  transmitter,
  go_rx_inter,
  go_rx_inter,
  not_first_bit_of_inter,
  not_first_bit_of_inter,
 
  rx_inter,
  set_reset_mode,
  set_reset_mode,
  node_bus_off,
  node_bus_off,
  error_status,
  error_status,
  rx_err_cnt,
  rx_err_cnt,
  tx_err_cnt,
  tx_err_cnt,
Line 389... Line 393...
output        rx_idle;
output        rx_idle;
output        transmitting;
output        transmitting;
output        transmitter;
output        transmitter;
output        go_rx_inter;
output        go_rx_inter;
output        not_first_bit_of_inter;
output        not_first_bit_of_inter;
 
output        rx_inter;
output        set_reset_mode;
output        set_reset_mode;
output        node_bus_off;
output        node_bus_off;
output        error_status;
output        error_status;
output  [8:0] rx_err_cnt;
output  [8:0] rx_err_cnt;
output  [8:0] tx_err_cnt;
output  [8:0] tx_err_cnt;
Line 688... Line 693...
 
 
assign go_error_frame = (form_err | stuff_err | bit_err | ack_err | (crc_err & go_rx_eof));
assign go_error_frame = (form_err | stuff_err | bit_err | ack_err | (crc_err & go_rx_eof));
assign error_frame_ended = (error_cnt2 == 3'd7) & tx_point;
assign error_frame_ended = (error_cnt2 == 3'd7) & tx_point;
assign overload_frame_ended = (overload_cnt2 == 3'd7) & tx_point;
assign overload_frame_ended = (overload_cnt2 == 3'd7) & tx_point;
 
 
assign go_overload_frame = (   ((sample_point &  rx_eof  & (eof_cnt == 3'd6)) | error_frame_ended | overload_frame_ended) & overload_request |
//assign go_overload_frame = (   ((sample_point &  rx_eof  & (eof_cnt == 3'd6)) | error_frame_ended | overload_frame_ended) & overload_request | 
 
assign go_overload_frame = (   ((sample_point &  rx_eof  & (eof_cnt == 3'd6)) | error_frame_ended | overload_frame_ended) & (overload_request | (~sampled_bit)) |
                                 sample_point & (~sampled_bit) & rx_inter & (bit_cnt[1:0] < 2'd2)                                            |
                                 sample_point & (~sampled_bit) & rx_inter & (bit_cnt[1:0] < 2'd2)                                            |
                                 sample_point & (~sampled_bit) & ((error_cnt2 == 3'd7) | (overload_cnt2 == 3'd7))
                                 sample_point & (~sampled_bit) & ((error_cnt2 == 3'd7) | (overload_cnt2 == 3'd7))
                           )
                           )
                           & (~overload_frame_blocked)
                           & (~overload_frame_blocked)
                           ;
                           ;
Line 1156... Line 1162...
    crc_err <=#Tp 1'b0;
    crc_err <=#Tp 1'b0;
end
end
 
 
 
 
// Conditions for form error
// Conditions for form error
assign form_err = sample_point & ( ((~bit_de_stuff) & rx_ide     &   sampled_bit & (~rtr1)      ) |
assign form_err = sample_point & ( ((~bit_de_stuff) & rx_crc_lim & (~sampled_bit)               ) |
                                   ((~bit_de_stuff) & rx_crc_lim & (~sampled_bit)               ) |
 
                                   (                  rx_ack_lim & (~sampled_bit)               ) |
                                   (                  rx_ack_lim & (~sampled_bit)               ) |
                                   ((eof_cnt < 3'd6)& rx_eof     & (~sampled_bit) & (~tx_state) ) |
                                   ((eof_cnt < 3'd6)& rx_eof     & (~sampled_bit) & (~tx_state) ) |
                                   (                & rx_eof     & (~sampled_bit) &   tx_state  )
                                   (                & rx_eof     & (~sampled_bit) &   tx_state  )
                                 );
                                 );
 
 
Line 1210... Line 1215...
// Rule 3 exception 1 - second part (Fault confinement).
// Rule 3 exception 1 - second part (Fault confinement).
always @ (posedge clk or posedge rst)
always @ (posedge clk or posedge rst)
begin
begin
  if (rst)
  if (rst)
    rule3_exc1_2 <= 1'b0;
    rule3_exc1_2 <= 1'b0;
  else if (reset_mode | error_flag_over)
//  else if (reset_mode | error_flag_over)
 
  else if (reset_mode | go_error_frame | rule3_exc1_2)
    rule3_exc1_2 <=#Tp 1'b0;
    rule3_exc1_2 <=#Tp 1'b0;
  else if (rule3_exc1_1)
  else if (rule3_exc1_1 & (error_cnt1 < 3'd7) & sample_point & (~sampled_bit))
    rule3_exc1_2 <=#Tp 1'b1;
    rule3_exc1_2 <=#Tp 1'b1;
  else if ((error_cnt1 < 3'd7) & sample_point & (~sampled_bit))
 
    rule3_exc1_2 <=#Tp 1'b0;
 
end
end
 
 
 
 
// Rule 3 exception 2 (Fault confinement).
// Rule 3 exception 2 (Fault confinement).
always @ (posedge clk or posedge rst)
always @ (posedge clk or posedge rst)
Line 1598... Line 1602...
assign send_ack = (~tx_state) & rx_ack & (~err) & (~listen_only_mode);
assign send_ack = (~tx_state) & rx_ack & (~err) & (~listen_only_mode);
 
 
 
 
reg tx_next;
reg tx_next;
always @ (reset_mode or tx_state or bit_de_stuff_tx or tx_bit or tx_q or
always @ (reset_mode or tx_state or bit_de_stuff_tx or tx_bit or tx_q or
          send_ack or overload_frame or overload_cnt1 or error_frame or error_cnt1 or
//always @ (reset_mode or go_tx or tx_state or bit_de_stuff_tx or tx_bit or tx_q or
          node_error_passive)
          send_ack or go_overload_frame or overload_frame or overload_cnt1 or
 
          go_error_frame or error_frame or error_cnt1 or node_error_passive)
begin
begin
  if (reset_mode)                                                               // Reset
  if (reset_mode)                                                               // Reset
    tx_next = 1'b1;
    tx_next = 1'b1;
  else
  else
    begin
    begin
      if (tx_state)                                                             // Transmitting message
      if (go_error_frame | error_frame)                                         // Transmitting error frame
        tx_next = ((~bit_de_stuff_tx) & tx_bit) | (bit_de_stuff_tx & (~tx_q));
 
      else if (send_ack)                                                        // Acknowledge
 
        tx_next = 1'b0;
 
      else if (overload_frame)                                                  // Transmitting overload frame
 
        begin
 
          if (overload_cnt1 < 3'd6)
 
            tx_next = 1'b0;
 
          else
 
            tx_next = 1'b1;
 
        end
 
      else if (error_frame)                                                     // Transmitting error frame
 
        begin
        begin
          if (error_cnt1 < 3'd6)
          if (error_cnt1 < 3'd6)
            begin
            begin
              if (node_error_passive)
              if (node_error_passive)
                tx_next = 1'b1;
                tx_next = 1'b1;
Line 1628... Line 1622...
                tx_next = 1'b0;
                tx_next = 1'b0;
            end
            end
          else
          else
            tx_next = 1'b1;
            tx_next = 1'b1;
        end
        end
 
      else if (go_overload_frame | overload_frame)                              // Transmitting overload frame
 
        begin
 
          if (overload_cnt1 < 3'd6)
 
            tx_next = 1'b0;
 
          else
 
            tx_next = 1'b1;
 
        end
 
      else if (tx_state)                                                        // Transmitting message
 
//      else if (go_tx | tx_state)                                                // Transmitting message
 
        tx_next = ((~bit_de_stuff_tx) & tx_bit) | (bit_de_stuff_tx & (~tx_q));
 
      else if (send_ack)                                                        // Acknowledge
 
        tx_next = 1'b0;
      else
      else
        tx_next = 1'b1;
        tx_next = 1'b1;
    end
    end
end
end
 
 
Line 1776... Line 1782...
// go_early_tx latched (for proper bit_de_stuff generation)
// go_early_tx latched (for proper bit_de_stuff generation)
always @ (posedge clk or posedge rst)
always @ (posedge clk or posedge rst)
begin
begin
  if (rst)
  if (rst)
    go_early_tx_latched <= 1'b0;
    go_early_tx_latched <= 1'b0;
  else if (tx_point_q)
//  else if (tx_point_q)
 
  else if (tx_point)
    go_early_tx_latched <=#Tp 1'b0;
    go_early_tx_latched <=#Tp 1'b0;
  else if (go_early_tx)
  else if (go_early_tx)
    go_early_tx_latched <=#Tp 1'b1;
    go_early_tx_latched <=#Tp 1'b1;
end
end
 
 
Line 1840... Line 1847...
  if (rst)
  if (rst)
    suspend <= 1'b0;
    suspend <= 1'b0;
  else if (reset_mode | (sample_point & (susp_cnt == 3'h7)))
  else if (reset_mode | (sample_point & (susp_cnt == 3'h7)))
    suspend <=#Tp 1'b0;
    suspend <=#Tp 1'b0;
//  else if (go_rx_inter & transmitter & node_error_passive)
//  else if (go_rx_inter & transmitter & node_error_passive)
  else if (rx_inter & transmitter & node_error_passive)
  else if (not_first_bit_of_inter & transmitter & node_error_passive)
    suspend <=#Tp 1'b1;
    suspend <=#Tp 1'b1;
end
end
 
 
 
 
always @ (posedge clk or posedge rst)
always @ (posedge clk or posedge rst)
Line 1948... Line 1955...
    rx_err_cnt <=#Tp {1'b0, data_in};
    rx_err_cnt <=#Tp {1'b0, data_in};
  else if (set_reset_mode)
  else if (set_reset_mode)
    rx_err_cnt <=#Tp 9'h0;
    rx_err_cnt <=#Tp 9'h0;
  else
  else
    begin
    begin
      if (~listen_only_mode)
      if ((~listen_only_mode) & (~transmitter | arbitration_lost))
        begin
        begin
          if (((~transmitter) | arbitration_lost) & go_rx_ack_lim & (~go_error_frame) & (rx_err_cnt > 9'h0))
          if (go_rx_ack_lim & (~go_error_frame) & (~crc_err) & (rx_err_cnt > 9'h0))
            begin
            begin
              if (rx_err_cnt > 9'd127)
              if (rx_err_cnt > 9'd127)
                rx_err_cnt <=#Tp 9'd127;
                rx_err_cnt <=#Tp 9'd127;
              else
              else
                rx_err_cnt <=#Tp rx_err_cnt - 1'b1;
                rx_err_cnt <=#Tp rx_err_cnt - 1'b1;
            end
            end
          else if ((rx_err_cnt < 9'd248) & (~transmitter))   // 248 + 8 = 256
          else if (rx_err_cnt < 9'd248)   // 248 + 8 = 256
            begin
            begin
              if (go_error_frame & (~rule5))                                                                            // 1  (rule 5 is just the opposite then rule 1 exception
              if (go_error_frame & (~rule5))                                                                            // 1  (rule 5 is just the opposite then rule 1 exception
                rx_err_cnt <=#Tp rx_err_cnt + 1'b1;
                rx_err_cnt <=#Tp rx_err_cnt + 1'b1;
//              else if ( (error_frame & sample_point & (~sampled_bit) & (error_cnt1 == 3'd7) & (~rx_err_cnt_blocked)  ) |   // 2
              else if ( (error_flag_over & (~error_flag_over_latched) & sample_point & (~sampled_bit) & (error_cnt1 == 3'd7) & (~rx_err_cnt_blocked)  ) |   // 2
              else if ( (error_flag_over_latched & sample_point & (~sampled_bit) & (error_cnt1 == 3'd7) & (~rx_err_cnt_blocked)  ) |   // 2
 
                        (go_error_frame & rule5                                                                                  ) |   // 5
                        (go_error_frame & rule5                                                                                  ) |   // 5
                        (error_frame & sample_point & (~sampled_bit) & (delayed_dominant_cnt == 3'h7)                            )     // 6
//                        (error_frame & sample_point & (~sampled_bit) & (delayed_dominant_cnt == 3'h7)                            )     // 6
 
                        (sample_point & (~sampled_bit) & (delayed_dominant_cnt == 3'h7)                            )     // 6
                      )
                      )
                rx_err_cnt <=#Tp rx_err_cnt + 4'h8;
                rx_err_cnt <=#Tp rx_err_cnt + 4'h8;
            end
            end
        end
        end
    end
    end
Line 1985... Line 1992...
    begin
    begin
      if (set_reset_mode)
      if (set_reset_mode)
        tx_err_cnt <=#Tp 9'd127;
        tx_err_cnt <=#Tp 9'd127;
      else if ((tx_err_cnt > 9'd0) & (tx_successful | bus_free))
      else if ((tx_err_cnt > 9'd0) & (tx_successful | bus_free))
        tx_err_cnt <=#Tp tx_err_cnt - 1'h1;
        tx_err_cnt <=#Tp tx_err_cnt - 1'h1;
      else if (transmitter)
      else if (transmitter & (~arbitration_lost))
        begin
        begin
          if ( (sample_point & (~sampled_bit) & (delayed_dominant_cnt == 3'h7)                  ) |       // 6
          if ( (sample_point & (~sampled_bit) & (delayed_dominant_cnt == 3'h7)                  ) |       // 6
               (go_error_frame & rule5                                                          ) |       // 4  (rule 5 is the same as rule 4)
               (go_error_frame & rule5                                                          ) |       // 4  (rule 5 is the same as rule 4)
//               (error_flag_over & (~error_flag_over_latched) & (~rule3_exc1_2) & (~rule3_exc2)  )         // 3
//               (error_flag_over & (~error_flag_over_latched) & (~rule3_exc1_2) & (~rule3_exc2)  )         // 3
               (go_error_frame & (~(transmitter & node_error_passive & ack_err))                ) // 3 ?
//               (go_error_frame & (~(transmitter & node_error_passive & ack_err))                ) // 3 ?
 
               (go_error_frame & (~(transmitter & node_error_passive & ack_err))                ) |       // 3 
 
               (error_frame & rule3_exc1_2)                                                               // 3
             )
             )
            tx_err_cnt <=#Tp tx_err_cnt + 4'h8;
            tx_err_cnt <=#Tp tx_err_cnt + 4'h8;
        end
        end
    end
    end
end
end
Line 2014... Line 2023...
 
 
always @ (posedge clk or posedge rst)
always @ (posedge clk or posedge rst)
begin
begin
  if (rst)
  if (rst)
    node_error_passive <= 1'b0;
    node_error_passive <= 1'b0;
  else if ((rx_err_cnt < 128) & (tx_err_cnt < 9'd128) & error_frame_ended)
//  else if ((rx_err_cnt < 128) & (tx_err_cnt < 9'd128) & error_frame_ended)
 
  else if ((rx_err_cnt < 128) & (tx_err_cnt < 9'd128))
    node_error_passive <=#Tp 1'b0;
    node_error_passive <=#Tp 1'b0;
  else if (((rx_err_cnt >= 128) | (tx_err_cnt >= 9'd128)) & (error_frame_ended | go_error_frame | (~reset_mode) & reset_mode_q) & (~node_bus_off))
  else if (((rx_err_cnt >= 128) | (tx_err_cnt >= 9'd128)) & (error_frame_ended | go_error_frame | (~reset_mode) & reset_mode_q) & (~node_bus_off))
    node_error_passive <=#Tp 1'b1;
    node_error_passive <=#Tp 1'b1;
end
end
 
 

powered by: WebSVN 2.1.0

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