Line 48... |
Line 48... |
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
//
|
//
|
// CVS Revision History
|
// CVS Revision History
|
//
|
//
|
// $Log: not supported by cvs2svn $
|
// $Log: not supported by cvs2svn $
|
|
// Revision 1.20 2003/06/20 14:51:11 mohor
|
|
// Previous change removed. When resynchronization occurs we go to seg1
|
|
// stage. sync stage does not cause another start of seg1 stage.
|
|
//
|
// Revision 1.19 2003/06/20 14:28:20 mohor
|
// Revision 1.19 2003/06/20 14:28:20 mohor
|
// When hard_sync or resync occure we need to go to seg1 segment. Going to
|
// When hard_sync or resync occure we need to go to seg1 segment. Going to
|
// sync segment is in that case blocked.
|
// sync segment is in that case blocked.
|
//
|
//
|
// Revision 1.18 2003/06/17 15:53:33 mohor
|
// Revision 1.18 2003/06/17 15:53:33 mohor
|
Line 144... |
Line 148... |
tx_point,
|
tx_point,
|
hard_sync,
|
hard_sync,
|
|
|
/* Output from can_bsp module */
|
/* Output from can_bsp module */
|
rx_idle,
|
rx_idle,
|
last_bit_of_inter
|
last_bit_of_inter,
|
|
transmitting,
|
|
go_rx_inter
|
|
|
|
|
|
|
);
|
);
|
|
|
parameter Tp = 1;
|
parameter Tp = 1;
|
|
|
Line 173... |
Line 175... |
input triple_sampling;
|
input triple_sampling;
|
|
|
/* Output from can_bsp module */
|
/* Output from can_bsp module */
|
input rx_idle;
|
input rx_idle;
|
input last_bit_of_inter;
|
input last_bit_of_inter;
|
|
input transmitting;
|
|
input go_rx_inter;
|
|
|
/* Output signals from this module */
|
/* Output signals from this module */
|
output sample_point;
|
output sample_point;
|
output sampled_bit;
|
output sampled_bit;
|
output sampled_bit_q;
|
output sampled_bit_q;
|
Line 187... |
Line 191... |
|
|
reg [6:0] clk_cnt;
|
reg [6:0] clk_cnt;
|
reg clk_en;
|
reg clk_en;
|
reg clk_en_q;
|
reg clk_en_q;
|
reg sync_blocked;
|
reg sync_blocked;
|
reg resync_blocked;
|
reg hard_sync_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;
|
reg [3:0] delay;
|
reg [3:0] delay;
|
reg sync;
|
reg sync;
|
Line 199... |
Line 203... |
reg seg2;
|
reg seg2;
|
reg resync_latched;
|
reg resync_latched;
|
reg sample_point;
|
reg sample_point;
|
reg [1:0] sample;
|
reg [1:0] sample;
|
reg go_sync;
|
reg go_sync;
|
|
reg go_seg1;
|
|
reg go_seg2;
|
|
reg tx_point;
|
|
|
wire go_sync_unregistered;
|
wire go_sync_unregistered;
|
wire go_seg1;
|
wire go_seg1_unregistered;
|
wire go_seg2;
|
wire go_seg2_unregistered;
|
wire [8:0] preset_cnt;
|
wire [8:0] preset_cnt;
|
wire sync_window;
|
wire sync_window;
|
wire resync;
|
wire resync;
|
wire quant_cnt_rst;
|
wire quant_cnt_rst;
|
|
|
|
|
|
|
assign preset_cnt = (baud_r_presc + 1'b1)<<1; // (BRP+1)*2
|
assign preset_cnt = (baud_r_presc + 1'b1)<<1; // (BRP+1)*2
|
assign hard_sync = (rx_idle | last_bit_of_inter) & (~rx) & sampled_bit & (~sync_blocked); // Hard synchronization
|
assign hard_sync = (rx_idle | last_bit_of_inter) & (~rx) & sampled_bit & (~hard_sync_blocked); // Hard synchronization
|
assign resync = (~rx_idle) & (~rx) & sampled_bit & (~sync_blocked) & (~resync_blocked); // Re-synchronization
|
assign resync = (~rx_idle) & (~last_bit_of_inter) & (~rx) & sampled_bit & (~sync_blocked) & (~(transmitting & seg1)); // Re-synchronization
|
|
|
|
|
/* 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
|
Line 251... |
Line 258... |
|
|
|
|
|
|
/* 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_q & ((sync & (~seg1)) | hard_sync | (resync & seg2 & sync_window) | (resync_latched & sync_window));
|
assign go_seg1_unregistered = clk_en & (((sync | hard_sync) & (~seg1)) | (resync & seg2 & sync_window) | (resync_latched & sync_window));
|
assign go_seg2 = clk_en_q & (seg1 & (~hard_sync) & (quant_cnt == (time_segment1 + delay)));
|
assign go_seg2_unregistered = clk_en & (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 264... |
Line 271... |
else
|
else
|
go_sync <=#Tp go_sync_unregistered;
|
go_sync <=#Tp go_sync_unregistered;
|
end
|
end
|
|
|
|
|
|
always @ (posedge clk or posedge rst)
|
|
begin
|
|
if (rst)
|
|
go_seg1 <= 1'b0;
|
|
else
|
|
go_seg1 <=#Tp go_seg1_unregistered;
|
|
end
|
|
|
|
|
|
always @ (posedge clk or posedge rst)
|
|
begin
|
|
if (rst)
|
|
go_seg2 <= 1'b0;
|
|
else
|
|
go_seg2 <=#Tp go_seg2_unregistered;
|
|
end
|
|
|
|
|
|
always @ (posedge clk or posedge rst)
|
|
begin
|
|
if (rst)
|
|
tx_point <= 1'b0;
|
|
else
|
|
tx_point <=#Tp go_sync_unregistered | (go_seg1_unregistered & (~(sync | hard_sync)));
|
|
end
|
|
|
|
|
/* When early edge is detected outside of the SJW field, synchronization request is latched and performed when
|
/* When early edge is detected outside of the SJW field, synchronization request is latched and performed when
|
SJW is reached */
|
SJW is reached */
|
always @ (posedge clk or posedge rst)
|
always @ (posedge clk or posedge rst)
|
begin
|
begin
|
if (rst)
|
if (rst)
|
Line 290... |
Line 324... |
else if (clk_en_q)
|
else if (clk_en_q)
|
sync <=#Tp 1'b0;
|
sync <=#Tp 1'b0;
|
end
|
end
|
|
|
|
|
assign tx_point = go_sync;
|
|
|
|
/* Seg1 stage/segment (together with propagation segment which is 1 quant long) */
|
/* Seg1 stage/segment (together with propagation segment which is 1 quant long) */
|
always @ (posedge clk or posedge rst)
|
always @ (posedge clk or posedge rst)
|
begin
|
begin
|
if (rst)
|
if (rst)
|
seg1 <= 1;
|
seg1 <= 1;
|
Line 391... |
Line 423... |
begin
|
begin
|
if (rst)
|
if (rst)
|
sync_blocked <=#Tp 1'b0;
|
sync_blocked <=#Tp 1'b0;
|
else if (clk_en_q)
|
else if (clk_en_q)
|
begin
|
begin
|
if (hard_sync | resync)
|
if (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;
|
end
|
end
|
end
|
end
|
|
|
|
|
/* Blocking resynchronization until reception starts (needed because after reset mode exits we are waiting for
|
/* Blocking hard synchronization when occurs once or when we are transmitting a msg */
|
end-of-frame and interframe. No resynchronization is needed meanwhile). */
|
|
always @ (posedge clk or posedge rst)
|
always @ (posedge clk or posedge rst)
|
begin
|
begin
|
if (rst)
|
if (rst)
|
resync_blocked <=#Tp 1'b1;
|
hard_sync_blocked <=#Tp 1'b0;
|
else if (reset_mode)
|
else if (hard_sync | transmitting & tx_point)
|
resync_blocked <=#Tp 1'b1;
|
hard_sync_blocked <=#Tp 1'b1;
|
else if (hard_sync)
|
else if (go_rx_inter)
|
resync_blocked <=#Tp 1'b0;
|
hard_sync_blocked <=#Tp 1'b0;
|
end
|
end
|
|
|
|
|
|
|
|
|