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

Subversion Repositories can

[/] [can/] [tags/] [rel_10/] [rtl/] [verilog/] [can_btl.v] - Diff between revs 77 and 78

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

Rev 77 Rev 78
Line 48... Line 48...
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
//
//
// CVS Revision History
// CVS Revision History
//
//
// $Log: not supported by cvs2svn $
// $Log: not supported by cvs2svn $
 
// Revision 1.15  2003/06/13 15:02:24  mohor
 
// Synchronization is also needed when transmitting a message.
 
//
// Revision 1.14  2003/06/13 14:55:11  mohor
// Revision 1.14  2003/06/13 14:55:11  mohor
// Counters width changed.
// Counters width changed.
//
//
// Revision 1.13  2003/06/11 14:21:35  mohor
// Revision 1.13  2003/06/11 14:21:35  mohor
// When switching to tx, sync stage is overjumped.
// When switching to tx, sync stage is overjumped.
Line 119... Line 122...
  time_segment1,
  time_segment1,
  time_segment2,
  time_segment2,
  triple_sampling,
  triple_sampling,
 
 
  /* Output signals from this module */
  /* Output signals from this module */
  clk_en,
 
  sample_point,
  sample_point,
  sampled_bit,
  sampled_bit,
  sampled_bit_q,
  sampled_bit_q,
  tx_point,
  tx_point,
  hard_sync,
  hard_sync,
Line 162... Line 164...
input         rx_idle;
input         rx_idle;
input         overjump_sync_seg;
input         overjump_sync_seg;
input         last_bit_of_inter;
input         last_bit_of_inter;
 
 
/* Output signals from this module */
/* Output signals from this module */
output        clk_en;
 
output        sample_point;
output        sample_point;
output        sampled_bit;
output        sampled_bit;
output        sampled_bit_q;
output        sampled_bit_q;
output        tx_point;
output        tx_point;
output        hard_sync;
output        hard_sync;
Line 174... Line 175...
 
 
 
 
 
 
reg     [8:0] clk_cnt;
reg     [8:0] clk_cnt;
reg           clk_en;
reg           clk_en;
 
reg           clk_en_q;
reg           sync_blocked;
reg           sync_blocked;
reg           resync_blocked;
reg           resync_blocked;
reg           sampled_bit;
reg           sampled_bit;
reg           sampled_bit_q;
reg           sampled_bit_q;
reg     [4:0] quant_cnt;
reg     [4:0] quant_cnt;
Line 209... Line 211...
/* Generating general enable signal that defines baud rate. */
/* Generating general enable signal that defines baud rate. */
always @ (posedge clk or posedge rst)
always @ (posedge clk or posedge rst)
begin
begin
  if (rst)
  if (rst)
    clk_cnt <= 0;
    clk_cnt <= 0;
  else if (clk_cnt == (preset_cnt-1'b1))
  else if (clk_cnt >= (preset_cnt-1'b1))
    clk_cnt <=#Tp 0;
    clk_cnt <=#Tp 0;
  else
  else
    clk_cnt <=#Tp clk_cnt + 1'b1;
    clk_cnt <=#Tp clk_cnt + 1'b1;
end
end
 
 
Line 228... Line 230...
    clk_en  <=#Tp 1'b0;
    clk_en  <=#Tp 1'b0;
end
end
 
 
 
 
 
 
 
always @ (posedge clk or posedge rst)
 
begin
 
  if (rst)
 
    clk_en_q  <= 1'b0;
 
  else
 
    clk_en_q  <=#Tp clk_en;
 
end
 
 
 
 
 
 
/* Changing states */
/* Changing states */
 assign go_sync_unregistered = clk_en & (seg2 & (~hard_sync) & (~resync) & ((quant_cnt[2:0] == time_segment2)));
 assign go_sync_unregistered = clk_en & (seg2 & (~hard_sync) & (~resync) & ((quant_cnt[2:0] == time_segment2)));
 assign go_seg1 = clk_en & (sync | hard_sync | (resync & seg2 & sync_window) | (resync_latched & sync_window));
 assign go_seg1 = clk_en_q & (sync | hard_sync | (resync & seg2 & sync_window) | (resync_latched & sync_window));
 assign go_seg2 = clk_en & (seg1 & (~hard_sync) & (quant_cnt == (time_segment1 + delay)));
 assign go_seg2 = clk_en_q & (seg1 & (~hard_sync) & (quant_cnt == (time_segment1 + delay)));
 
 
 
 
 
 
always @ (posedge clk or posedge rst)
always @ (posedge clk or posedge rst)
begin
begin
  if (rst)
  if (rst)
Line 265... Line 276...
begin
begin
  if (rst)
  if (rst)
    sync <= 0;
    sync <= 0;
  else if (go_sync)
  else if (go_sync)
    sync <=#Tp 1'b1;
    sync <=#Tp 1'b1;
  else
  else if (clk_en_q)
    sync <=#Tp 1'b0;
    sync <=#Tp 1'b0;
end
end
 
 
 
 
assign tx_point = go_sync;
assign tx_point = go_sync;
Line 298... Line 309...
end
end
 
 
 
 
/* Quant counter */
/* Quant counter */
 
 
assign quant_cnt_rst1 = go_sync | go_seg1 & (~overjump_sync_seg) | go_seg2;
//assign quant_cnt_rst1 = go_sync | go_seg1 & (~overjump_sync_seg) | go_seg2;
assign quant_cnt_rst2 = go_seg1 & overjump_sync_seg;
//assign quant_cnt_rst2 = go_seg1 & overjump_sync_seg;
 
assign quant_cnt_rst1 = go_sync | go_seg1 | go_seg2;
 
assign quant_cnt_rst2 = 1'b0;
always @ (posedge clk or posedge rst)
always @ (posedge clk or posedge rst)
begin
begin
  if (rst)
  if (rst)
    quant_cnt <= 0;
    quant_cnt <= 0;
  else if (quant_cnt_rst1)
  else if (quant_cnt_rst1)
    quant_cnt <=#Tp 0;
    quant_cnt <=#Tp 0;
  else if (quant_cnt_rst2)
  else if (quant_cnt_rst2)
    quant_cnt <=#Tp 1;
    quant_cnt <=#Tp 1;
  else if (clk_en)
  else if (clk_en_q)
    quant_cnt <=#Tp quant_cnt + 1'b1;
    quant_cnt <=#Tp quant_cnt + 1'b1;
end
end
 
 
 
 
/* When late edge is detected (in seg1 stage), stage seg1 is prolonged. */
/* When late edge is detected (in seg1 stage), stage seg1 is prolonged. */
always @ (posedge clk or posedge rst)
always @ (posedge clk or posedge rst)
begin
begin
  if (rst)
  if (rst)
    delay <= 0;
    delay <= 0;
  else if (clk_en & resync & seg1)
  else if (clk_en_q & resync & seg1)
    delay <=#Tp (quant_cnt > {3'h0, sync_jump_width})? (sync_jump_width + 1'b1) : (quant_cnt + 1'b1);
    delay <=#Tp (quant_cnt > {3'h0, sync_jump_width})? (sync_jump_width + 1'b1) : (quant_cnt + 1'b1);
  else if (go_sync | go_seg1)
  else if (go_sync | go_seg1)
    delay <=#Tp 0;
    delay <=#Tp 0;
end
end
 
 
Line 334... Line 347...
// Sampling data (memorizing two samples all the time).
// Sampling data (memorizing two samples all the time).
always @ (posedge clk or posedge rst)
always @ (posedge clk or posedge rst)
begin
begin
  if (rst)
  if (rst)
    sample <= 2'b11;
    sample <= 2'b11;
  else if (clk_en)
  else if (clk_en_q)
    sample <= {sample[0], rx};
    sample <= {sample[0], rx};
end
end
 
 
 
 
// When enabled, tripple sampling is done here.
// When enabled, tripple sampling is done here.
Line 348... Line 361...
    begin
    begin
      sampled_bit <= 1;
      sampled_bit <= 1;
      sampled_bit_q <= 1;
      sampled_bit_q <= 1;
      sample_point <= 0;
      sample_point <= 0;
    end
    end
  else if (clk_en & (~hard_sync))
  else if (clk_en_q & (~hard_sync))
    begin
    begin
      if (seg1 & (quant_cnt == (time_segment1 + delay)))
      if (seg1 & (quant_cnt == (time_segment1 + delay)))
        begin
        begin
          sample_point <=#Tp 1;
          sample_point <=#Tp 1;
          sampled_bit_q <=#Tp sampled_bit;
          sampled_bit_q <=#Tp sampled_bit;
Line 372... Line 385...
 
 
always @ (posedge clk or posedge rst)
always @ (posedge clk or posedge rst)
begin
begin
  if (rst)
  if (rst)
    sync_blocked <=#Tp 1'b0;
    sync_blocked <=#Tp 1'b0;
  else if (clk_en)
  else if (clk_en_q)
    begin
    begin
      if (hard_sync | resync)
      if (hard_sync | resync)
        sync_blocked <=#Tp 1'b1;
        sync_blocked <=#Tp 1'b1;
      else if (seg2 & (quant_cnt[2:0] == time_segment2))
      else if (seg2 & (quant_cnt[2:0] == time_segment2))
        sync_blocked <=#Tp 1'b0;
        sync_blocked <=#Tp 1'b0;

powered by: WebSVN 2.1.0

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