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

Subversion Repositories can

[/] [can/] [tags/] [rel_24/] [rtl/] [verilog/] [can_bsp.v] - Blame information for rev 163

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 mohor
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  can_bsp.v                                                   ////
4
////                                                              ////
5
////                                                              ////
6 9 mohor
////  This file is part of the CAN Protocol Controller            ////
7 2 mohor
////  http://www.opencores.org/projects/can/                      ////
8
////                                                              ////
9
////                                                              ////
10
////  Author(s):                                                  ////
11
////       Igor Mohor                                             ////
12
////       igorm@opencores.org                                    ////
13
////                                                              ////
14
////                                                              ////
15 9 mohor
////  All additional information is available in the README.txt   ////
16 2 mohor
////  file.                                                       ////
17
////                                                              ////
18
//////////////////////////////////////////////////////////////////////
19
////                                                              ////
20 136 mohor
//// Copyright (C) 2002, 2003, 2004 Authors                       ////
21 2 mohor
////                                                              ////
22
//// This source file may be used and distributed without         ////
23
//// restriction provided that this copyright statement is not    ////
24
//// removed from the file and that any derivative work contains  ////
25
//// the original copyright notice and the associated disclaimer. ////
26
////                                                              ////
27
//// This source file is free software; you can redistribute it   ////
28
//// and/or modify it under the terms of the GNU Lesser General   ////
29
//// Public License as published by the Free Software Foundation; ////
30
//// either version 2.1 of the License, or (at your option) any   ////
31
//// later version.                                               ////
32
////                                                              ////
33
//// This source is distributed in the hope that it will be       ////
34
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
35
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
36
//// PURPOSE.  See the GNU Lesser General Public License for more ////
37
//// details.                                                     ////
38
////                                                              ////
39
//// You should have received a copy of the GNU Lesser General    ////
40
//// Public License along with this source; if not, download it   ////
41
//// from http://www.opencores.org/lgpl.shtml                     ////
42
////                                                              ////
43 28 mohor
//// The CAN protocol is developed by Robert Bosch GmbH and       ////
44
//// protected by patents. Anybody who wants to implement this    ////
45
//// CAN IP core on silicon has to obtain a CAN protocol license  ////
46
//// from Bosch.                                                  ////
47
////                                                              ////
48 2 mohor
//////////////////////////////////////////////////////////////////////
49
//
50
// CVS Revision History
51
//
52
// $Log: not supported by cvs2svn $
53 149 igorm
// Revision 1.49  2004/10/25 06:37:51  igorm
54
// Arbitration bug fixed.
55
//
56 145 igorm
// Revision 1.48  2004/05/12 15:58:41  igorm
57
// Core improved to pass all tests with the Bosch VHDL Reference system.
58
//
59 141 igorm
// Revision 1.47  2004/02/08 14:24:10  mohor
60
// Error counters changed.
61
//
62 136 mohor
// Revision 1.46  2003/10/17 05:55:20  markom
63
// mbist signals updated according to newest convention
64
//
65 130 markom
// Revision 1.45  2003/09/30 21:14:33  mohor
66
// Error counters changed.
67
//
68 129 mohor
// Revision 1.44  2003/09/30 00:55:12  mohor
69
// Error counters fixed to be compatible with Bosch VHDL reference model.
70
// Small synchronization changes.
71
//
72 126 mohor
// Revision 1.43  2003/09/25 18:55:49  mohor
73
// Synchronization changed, error counters fixed.
74
//
75 125 mohor
// Revision 1.42  2003/08/29 07:01:14  mohor
76
// When detecting bus-free, signal bus_free_cnt_en was cleared to zero
77
// although the last sampled bit was zero instead of one.
78
//
79 121 mohor
// Revision 1.41  2003/07/18 15:23:31  tadejm
80
// Tx and rx length are limited to 8 bytes regardless to the DLC value.
81
//
82 112 tadejm
// Revision 1.40  2003/07/16 15:10:17  mohor
83
// Fixed according to the linter.
84
//
85 110 mohor
// Revision 1.39  2003/07/16 13:12:46  mohor
86
// Fixed according to the linter.
87
//
88 107 mohor
// Revision 1.38  2003/07/10 01:59:04  tadejm
89
// Synchronization fixed. In some strange cases it didn't work according to
90
// the VHDL reference model.
91
//
92 104 tadejm
// Revision 1.37  2003/07/07 11:21:37  mohor
93
// Little fixes (to fix warnings).
94
//
95 102 mohor
// Revision 1.36  2003/07/03 09:32:20  mohor
96
// Synchronization changed.
97
//
98 100 mohor
// Revision 1.35  2003/06/27 20:56:12  simons
99
// Virtual silicon ram instances added.
100
//
101 95 simons
// Revision 1.34  2003/06/22 09:43:03  mohor
102 102 mohor
// synthesi full_case parallel_case fixed.
103 95 simons
//
104 93 mohor
// Revision 1.33  2003/06/21 12:16:30  mohor
105
// paralel_case and full_case compiler directives added to case statements.
106
//
107 90 mohor
// Revision 1.32  2003/06/17 14:28:32  mohor
108
// Form error was detected when stuff bit occured at the end of crc.
109
//
110 80 mohor
// Revision 1.31  2003/06/16 14:31:29  tadejm
111
// Bit stuffing corrected when stuffing comes at the end of the crc.
112
//
113 79 tadejm
// Revision 1.30  2003/06/16 13:57:58  mohor
114
// tx_point generated one clk earlier. rx_i registered. Data corrected when
115
// using extended mode.
116
//
117 78 mohor
// Revision 1.29  2003/06/11 14:21:35  mohor
118
// When switching to tx, sync stage is overjumped.
119
//
120 75 mohor
// Revision 1.28  2003/03/01 22:53:33  mohor
121
// Actel APA ram supported.
122
//
123 48 mohor
// Revision 1.27  2003/02/20 00:26:02  mohor
124
// When a dominant bit was detected at the third bit of the intermission and
125
// node had a message to transmit, bit_stuff error could occur. Fixed.
126
//
127 45 mohor
// Revision 1.26  2003/02/19 23:21:54  mohor
128
// When bit error occured while active error flag was transmitted, counter was
129
// not incremented.
130
//
131 44 mohor
// Revision 1.25  2003/02/19 14:44:03  mohor
132
// CAN core finished. Host interface added. Registers finished.
133
// Synchronization to the wishbone finished.
134
//
135 39 mohor
// Revision 1.24  2003/02/18 00:10:15  mohor
136
// Most of the registers added. Registers "arbitration lost capture", "error code
137
// capture" + few more still need to be added.
138
//
139 36 mohor
// Revision 1.23  2003/02/14 20:17:01  mohor
140
// Several registers added. Not finished, yet.
141
//
142 35 mohor
// Revision 1.22  2003/02/12 14:23:59  mohor
143
// abort_tx added. Bit destuff fixed.
144
//
145 32 mohor
// Revision 1.21  2003/02/11 00:56:06  mohor
146
// Wishbone interface added.
147
//
148 31 mohor
// Revision 1.20  2003/02/10 16:02:11  mohor
149
// CAN is working according to the specification. WB interface and more
150
// registers (status, IRQ, ...) needs to be added.
151
//
152 30 mohor
// Revision 1.19  2003/02/09 18:40:29  mohor
153
// Overload fixed. Hard synchronization also enabled at the last bit of
154
// interframe.
155
//
156 29 mohor
// Revision 1.18  2003/02/09 02:24:33  mohor
157
// Bosch license warning added. Error counters finished. Overload frames
158
// still need to be fixed.
159
//
160 28 mohor
// Revision 1.17  2003/02/04 17:24:41  mohor
161
// Backup.
162
//
163 26 mohor
// Revision 1.16  2003/02/04 14:34:52  mohor
164
// *** empty log message ***
165
//
166 25 mohor
// Revision 1.15  2003/01/31 01:13:37  mohor
167
// backup.
168
//
169 24 mohor
// Revision 1.14  2003/01/16 13:36:19  mohor
170
// Form error supported. When receiving messages, last bit of the end-of-frame
171
// does not generate form error. Receiver goes to the idle mode one bit sooner.
172
// (CAN specification ver 2.0, part B, page 57).
173
//
174 22 mohor
// Revision 1.13  2003/01/15 21:59:45  mohor
175
// Data is stored to fifo at the end of ack stage.
176
//
177 21 mohor
// Revision 1.12  2003/01/15 21:05:11  mohor
178
// CRC checking fixed (when bitstuff occurs at the end of a CRC sequence).
179
//
180 20 mohor
// Revision 1.11  2003/01/15 14:40:23  mohor
181 31 mohor
// RX state machine fixed to receive "remote request" frames correctly.
182
// No data bytes are written to fifo when such frames are received.
183 20 mohor
//
184 19 mohor
// Revision 1.10  2003/01/15 13:16:47  mohor
185 31 mohor
// When a frame with "remote request" is received, no data is stored to
186
// fifo, just the frame information (identifier, ...). Data length that
187
// is stored is the received data length and not the actual data length
188
// that is stored to fifo.
189 19 mohor
//
190 18 mohor
// Revision 1.9  2003/01/14 12:19:35  mohor
191
// rx_fifo is now working.
192
//
193 16 mohor
// Revision 1.8  2003/01/10 17:51:33  mohor
194
// Temporary version (backup).
195
//
196 15 mohor
// Revision 1.7  2003/01/09 21:54:45  mohor
197
// rx fifo added. Not 100 % verified, yet.
198
//
199 14 mohor
// Revision 1.6  2003/01/09 14:46:58  mohor
200
// Temporary files (backup).
201
//
202 13 mohor
// Revision 1.5  2003/01/08 13:30:31  mohor
203
// Temp version.
204
//
205 12 mohor
// Revision 1.4  2003/01/08 02:10:53  mohor
206
// Acceptance filter added.
207
//
208 11 mohor
// Revision 1.3  2002/12/28 04:13:23  mohor
209
// Backup version.
210
//
211 10 mohor
// Revision 1.2  2002/12/27 00:12:52  mohor
212
// Header changed, testbench improved to send a frame (crc still missing).
213
//
214 9 mohor
// Revision 1.1.1.1  2002/12/20 16:39:21  mohor
215
// Initial
216 2 mohor
//
217
//
218 9 mohor
//
219 2 mohor
 
220
// synopsys translate_off
221
`include "timescale.v"
222
// synopsys translate_on
223
`include "can_defines.v"
224
 
225
module can_bsp
226
(
227
  clk,
228 10 mohor
  rst,
229
 
230
  sample_point,
231
  sampled_bit,
232
  sampled_bit_q,
233 24 mohor
  tx_point,
234 11 mohor
  hard_sync,
235
 
236 14 mohor
  addr,
237 35 mohor
  data_in,
238 14 mohor
  data_out,
239 48 mohor
  fifo_selected,
240 35 mohor
 
241 14 mohor
 
242
 
243 11 mohor
  /* Mode register */
244 10 mohor
  reset_mode,
245 36 mohor
  listen_only_mode,
246 11 mohor
  acceptance_filter_mode,
247 36 mohor
  self_test_mode,
248 11 mohor
 
249 15 mohor
  /* Command register */
250
  release_buffer,
251 25 mohor
  tx_request,
252 32 mohor
  abort_tx,
253 36 mohor
  self_rx_request,
254
  single_shot_transmission,
255 104 tadejm
  tx_state,
256
  tx_state_q,
257 125 mohor
  overload_request,
258
  overload_frame,
259 15 mohor
 
260 39 mohor
  /* Arbitration Lost Capture Register */
261
  read_arbitration_lost_capture_reg,
262
 
263
  /* Error Code Capture Register */
264
  read_error_code_capture_reg,
265
  error_capture_code,
266
 
267 35 mohor
  /* Error Warning Limit register */
268
  error_warning_limit,
269
 
270
  /* Rx Error Counter register */
271
  we_rx_err_cnt,
272
 
273
  /* Tx Error Counter register */
274
  we_tx_err_cnt,
275
 
276 15 mohor
  /* Clock Divider register */
277 11 mohor
  extended_mode,
278
 
279
  rx_idle,
280 24 mohor
  transmitting,
281 125 mohor
  transmitter,
282 100 mohor
  go_rx_inter,
283 104 tadejm
  not_first_bit_of_inter,
284 126 mohor
  rx_inter,
285 35 mohor
  set_reset_mode,
286
  node_bus_off,
287
  error_status,
288
  rx_err_cnt,
289
  tx_err_cnt,
290
  transmit_status,
291
  receive_status,
292
  tx_successful,
293
  need_to_tx,
294
  overrun,
295
  info_empty,
296 39 mohor
  set_bus_error_irq,
297
  set_arbitration_lost_irq,
298
  arbitration_lost_capture,
299 36 mohor
  node_error_passive,
300
  node_error_active,
301 39 mohor
  rx_message_counter,
302 11 mohor
 
303
  /* This section is for BASIC and EXTENDED mode */
304
  /* Acceptance code register */
305
  acceptance_code_0,
306
 
307
  /* Acceptance mask register */
308
  acceptance_mask_0,
309
  /* End: This section is for BASIC and EXTENDED mode */
310 10 mohor
 
311 11 mohor
  /* This section is for EXTENDED mode */
312
  /* Acceptance code register */
313
  acceptance_code_1,
314
  acceptance_code_2,
315
  acceptance_code_3,
316 10 mohor
 
317 11 mohor
  /* Acceptance mask register */
318
  acceptance_mask_1,
319
  acceptance_mask_2,
320 18 mohor
  acceptance_mask_3,
321 11 mohor
  /* End: This section is for EXTENDED mode */
322 10 mohor
 
323 18 mohor
  /* Tx data registers. Holding identifier (basic mode), tx frame information (extended mode) and data */
324
  tx_data_0,
325
  tx_data_1,
326
  tx_data_2,
327
  tx_data_3,
328
  tx_data_4,
329
  tx_data_5,
330
  tx_data_6,
331
  tx_data_7,
332
  tx_data_8,
333
  tx_data_9,
334
  tx_data_10,
335
  tx_data_11,
336 24 mohor
  tx_data_12,
337 18 mohor
  /* End: Tx data registers */
338 24 mohor
 
339
  /* Tx signal */
340 28 mohor
  tx,
341 125 mohor
  tx_next,
342 136 mohor
  bus_off_on,
343 18 mohor
 
344 125 mohor
  go_overload_frame,
345
  go_error_frame,
346
  go_tx,
347
  send_ack
348
 
349 95 simons
  /* Bist */
350
`ifdef CAN_BIST
351
  ,
352 130 markom
  mbist_si_i,
353
  mbist_so_o,
354
  mbist_ctrl_i
355 95 simons
`endif
356 2 mohor
);
357
 
358
parameter Tp = 1;
359
 
360 10 mohor
input         clk;
361
input         rst;
362
input         sample_point;
363
input         sampled_bit;
364
input         sampled_bit_q;
365 24 mohor
input         tx_point;
366 11 mohor
input         hard_sync;
367 14 mohor
input   [7:0] addr;
368 35 mohor
input   [7:0] data_in;
369 14 mohor
output  [7:0] data_out;
370 48 mohor
input         fifo_selected;
371 11 mohor
 
372 10 mohor
input         reset_mode;
373 36 mohor
input         listen_only_mode;
374 11 mohor
input         acceptance_filter_mode;
375
input         extended_mode;
376 36 mohor
input         self_test_mode;
377 2 mohor
 
378 15 mohor
/* Command register */
379
input         release_buffer;
380 25 mohor
input         tx_request;
381 32 mohor
input         abort_tx;
382 36 mohor
input         self_rx_request;
383
input         single_shot_transmission;
384 104 tadejm
output        tx_state;
385
output        tx_state_q;
386 141 igorm
input         overload_request;     // When receiver is busy, it needs to send overload frame. Only 2 overload frames are allowed to
387
output        overload_frame;       // be send in a row. This is not implemented, yet,  because host can not send an overload request.
388 11 mohor
 
389 39 mohor
/* Arbitration Lost Capture Register */
390
input         read_arbitration_lost_capture_reg;
391
 
392
/* Error Code Capture Register */
393
input         read_error_code_capture_reg;
394
output  [7:0] error_capture_code;
395
 
396 35 mohor
/* Error Warning Limit register */
397
input   [7:0] error_warning_limit;
398
 
399
/* Rx Error Counter register */
400
input         we_rx_err_cnt;
401
 
402
/* Tx Error Counter register */
403
input         we_tx_err_cnt;
404
 
405 10 mohor
output        rx_idle;
406 24 mohor
output        transmitting;
407 125 mohor
output        transmitter;
408 100 mohor
output        go_rx_inter;
409 104 tadejm
output        not_first_bit_of_inter;
410 126 mohor
output        rx_inter;
411 35 mohor
output        set_reset_mode;
412
output        node_bus_off;
413
output        error_status;
414
output  [8:0] rx_err_cnt;
415
output  [8:0] tx_err_cnt;
416
output        transmit_status;
417
output        receive_status;
418
output        tx_successful;
419
output        need_to_tx;
420
output        overrun;
421
output        info_empty;
422 39 mohor
output        set_bus_error_irq;
423
output        set_arbitration_lost_irq;
424
output  [4:0] arbitration_lost_capture;
425 36 mohor
output        node_error_passive;
426
output        node_error_active;
427 39 mohor
output  [6:0] rx_message_counter;
428 2 mohor
 
429 29 mohor
 
430 11 mohor
/* This section is for BASIC and EXTENDED mode */
431
/* Acceptance code register */
432
input   [7:0] acceptance_code_0;
433
 
434
/* Acceptance mask register */
435
input   [7:0] acceptance_mask_0;
436
 
437
/* End: This section is for BASIC and EXTENDED mode */
438
 
439
 
440
/* This section is for EXTENDED mode */
441
/* Acceptance code register */
442
input   [7:0] acceptance_code_1;
443
input   [7:0] acceptance_code_2;
444
input   [7:0] acceptance_code_3;
445
 
446
/* Acceptance mask register */
447
input   [7:0] acceptance_mask_1;
448
input   [7:0] acceptance_mask_2;
449
input   [7:0] acceptance_mask_3;
450
/* End: This section is for EXTENDED mode */
451
 
452 24 mohor
/* Tx data registers. Holding identifier (basic mode), tx frame information (extended mode) and data */
453 18 mohor
input   [7:0] tx_data_0;
454
input   [7:0] tx_data_1;
455
input   [7:0] tx_data_2;
456
input   [7:0] tx_data_3;
457
input   [7:0] tx_data_4;
458
input   [7:0] tx_data_5;
459
input   [7:0] tx_data_6;
460
input   [7:0] tx_data_7;
461
input   [7:0] tx_data_8;
462
input   [7:0] tx_data_9;
463
input   [7:0] tx_data_10;
464
input   [7:0] tx_data_11;
465
input   [7:0] tx_data_12;
466 24 mohor
/* End: Tx data registers */
467 11 mohor
 
468 24 mohor
/* Tx signal */
469
output        tx;
470 125 mohor
output        tx_next;
471 136 mohor
output        bus_off_on;
472 11 mohor
 
473 125 mohor
output        go_overload_frame;
474
output        go_error_frame;
475
output        go_tx;
476
output        send_ack;
477
 
478 95 simons
/* Bist */
479
`ifdef CAN_BIST
480 130 markom
input         mbist_si_i;
481
output        mbist_so_o;
482
input [`CAN_MBIST_CTRL_WIDTH - 1:0] mbist_ctrl_i;       // bist chain shift control
483 95 simons
`endif
484
 
485 10 mohor
reg           reset_mode_q;
486
reg     [5:0] bit_cnt;
487 2 mohor
 
488 10 mohor
reg     [3:0] data_len;
489
reg    [28:0] id;
490
reg     [2:0] bit_stuff_cnt;
491 25 mohor
reg     [2:0] bit_stuff_cnt_tx;
492
reg           tx_point_q;
493 10 mohor
 
494
reg           rx_idle;
495
reg           rx_id1;
496
reg           rx_rtr1;
497
reg           rx_ide;
498
reg           rx_id2;
499
reg           rx_rtr2;
500
reg           rx_r1;
501
reg           rx_r0;
502
reg           rx_dlc;
503
reg           rx_data;
504
reg           rx_crc;
505 11 mohor
reg           rx_crc_lim;
506 10 mohor
reg           rx_ack;
507 11 mohor
reg           rx_ack_lim;
508 10 mohor
reg           rx_eof;
509 24 mohor
reg           rx_inter;
510 45 mohor
reg           go_early_tx_latched;
511 10 mohor
 
512 19 mohor
reg           rtr1;
513
reg           ide;
514
reg           rtr2;
515
reg    [14:0] crc_in;
516
 
517 24 mohor
reg     [7:0] tmp_data;
518
reg     [7:0] tmp_fifo [0:7];
519
reg           write_data_to_tmp_fifo;
520
reg     [2:0] byte_cnt;
521
reg           bit_stuff_cnt_en;
522 11 mohor
reg           crc_enable;
523
 
524 10 mohor
reg     [2:0] eof_cnt;
525 28 mohor
reg     [2:0] passive_cnt;
526
 
527 24 mohor
reg           transmitting;
528 10 mohor
 
529 24 mohor
reg           error_frame;
530
reg           enable_error_cnt2;
531
reg     [2:0] error_cnt1;
532
reg     [2:0] error_cnt2;
533 29 mohor
reg     [2:0] delayed_dominant_cnt;
534
reg           enable_overload_cnt2;
535 30 mohor
reg           overload_frame;
536
reg           overload_frame_blocked;
537 125 mohor
reg     [1:0] overload_request_cnt;
538 29 mohor
reg     [2:0] overload_cnt1;
539
reg     [2:0] overload_cnt2;
540 24 mohor
reg           tx;
541 28 mohor
reg           crc_err;
542 24 mohor
 
543 39 mohor
reg           arbitration_lost;
544
reg           arbitration_lost_q;
545 149 igorm
reg           read_arbitration_lost_capture_reg_q;
546 39 mohor
reg     [4:0] arbitration_lost_capture;
547
reg           arbitration_cnt_en;
548
reg           arbitration_blocked;
549 25 mohor
reg           tx_q;
550
 
551 28 mohor
reg           need_to_tx;   // When the CAN core has something to transmit and a dominant bit is sampled at the third bit
552 25 mohor
reg     [3:0] data_cnt;     // Counting the data bytes that are written to FIFO
553
reg     [2:0] header_cnt;   // Counting header length
554
reg           wr_fifo;      // Write data and header to 64-byte fifo
555
reg     [7:0] data_for_fifo;// Multiplexed data that is stored to 64-byte fifo
556
 
557
reg     [5:0] tx_pointer;
558
reg           tx_bit;
559
reg           tx_state;
560 104 tadejm
reg           tx_state_q;
561 28 mohor
reg           transmitter;
562 25 mohor
reg           finish_msg;
563
 
564 35 mohor
reg     [8:0] rx_err_cnt;
565
reg     [8:0] tx_err_cnt;
566
reg     [3:0] bus_free_cnt;
567
reg           bus_free_cnt_en;
568
reg           bus_free;
569
reg           waiting_for_bus_free;
570 28 mohor
 
571
reg           node_error_passive;
572
reg           node_bus_off;
573 35 mohor
reg           node_bus_off_q;
574 28 mohor
reg           ack_err_latched;
575
reg           bit_err_latched;
576
reg           stuff_err_latched;
577
reg           form_err_latched;
578
reg           rule3_exc1_1;
579
reg           rule3_exc1_2;
580
reg           suspend;
581
reg           susp_cnt_en;
582
reg     [2:0] susp_cnt;
583 125 mohor
reg           error_flag_over_latched;
584 28 mohor
 
585 39 mohor
reg     [7:0] error_capture_code;
586
reg     [7:6] error_capture_code_type;
587
reg           error_capture_code_blocked;
588 141 igorm
reg           tx_next;
589
reg           first_compare_bit;
590 39 mohor
 
591 141 igorm
 
592 39 mohor
wire    [4:0] error_capture_code_segment;
593
wire          error_capture_code_direction;
594
 
595 28 mohor
wire          bit_de_stuff;
596
wire          bit_de_stuff_tx;
597
 
598 44 mohor
wire          rule5;
599 28 mohor
 
600
/* Rx state machine */
601
wire          go_rx_idle;
602
wire          go_rx_id1;
603
wire          go_rx_rtr1;
604
wire          go_rx_ide;
605
wire          go_rx_id2;
606
wire          go_rx_rtr2;
607
wire          go_rx_r1;
608
wire          go_rx_r0;
609
wire          go_rx_dlc;
610
wire          go_rx_data;
611
wire          go_rx_crc;
612
wire          go_rx_crc_lim;
613
wire          go_rx_ack;
614
wire          go_rx_ack_lim;
615
wire          go_rx_eof;
616
wire          go_rx_inter;
617
 
618 104 tadejm
wire          last_bit_of_inter;
619
 
620 28 mohor
wire          go_crc_enable;
621
wire          rst_crc_enable;
622
 
623
wire          bit_de_stuff_set;
624
wire          bit_de_stuff_reset;
625
 
626
wire          go_early_tx;
627
 
628
wire   [14:0] calculated_crc;
629
wire   [15:0] r_calculated_crc;
630
wire          remote_rq;
631
wire    [3:0] limited_data_len;
632
wire          form_err;
633
 
634
wire          error_frame_ended;
635
wire          overload_frame_ended;
636
wire          bit_err;
637
wire          ack_err;
638
wire          stuff_err;
639
 
640 29 mohor
wire          id_ok;                // If received ID matches ID set in registers
641
wire          no_byte0;             // There is no byte 0 (RTR bit set to 1 or DLC field equal to 0). Signal used for acceptance filter.
642
wire          no_byte1;             // There is no byte 1 (RTR bit set to 1 or DLC field equal to 1). Signal used for acceptance filter.
643 28 mohor
 
644 25 mohor
wire    [2:0] header_len;
645
wire          storing_header;
646
wire    [3:0] limited_data_len_minus1;
647
wire          reset_wr_fifo;
648 28 mohor
wire          err;
649 25 mohor
 
650 28 mohor
wire          arbitration_field;
651 25 mohor
 
652 28 mohor
wire   [18:0] basic_chain;
653
wire   [63:0] basic_chain_data;
654
wire   [18:0] extended_chain_std;
655
wire   [38:0] extended_chain_ext;
656 78 mohor
wire   [63:0] extended_chain_data_std;
657
wire   [63:0] extended_chain_data_ext;
658 28 mohor
 
659
wire          rst_tx_pointer;
660
 
661
wire    [7:0] r_tx_data_0;
662
wire    [7:0] r_tx_data_1;
663
wire    [7:0] r_tx_data_2;
664
wire    [7:0] r_tx_data_3;
665
wire    [7:0] r_tx_data_4;
666
wire    [7:0] r_tx_data_5;
667
wire    [7:0] r_tx_data_6;
668
wire    [7:0] r_tx_data_7;
669
wire    [7:0] r_tx_data_8;
670
wire    [7:0] r_tx_data_9;
671
wire    [7:0] r_tx_data_10;
672
wire    [7:0] r_tx_data_11;
673
wire    [7:0] r_tx_data_12;
674
 
675
wire          send_ack;
676
wire          bit_err_exc1;
677
wire          bit_err_exc2;
678
wire          bit_err_exc3;
679
wire          bit_err_exc4;
680 30 mohor
wire          bit_err_exc5;
681 129 mohor
wire          bit_err_exc6;
682 28 mohor
wire          error_flag_over;
683 29 mohor
wire          overload_flag_over;
684 28 mohor
 
685 112 tadejm
wire    [5:0] limited_tx_cnt_ext;
686
wire    [5:0] limited_tx_cnt_std;
687 28 mohor
 
688 35 mohor
assign go_rx_idle     =                   sample_point &  sampled_bit & last_bit_of_inter | bus_free & (~node_bus_off);
689 29 mohor
assign go_rx_id1      =                   sample_point &  (~sampled_bit) & (rx_idle | last_bit_of_inter);
690 107 mohor
assign go_rx_rtr1     = (~bit_de_stuff) & sample_point &  rx_id1  & (bit_cnt[3:0] == 4'd10);
691 11 mohor
assign go_rx_ide      = (~bit_de_stuff) & sample_point &  rx_rtr1;
692
assign go_rx_id2      = (~bit_de_stuff) & sample_point &  rx_ide  &   sampled_bit;
693 107 mohor
assign go_rx_rtr2     = (~bit_de_stuff) & sample_point &  rx_id2  & (bit_cnt[4:0] == 5'd17);
694 11 mohor
assign go_rx_r1       = (~bit_de_stuff) & sample_point &  rx_rtr2;
695
assign go_rx_r0       = (~bit_de_stuff) & sample_point & (rx_ide  & (~sampled_bit) | rx_r1);
696
assign go_rx_dlc      = (~bit_de_stuff) & sample_point &  rx_r0;
697 107 mohor
assign go_rx_data     = (~bit_de_stuff) & sample_point &  rx_dlc  & (bit_cnt[1:0] == 2'd3) &  (sampled_bit   |   (|data_len[2:0])) & (~remote_rq);
698
assign go_rx_crc      = (~bit_de_stuff) & sample_point & (rx_dlc  & (bit_cnt[1:0] == 2'd3) & ((~sampled_bit) & (~(|data_len[2:0])) | remote_rq) |
699
                                                          rx_data & (bit_cnt[5:0] == ((limited_data_len<<3) - 1'b1)));  // overflow works ok at max value (8<<3 = 64 = 0). 0-1 = 6'h3f
700
assign go_rx_crc_lim  = (~bit_de_stuff) & sample_point &  rx_crc  & (bit_cnt[3:0] == 4'd14);
701 79 tadejm
assign go_rx_ack      = (~bit_de_stuff) & sample_point &  rx_crc_lim;
702 11 mohor
assign go_rx_ack_lim  =                   sample_point &  rx_ack;
703 35 mohor
assign go_rx_eof      =                   sample_point &  rx_ack_lim;
704 125 mohor
assign go_rx_inter    =                 ((sample_point &  rx_eof  & (eof_cnt == 3'd6)) | error_frame_ended | overload_frame_ended) & (~overload_request);
705 10 mohor
 
706 28 mohor
assign go_error_frame = (form_err | stuff_err | bit_err | ack_err | (crc_err & go_rx_eof));
707 107 mohor
assign error_frame_ended = (error_cnt2 == 3'd7) & tx_point;
708
assign overload_frame_ended = (overload_cnt2 == 3'd7) & tx_point;
709 24 mohor
 
710 129 mohor
assign go_overload_frame = (     sample_point & ((~sampled_bit) | overload_request) & (rx_eof & (~transmitter) & (eof_cnt == 3'd6) | error_frame_ended | overload_frame_ended) |
711
                                 sample_point & (~sampled_bit) & rx_inter & (bit_cnt[1:0] < 2'd2)                                                            |
712 125 mohor
                                 sample_point & (~sampled_bit) & ((error_cnt2 == 3'd7) | (overload_cnt2 == 3'd7))
713 30 mohor
                           )
714
                           & (~overload_frame_blocked)
715
                           ;
716 24 mohor
 
717 25 mohor
 
718
assign go_crc_enable  = hard_sync | go_tx;
719 11 mohor
assign rst_crc_enable = go_rx_crc;
720 10 mohor
 
721 32 mohor
assign bit_de_stuff_set   = go_rx_id1 & (~go_error_frame);
722 79 tadejm
assign bit_de_stuff_reset = go_rx_ack | reset_mode | go_error_frame | go_overload_frame;
723 11 mohor
 
724 19 mohor
assign remote_rq = ((~ide) & rtr1) | (ide & rtr2);
725 107 mohor
assign limited_data_len = (data_len < 4'h8)? data_len : 4'h8;
726 11 mohor
 
727 36 mohor
assign ack_err = rx_ack & sample_point & sampled_bit & tx_state & (~self_test_mode);
728 129 mohor
assign bit_err = (tx_state | error_frame | overload_frame | rx_ack) & sample_point & (tx != sampled_bit) & (~bit_err_exc1) & (~bit_err_exc2) & (~bit_err_exc3) & (~bit_err_exc4) & (~bit_err_exc5) & (~bit_err_exc6);
729 28 mohor
assign bit_err_exc1 = tx_state & arbitration_field & tx;
730
assign bit_err_exc2 = rx_ack & tx;
731 107 mohor
assign bit_err_exc3 = error_frame & node_error_passive & (error_cnt1 < 3'd7);
732
assign bit_err_exc4 = (error_frame & (error_cnt1 == 3'd7) & (~enable_error_cnt2)) | (overload_frame & (overload_cnt1 == 3'd7) & (~enable_overload_cnt2));
733
assign bit_err_exc5 = (error_frame & (error_cnt2 == 3'd7)) | (overload_frame & (overload_cnt2 == 3'd7));
734 129 mohor
assign bit_err_exc6 = (eof_cnt == 3'd6) & rx_eof & (~transmitter);
735 19 mohor
 
736 28 mohor
assign arbitration_field = rx_id1 | rx_rtr1 | rx_ide | rx_id2 | rx_rtr2;
737 25 mohor
 
738 107 mohor
assign last_bit_of_inter = rx_inter & (bit_cnt[1:0] == 2'd2);
739
assign not_first_bit_of_inter = rx_inter & (bit_cnt[1:0] != 2'd0);
740 25 mohor
 
741 26 mohor
 
742 10 mohor
// Rx idle state
743
always @ (posedge clk or posedge rst)
744
begin
745
  if (rst)
746 24 mohor
    rx_idle <= 1'b0;
747 125 mohor
  else if (reset_mode | go_rx_id1 | go_error_frame)
748 10 mohor
    rx_idle <=#Tp 1'b0;
749
  else if (go_rx_idle)
750
    rx_idle <=#Tp 1'b1;
751
end
752
 
753
 
754
// Rx id1 state
755
always @ (posedge clk or posedge rst)
756
begin
757
  if (rst)
758
    rx_id1 <= 1'b0;
759 125 mohor
  else if (reset_mode | go_rx_rtr1 | go_error_frame)
760 10 mohor
    rx_id1 <=#Tp 1'b0;
761
  else if (go_rx_id1)
762
    rx_id1 <=#Tp 1'b1;
763
end
764
 
765
 
766
// Rx rtr1 state
767
always @ (posedge clk or posedge rst)
768
begin
769
  if (rst)
770
    rx_rtr1 <= 1'b0;
771 125 mohor
  else if (reset_mode | go_rx_ide | go_error_frame)
772 10 mohor
    rx_rtr1 <=#Tp 1'b0;
773
  else if (go_rx_rtr1)
774
    rx_rtr1 <=#Tp 1'b1;
775
end
776
 
777
 
778
// Rx ide state
779
always @ (posedge clk or posedge rst)
780
begin
781
  if (rst)
782
    rx_ide <= 1'b0;
783 125 mohor
  else if (reset_mode | go_rx_r0 | go_rx_id2 | go_error_frame)
784 10 mohor
    rx_ide <=#Tp 1'b0;
785
  else if (go_rx_ide)
786
    rx_ide <=#Tp 1'b1;
787
end
788
 
789
 
790
// Rx id2 state
791
always @ (posedge clk or posedge rst)
792
begin
793
  if (rst)
794
    rx_id2 <= 1'b0;
795 125 mohor
  else if (reset_mode | go_rx_rtr2 | go_error_frame)
796 10 mohor
    rx_id2 <=#Tp 1'b0;
797
  else if (go_rx_id2)
798
    rx_id2 <=#Tp 1'b1;
799
end
800
 
801
 
802
// Rx rtr2 state
803
always @ (posedge clk or posedge rst)
804
begin
805
  if (rst)
806
    rx_rtr2 <= 1'b0;
807 125 mohor
  else if (reset_mode | go_rx_r1 | go_error_frame)
808 10 mohor
    rx_rtr2 <=#Tp 1'b0;
809
  else if (go_rx_rtr2)
810
    rx_rtr2 <=#Tp 1'b1;
811
end
812
 
813
 
814
// Rx r0 state
815
always @ (posedge clk or posedge rst)
816
begin
817
  if (rst)
818
    rx_r1 <= 1'b0;
819 125 mohor
  else if (reset_mode | go_rx_r0 | go_error_frame)
820 10 mohor
    rx_r1 <=#Tp 1'b0;
821
  else if (go_rx_r1)
822
    rx_r1 <=#Tp 1'b1;
823
end
824
 
825
 
826
// Rx r0 state
827
always @ (posedge clk or posedge rst)
828
begin
829
  if (rst)
830
    rx_r0 <= 1'b0;
831 125 mohor
  else if (reset_mode | go_rx_dlc | go_error_frame)
832 10 mohor
    rx_r0 <=#Tp 1'b0;
833
  else if (go_rx_r0)
834
    rx_r0 <=#Tp 1'b1;
835
end
836
 
837
 
838
// Rx dlc state
839
always @ (posedge clk or posedge rst)
840
begin
841
  if (rst)
842
    rx_dlc <= 1'b0;
843 125 mohor
  else if (reset_mode | go_rx_data | go_rx_crc | go_error_frame)
844 10 mohor
    rx_dlc <=#Tp 1'b0;
845
  else if (go_rx_dlc)
846
    rx_dlc <=#Tp 1'b1;
847
end
848
 
849
 
850
// Rx data state
851
always @ (posedge clk or posedge rst)
852
begin
853
  if (rst)
854
    rx_data <= 1'b0;
855 125 mohor
  else if (reset_mode | go_rx_crc | go_error_frame)
856 10 mohor
    rx_data <=#Tp 1'b0;
857
  else if (go_rx_data)
858
    rx_data <=#Tp 1'b1;
859
end
860
 
861
 
862
// Rx crc state
863
always @ (posedge clk or posedge rst)
864
begin
865
  if (rst)
866
    rx_crc <= 1'b0;
867 125 mohor
  else if (reset_mode | go_rx_crc_lim | go_error_frame)
868 10 mohor
    rx_crc <=#Tp 1'b0;
869
  else if (go_rx_crc)
870
    rx_crc <=#Tp 1'b1;
871
end
872
 
873
 
874 11 mohor
// Rx crc delimiter state
875
always @ (posedge clk or posedge rst)
876
begin
877
  if (rst)
878
    rx_crc_lim <= 1'b0;
879 125 mohor
  else if (reset_mode | go_rx_ack | go_error_frame)
880 11 mohor
    rx_crc_lim <=#Tp 1'b0;
881
  else if (go_rx_crc_lim)
882
    rx_crc_lim <=#Tp 1'b1;
883
end
884
 
885
 
886 10 mohor
// Rx ack state
887
always @ (posedge clk or posedge rst)
888
begin
889
  if (rst)
890
    rx_ack <= 1'b0;
891 125 mohor
  else if (reset_mode | go_rx_ack_lim | go_error_frame)
892 10 mohor
    rx_ack <=#Tp 1'b0;
893
  else if (go_rx_ack)
894
    rx_ack <=#Tp 1'b1;
895
end
896
 
897
 
898 11 mohor
// Rx ack delimiter state
899
always @ (posedge clk or posedge rst)
900
begin
901
  if (rst)
902
    rx_ack_lim <= 1'b0;
903 125 mohor
  else if (reset_mode | go_rx_eof | go_error_frame)
904 11 mohor
    rx_ack_lim <=#Tp 1'b0;
905
  else if (go_rx_ack_lim)
906
    rx_ack_lim <=#Tp 1'b1;
907
end
908
 
909
 
910 10 mohor
// Rx eof state
911
always @ (posedge clk or posedge rst)
912
begin
913
  if (rst)
914
    rx_eof <= 1'b0;
915 125 mohor
  else if (go_rx_inter | go_error_frame | go_overload_frame)
916 10 mohor
    rx_eof <=#Tp 1'b0;
917
  else if (go_rx_eof)
918
    rx_eof <=#Tp 1'b1;
919
end
920
 
921
 
922 24 mohor
 
923
// Interframe space
924
always @ (posedge clk or posedge rst)
925
begin
926
  if (rst)
927
    rx_inter <= 1'b0;
928 35 mohor
  else if (reset_mode | go_rx_idle | go_rx_id1 | go_overload_frame | go_error_frame)
929 24 mohor
    rx_inter <=#Tp 1'b0;
930
  else if (go_rx_inter)
931
    rx_inter <=#Tp 1'b1;
932
end
933
 
934
 
935 10 mohor
// ID register
936
always @ (posedge clk or posedge rst)
937
begin
938
  if (rst)
939 107 mohor
    id <= 29'h0;
940 11 mohor
  else if (sample_point & (rx_id1 | rx_id2) & (~bit_de_stuff))
941 10 mohor
    id <=#Tp {id[27:0], sampled_bit};
942
end
943
 
944 11 mohor
 
945
// rtr1 bit
946
always @ (posedge clk or posedge rst)
947
begin
948
  if (rst)
949 107 mohor
    rtr1 <= 1'b0;
950 11 mohor
  else if (sample_point & rx_rtr1 & (~bit_de_stuff))
951
    rtr1 <=#Tp sampled_bit;
952
end
953
 
954
 
955
// rtr2 bit
956
always @ (posedge clk or posedge rst)
957
begin
958
  if (rst)
959 107 mohor
    rtr2 <= 1'b0;
960 11 mohor
  else if (sample_point & rx_rtr2 & (~bit_de_stuff))
961
    rtr2 <=#Tp sampled_bit;
962
end
963
 
964
 
965
// ide bit
966
always @ (posedge clk or posedge rst)
967
begin
968
  if (rst)
969 107 mohor
    ide <= 1'b0;
970 11 mohor
  else if (sample_point & rx_ide & (~bit_de_stuff))
971
    ide <=#Tp sampled_bit;
972
end
973
 
974
 
975 10 mohor
// Data length
976
always @ (posedge clk or posedge rst)
977
begin
978
  if (rst)
979 107 mohor
    data_len <= 4'b0;
980 10 mohor
  else if (sample_point & rx_dlc & (~bit_de_stuff))
981
    data_len <=#Tp {data_len[2:0], sampled_bit};
982
end
983
 
984
 
985 11 mohor
// Data
986
always @ (posedge clk or posedge rst)
987
begin
988
  if (rst)
989 107 mohor
    tmp_data <= 8'h0;
990 11 mohor
  else if (sample_point & rx_data & (~bit_de_stuff))
991
    tmp_data <=#Tp {tmp_data[6:0], sampled_bit};
992
end
993
 
994
 
995
always @ (posedge clk or posedge rst)
996
begin
997
  if (rst)
998 107 mohor
    write_data_to_tmp_fifo <= 1'b0;
999 11 mohor
  else if (sample_point & rx_data & (~bit_de_stuff) & (&bit_cnt[2:0]))
1000
    write_data_to_tmp_fifo <=#Tp 1'b1;
1001
  else
1002 107 mohor
    write_data_to_tmp_fifo <=#Tp 1'b0;
1003 11 mohor
end
1004
 
1005
 
1006
always @ (posedge clk or posedge rst)
1007
begin
1008
  if (rst)
1009 107 mohor
    byte_cnt <= 3'h0;
1010 36 mohor
  else if (write_data_to_tmp_fifo)
1011 107 mohor
    byte_cnt <=#Tp byte_cnt + 1'b1;
1012 36 mohor
  else if (reset_mode | (sample_point & go_rx_crc_lim))
1013 107 mohor
    byte_cnt <=#Tp 3'h0;
1014 11 mohor
end
1015
 
1016
 
1017 24 mohor
always @ (posedge clk)
1018 11 mohor
begin
1019
  if (write_data_to_tmp_fifo)
1020
    tmp_fifo[byte_cnt] <=#Tp tmp_data;
1021
end
1022
 
1023
 
1024
 
1025
// CRC
1026
always @ (posedge clk or posedge rst)
1027
begin
1028
  if (rst)
1029 107 mohor
    crc_in <= 15'h0;
1030 11 mohor
  else if (sample_point & rx_crc & (~bit_de_stuff))
1031
    crc_in <=#Tp {crc_in[13:0], sampled_bit};
1032
end
1033
 
1034
 
1035 10 mohor
// bit_cnt
1036
always @ (posedge clk or posedge rst)
1037
begin
1038
  if (rst)
1039 107 mohor
    bit_cnt <= 6'd0;
1040 24 mohor
  else if (go_rx_id1 | go_rx_id2 | go_rx_dlc | go_rx_data | go_rx_crc |
1041
           go_rx_ack | go_rx_eof | go_rx_inter | go_error_frame | go_overload_frame)
1042 107 mohor
    bit_cnt <=#Tp 6'd0;
1043 11 mohor
  else if (sample_point & (~bit_de_stuff))
1044 10 mohor
    bit_cnt <=#Tp bit_cnt + 1'b1;
1045
end
1046
 
1047
 
1048
// eof_cnt
1049
always @ (posedge clk or posedge rst)
1050
begin
1051
  if (rst)
1052 107 mohor
    eof_cnt <= 3'd0;
1053 10 mohor
  else if (sample_point)
1054
    begin
1055 35 mohor
      if (reset_mode | go_rx_inter | go_error_frame | go_overload_frame)
1056 107 mohor
        eof_cnt <=#Tp 3'd0;
1057 28 mohor
      else if (rx_eof)
1058 10 mohor
        eof_cnt <=#Tp eof_cnt + 1'b1;
1059
    end
1060
end
1061
 
1062
 
1063 11 mohor
// Enabling bit de-stuffing
1064
always @ (posedge clk or posedge rst)
1065
begin
1066
  if (rst)
1067
    bit_stuff_cnt_en <= 1'b0;
1068
  else if (bit_de_stuff_set)
1069
    bit_stuff_cnt_en <=#Tp 1'b1;
1070
  else if (bit_de_stuff_reset)
1071
    bit_stuff_cnt_en <=#Tp 1'b0;
1072
end
1073 10 mohor
 
1074 24 mohor
 
1075 10 mohor
// bit_stuff_cnt
1076
always @ (posedge clk or posedge rst)
1077
begin
1078
  if (rst)
1079 107 mohor
    bit_stuff_cnt <= 3'h1;
1080 15 mohor
  else if (bit_de_stuff_reset)
1081 107 mohor
    bit_stuff_cnt <=#Tp 3'h1;
1082 11 mohor
  else if (sample_point & bit_stuff_cnt_en)
1083 10 mohor
    begin
1084 107 mohor
      if (bit_stuff_cnt == 3'h5)
1085
        bit_stuff_cnt <=#Tp 3'h1;
1086 10 mohor
      else if (sampled_bit == sampled_bit_q)
1087
        bit_stuff_cnt <=#Tp bit_stuff_cnt + 1'b1;
1088
      else
1089 107 mohor
        bit_stuff_cnt <=#Tp 3'h1;
1090 10 mohor
    end
1091
end
1092
 
1093
 
1094 25 mohor
// bit_stuff_cnt_tx
1095
always @ (posedge clk or posedge rst)
1096
begin
1097
  if (rst)
1098 107 mohor
    bit_stuff_cnt_tx <= 3'h1;
1099 25 mohor
  else if (bit_de_stuff_reset)
1100 107 mohor
    bit_stuff_cnt_tx <=#Tp 3'h1;
1101 25 mohor
  else if (tx_point_q & bit_stuff_cnt_en)
1102
    begin
1103 107 mohor
      if (bit_stuff_cnt_tx == 3'h5)
1104
        bit_stuff_cnt_tx <=#Tp 3'h1;
1105 25 mohor
      else if (tx == tx_q)
1106
        bit_stuff_cnt_tx <=#Tp bit_stuff_cnt_tx + 1'b1;
1107
      else
1108 107 mohor
        bit_stuff_cnt_tx <=#Tp 3'h1;
1109 25 mohor
    end
1110
end
1111
 
1112
 
1113 107 mohor
assign bit_de_stuff = bit_stuff_cnt == 3'h5;
1114
assign bit_de_stuff_tx = bit_stuff_cnt_tx == 3'h5;
1115 10 mohor
 
1116
 
1117 24 mohor
 
1118 28 mohor
// stuff_err
1119
assign stuff_err = sample_point & bit_stuff_cnt_en & bit_de_stuff & (sampled_bit == sampled_bit_q);
1120 10 mohor
 
1121
 
1122 28 mohor
 
1123 35 mohor
// Generating delayed signals
1124 107 mohor
always @ (posedge clk or posedge rst)
1125 10 mohor
begin
1126 107 mohor
  if (rst)
1127
    begin
1128
      reset_mode_q <=#Tp 1'b0;
1129
      node_bus_off_q <=#Tp 1'b0;
1130
    end
1131
  else
1132
    begin
1133
      reset_mode_q <=#Tp reset_mode;
1134
      node_bus_off_q <=#Tp node_bus_off;
1135
    end
1136 10 mohor
end
1137
 
1138
 
1139 11 mohor
 
1140
always @ (posedge clk or posedge rst)
1141
begin
1142
  if (rst)
1143
    crc_enable <= 1'b0;
1144
  else if (go_crc_enable)
1145
    crc_enable <=#Tp 1'b1;
1146
  else if (reset_mode | rst_crc_enable)
1147
    crc_enable <=#Tp 1'b0;
1148
end
1149
 
1150
 
1151
// CRC error generation
1152
always @ (posedge clk or posedge rst)
1153
begin
1154
  if (rst)
1155 28 mohor
    crc_err <= 1'b0;
1156 12 mohor
  else if (go_rx_ack)
1157 28 mohor
    crc_err <=#Tp crc_in != calculated_crc;
1158
  else if (reset_mode | error_frame_ended)
1159
    crc_err <=#Tp 1'b0;
1160 11 mohor
end
1161
 
1162
 
1163 22 mohor
// Conditions for form error
1164 141 igorm
assign form_err = sample_point & ( ((~bit_de_stuff) & rx_crc_lim & (~sampled_bit)                  ) |
1165
                                   (                  rx_ack_lim & (~sampled_bit)                  ) |
1166 129 mohor
                                   ((eof_cnt < 3'd6)& rx_eof     & (~sampled_bit) & (~transmitter) ) |
1167
                                   (                & rx_eof     & (~sampled_bit) &   transmitter  )
1168 28 mohor
                                 );
1169 11 mohor
 
1170 22 mohor
 
1171 28 mohor
always @ (posedge clk or posedge rst)
1172
begin
1173
  if (rst)
1174
    ack_err_latched <= 1'b0;
1175 30 mohor
  else if (reset_mode | error_frame_ended | go_overload_frame)
1176 28 mohor
    ack_err_latched <=#Tp 1'b0;
1177
  else if (ack_err)
1178
    ack_err_latched <=#Tp 1'b1;
1179
end
1180
 
1181
 
1182
always @ (posedge clk or posedge rst)
1183
begin
1184
  if (rst)
1185
    bit_err_latched <= 1'b0;
1186 30 mohor
  else if (reset_mode | error_frame_ended | go_overload_frame)
1187 28 mohor
    bit_err_latched <=#Tp 1'b0;
1188
  else if (bit_err)
1189
    bit_err_latched <=#Tp 1'b1;
1190
end
1191
 
1192
 
1193 44 mohor
 
1194 28 mohor
// Rule 5 (Fault confinement).
1195 125 mohor
assign rule5 = bit_err &  ( (~node_error_passive) & error_frame    & (error_cnt1    < 3'd7)
1196
                            |
1197
                                                    overload_frame & (overload_cnt1 < 3'd7)
1198
                          );
1199 28 mohor
 
1200
// Rule 3 exception 1 - first part (Fault confinement).
1201
always @ (posedge clk or posedge rst)
1202
begin
1203
  if (rst)
1204
    rule3_exc1_1 <= 1'b0;
1205
  else if (reset_mode | error_flag_over | rule3_exc1_2)
1206
    rule3_exc1_1 <=#Tp 1'b0;
1207
  else if (transmitter & node_error_passive & ack_err)
1208
    rule3_exc1_1 <=#Tp 1'b1;
1209
end
1210
 
1211
 
1212
// Rule 3 exception 1 - second part (Fault confinement).
1213
always @ (posedge clk or posedge rst)
1214
begin
1215
  if (rst)
1216
    rule3_exc1_2 <= 1'b0;
1217 126 mohor
  else if (reset_mode | go_error_frame | rule3_exc1_2)
1218 28 mohor
    rule3_exc1_2 <=#Tp 1'b0;
1219 126 mohor
  else if (rule3_exc1_1 & (error_cnt1 < 3'd7) & sample_point & (~sampled_bit))
1220 28 mohor
    rule3_exc1_2 <=#Tp 1'b1;
1221
end
1222
 
1223
 
1224
always @ (posedge clk or posedge rst)
1225
begin
1226
  if (rst)
1227
    stuff_err_latched <= 1'b0;
1228 30 mohor
  else if (reset_mode | error_frame_ended | go_overload_frame)
1229 28 mohor
    stuff_err_latched <=#Tp 1'b0;
1230
  else if (stuff_err)
1231
    stuff_err_latched <=#Tp 1'b1;
1232
end
1233
 
1234
 
1235
 
1236
always @ (posedge clk or posedge rst)
1237
begin
1238
  if (rst)
1239
    form_err_latched <= 1'b0;
1240 30 mohor
  else if (reset_mode | error_frame_ended | go_overload_frame)
1241 28 mohor
    form_err_latched <=#Tp 1'b0;
1242
  else if (form_err)
1243
    form_err_latched <=#Tp 1'b1;
1244
end
1245
 
1246
 
1247
 
1248 11 mohor
// Instantiation of the RX CRC module
1249
can_crc i_can_crc_rx
1250
(
1251
  .clk(clk),
1252 25 mohor
  .data(sampled_bit),
1253 11 mohor
  .enable(crc_enable & sample_point & (~bit_de_stuff)),
1254 35 mohor
  .initialize(go_crc_enable),
1255 11 mohor
  .crc(calculated_crc)
1256
);
1257
 
1258
 
1259
 
1260
 
1261 107 mohor
assign no_byte0 = rtr1 | (data_len<4'h1);
1262
assign no_byte1 = rtr1 | (data_len<4'h2);
1263 11 mohor
 
1264
can_acf i_can_acf
1265
(
1266
  .clk(clk),
1267
  .rst(rst),
1268
 
1269
  .id(id),
1270
 
1271
  /* Mode register */
1272
  .reset_mode(reset_mode),
1273
  .acceptance_filter_mode(acceptance_filter_mode),
1274
 
1275 12 mohor
  // Clock Divider register
1276 11 mohor
  .extended_mode(extended_mode),
1277
 
1278
  /* This section is for BASIC and EXTENDED mode */
1279
  /* Acceptance code register */
1280
  .acceptance_code_0(acceptance_code_0),
1281
 
1282
  /* Acceptance mask register */
1283
  .acceptance_mask_0(acceptance_mask_0),
1284
  /* End: This section is for BASIC and EXTENDED mode */
1285
 
1286
  /* This section is for EXTENDED mode */
1287
  /* Acceptance code register */
1288
  .acceptance_code_1(acceptance_code_1),
1289
  .acceptance_code_2(acceptance_code_2),
1290
  .acceptance_code_3(acceptance_code_3),
1291
 
1292
  /* Acceptance mask register */
1293
  .acceptance_mask_1(acceptance_mask_1),
1294
  .acceptance_mask_2(acceptance_mask_2),
1295
  .acceptance_mask_3(acceptance_mask_3),
1296
  /* End: This section is for EXTENDED mode */
1297
 
1298
  .go_rx_crc_lim(go_rx_crc_lim),
1299 29 mohor
  .go_rx_inter(go_rx_inter),
1300 30 mohor
  .go_error_frame(go_error_frame),
1301 11 mohor
 
1302
  .data0(tmp_fifo[0]),
1303
  .data1(tmp_fifo[1]),
1304
  .rtr1(rtr1),
1305
  .rtr2(rtr2),
1306
  .ide(ide),
1307 16 mohor
  .no_byte0(no_byte0),
1308
  .no_byte1(no_byte1),
1309 11 mohor
 
1310
  .id_ok(id_ok)
1311
 
1312
);
1313
 
1314
 
1315
 
1316
 
1317 16 mohor
assign header_len[2:0] = extended_mode ? (ide? (3'h5) : (3'h3)) : 3'h2;
1318 13 mohor
assign storing_header = header_cnt < header_len;
1319 107 mohor
assign limited_data_len_minus1[3:0] = remote_rq? 4'hf : ((data_len < 4'h8)? (data_len -1'b1) : 4'h7);   // - 1 because counter counts from 0
1320
assign reset_wr_fifo = (data_cnt == (limited_data_len_minus1 + {1'b0, header_len})) | reset_mode;
1321 12 mohor
 
1322 28 mohor
assign err = form_err | stuff_err | bit_err | ack_err | form_err_latched | stuff_err_latched | bit_err_latched | ack_err_latched | crc_err;
1323 24 mohor
 
1324
 
1325 28 mohor
 
1326 13 mohor
// Write enable signal for 64-byte rx fifo
1327
always @ (posedge clk or posedge rst)
1328
begin
1329
  if (rst)
1330
    wr_fifo <= 1'b0;
1331 16 mohor
  else if (reset_wr_fifo)
1332
    wr_fifo <=#Tp 1'b0;
1333 36 mohor
  else if (go_rx_inter & id_ok & (~error_frame_ended) & ((~tx_state) | self_rx_request))
1334 13 mohor
    wr_fifo <=#Tp 1'b1;
1335
end
1336 12 mohor
 
1337
 
1338 13 mohor
// Header counter. Header length depends on the mode of operation and frame format.
1339 12 mohor
always @ (posedge clk or posedge rst)
1340
begin
1341
  if (rst)
1342 107 mohor
    header_cnt <= 3'h0;
1343 16 mohor
  else if (reset_wr_fifo)
1344 107 mohor
    header_cnt <=#Tp 3'h0;
1345 16 mohor
  else if (wr_fifo & storing_header)
1346 107 mohor
    header_cnt <=#Tp header_cnt + 1'h1;
1347 12 mohor
end
1348
 
1349
 
1350 13 mohor
// Data counter. Length of the data is limited to 8 bytes.
1351 12 mohor
always @ (posedge clk or posedge rst)
1352
begin
1353
  if (rst)
1354 107 mohor
    data_cnt <= 4'h0;
1355 16 mohor
  else if (reset_wr_fifo)
1356 107 mohor
    data_cnt <=#Tp 4'h0;
1357 16 mohor
  else if (wr_fifo)
1358 107 mohor
    data_cnt <=#Tp data_cnt + 4'h1;
1359 12 mohor
end
1360
 
1361
 
1362 13 mohor
// Multiplexing data that is stored to 64-byte fifo depends on the mode of operation and frame format
1363 24 mohor
always @ (extended_mode or ide or data_cnt or header_cnt or  header_len or
1364
          storing_header or id or rtr1 or rtr2 or data_len or
1365 13 mohor
          tmp_fifo[0] or tmp_fifo[2] or tmp_fifo[4] or tmp_fifo[6] or
1366
          tmp_fifo[1] or tmp_fifo[3] or tmp_fifo[5] or tmp_fifo[7])
1367 12 mohor
begin
1368 107 mohor
  casex ({storing_header, extended_mode, ide, header_cnt}) /* synthesis parallel_case */
1369
    6'b1_1_1_000  : data_for_fifo = {1'b1, rtr2, 2'h0, data_len};  // extended mode, extended format header
1370
    6'b1_1_1_001  : data_for_fifo = id[28:21];                     // extended mode, extended format header
1371
    6'b1_1_1_010  : data_for_fifo = id[20:13];                     // extended mode, extended format header
1372
    6'b1_1_1_011  : data_for_fifo = id[12:5];                      // extended mode, extended format header
1373
    6'b1_1_1_100  : data_for_fifo = {id[4:0], 3'h0};               // extended mode, extended format header
1374
    6'b1_1_0_000  : data_for_fifo = {1'b0, rtr1, 2'h0, data_len};  // extended mode, standard format header
1375
    6'b1_1_0_001  : data_for_fifo = id[10:3];                      // extended mode, standard format header
1376 141 igorm
    6'b1_1_0_010  : data_for_fifo = {id[2:0], rtr1, 4'h0};         // extended mode, standard format header
1377 107 mohor
    6'b1_0_x_000  : data_for_fifo = id[10:3];                      // normal mode                    header
1378
    6'b1_0_x_001  : data_for_fifo = {id[2:0], rtr1, data_len};     // normal mode                    header
1379
    default       : data_for_fifo = tmp_fifo[data_cnt - {1'b0, header_len}]; // data 
1380
  endcase
1381 12 mohor
end
1382
 
1383
 
1384
 
1385
 
1386
// Instantiation of the RX fifo module
1387 13 mohor
can_fifo i_can_fifo
1388 12 mohor
(
1389
  .clk(clk),
1390
  .rst(rst),
1391
 
1392 13 mohor
  .wr(wr_fifo),
1393 12 mohor
 
1394 13 mohor
  .data_in(data_for_fifo),
1395 110 mohor
  .addr(addr[5:0]),
1396 14 mohor
  .data_out(data_out),
1397 48 mohor
  .fifo_selected(fifo_selected),
1398 12 mohor
 
1399
  .reset_mode(reset_mode),
1400 15 mohor
  .release_buffer(release_buffer),
1401 35 mohor
  .extended_mode(extended_mode),
1402
  .overrun(overrun),
1403 39 mohor
  .info_empty(info_empty),
1404
  .info_cnt(rx_message_counter)
1405 95 simons
 
1406
`ifdef CAN_BIST
1407
  ,
1408 130 markom
  .mbist_si_i(mbist_si_i),
1409
  .mbist_so_o(mbist_so_o),
1410
  .mbist_ctrl_i(mbist_ctrl_i)
1411 95 simons
`endif
1412 12 mohor
);
1413
 
1414
 
1415 29 mohor
// Transmitting error frame.
1416 24 mohor
always @ (posedge clk or posedge rst)
1417
begin
1418
  if (rst)
1419
    error_frame <= 1'b0;
1420 30 mohor
  else if (reset_mode | error_frame_ended | go_overload_frame)
1421 24 mohor
    error_frame <=#Tp 1'b0;
1422 28 mohor
  else if (go_error_frame)
1423 24 mohor
    error_frame <=#Tp 1'b1;
1424
end
1425 12 mohor
 
1426 13 mohor
 
1427 107 mohor
always @ (posedge clk or posedge rst)
1428 28 mohor
begin
1429 107 mohor
  if (rst)
1430
    error_cnt1 <= 3'd0;
1431 30 mohor
  else if (reset_mode | error_frame_ended | go_error_frame | go_overload_frame)
1432 107 mohor
    error_cnt1 <=#Tp 3'd0;
1433
  else if (error_frame & tx_point & (error_cnt1 < 3'd7))
1434 24 mohor
    error_cnt1 <=#Tp error_cnt1 + 1'b1;
1435
end
1436
 
1437
 
1438 28 mohor
 
1439 141 igorm
assign error_flag_over = ((~node_error_passive) & sample_point & (error_cnt1 == 3'd7) | node_error_passive  & sample_point & (passive_cnt == 3'h6)) & (~enable_error_cnt2);
1440 28 mohor
 
1441
 
1442 24 mohor
always @ (posedge clk or posedge rst)
1443
begin
1444
  if (rst)
1445 125 mohor
    error_flag_over_latched <= 1'b0;
1446 30 mohor
  else if (reset_mode | error_frame_ended | go_error_frame | go_overload_frame)
1447 125 mohor
    error_flag_over_latched <=#Tp 1'b0;
1448 28 mohor
  else if (error_flag_over)
1449 125 mohor
    error_flag_over_latched <=#Tp 1'b1;
1450 28 mohor
end
1451
 
1452
 
1453
always @ (posedge clk or posedge rst)
1454
begin
1455
  if (rst)
1456 24 mohor
    enable_error_cnt2 <= 1'b0;
1457 30 mohor
  else if (reset_mode | error_frame_ended | go_error_frame | go_overload_frame)
1458 24 mohor
    enable_error_cnt2 <=#Tp 1'b0;
1459 30 mohor
  else if (error_frame & (error_flag_over & sampled_bit))
1460 24 mohor
    enable_error_cnt2 <=#Tp 1'b1;
1461
end
1462
 
1463
 
1464
always @ (posedge clk or posedge rst)
1465
begin
1466
  if (rst)
1467 107 mohor
    error_cnt2 <= 3'd0;
1468 30 mohor
  else if (reset_mode | error_frame_ended | go_error_frame | go_overload_frame)
1469 107 mohor
    error_cnt2 <=#Tp 3'd0;
1470 24 mohor
  else if (enable_error_cnt2 & tx_point)
1471
    error_cnt2 <=#Tp error_cnt2 + 1'b1;
1472
end
1473
 
1474
 
1475 28 mohor
always @ (posedge clk or posedge rst)
1476
begin
1477
  if (rst)
1478 107 mohor
    delayed_dominant_cnt <= 3'h0;
1479 29 mohor
  else if (reset_mode | enable_error_cnt2 | go_error_frame | enable_overload_cnt2 | go_overload_frame)
1480 107 mohor
    delayed_dominant_cnt <=#Tp 3'h0;
1481
  else if (sample_point & (~sampled_bit) & ((error_cnt1 == 3'd7) | (overload_cnt1 == 3'd7)))
1482 29 mohor
    delayed_dominant_cnt <=#Tp delayed_dominant_cnt + 1'b1;
1483 28 mohor
end
1484 24 mohor
 
1485 25 mohor
 
1486 28 mohor
// passive_cnt
1487
always @ (posedge clk or posedge rst)
1488
begin
1489
  if (rst)
1490 141 igorm
    passive_cnt <= 3'h1;
1491
  else if (reset_mode | error_frame_ended | go_error_frame | go_overload_frame | first_compare_bit)
1492
    passive_cnt <=#Tp 3'h1;
1493
  else if (sample_point & (passive_cnt < 3'h6))
1494 28 mohor
    begin
1495 141 igorm
      if (error_frame & (~enable_error_cnt2) & (sampled_bit == sampled_bit_q))
1496 28 mohor
        passive_cnt <=#Tp passive_cnt + 1'b1;
1497
      else
1498 141 igorm
        passive_cnt <=#Tp 3'h1;
1499 28 mohor
    end
1500
end
1501 25 mohor
 
1502
 
1503 141 igorm
// When comparing 6 equal bits, first is always equal
1504
always @ (posedge clk or posedge rst)
1505
begin
1506
  if (rst)
1507
    first_compare_bit <= 1'b0;
1508
  else if (go_error_frame)
1509
    first_compare_bit <=#Tp 1'b1;
1510
  else if (sample_point)
1511
    first_compare_bit <= 1'b0;
1512
end
1513 29 mohor
 
1514 141 igorm
 
1515 29 mohor
// Transmitting overload frame.
1516
always @ (posedge clk or posedge rst)
1517
begin
1518
  if (rst)
1519
    overload_frame <= 1'b0;
1520
  else if (reset_mode | overload_frame_ended | go_error_frame)
1521
    overload_frame <=#Tp 1'b0;
1522
  else if (go_overload_frame)
1523
    overload_frame <=#Tp 1'b1;
1524
end
1525
 
1526
 
1527
always @ (posedge clk or posedge rst)
1528
begin
1529
  if (rst)
1530 107 mohor
    overload_cnt1 <= 3'd0;
1531 30 mohor
  else if (reset_mode | overload_frame_ended | go_error_frame | go_overload_frame)
1532 107 mohor
    overload_cnt1 <=#Tp 3'd0;
1533
  else if (overload_frame & tx_point & (overload_cnt1 < 3'd7))
1534 29 mohor
    overload_cnt1 <=#Tp overload_cnt1 + 1'b1;
1535
end
1536
 
1537
 
1538 107 mohor
assign overload_flag_over = sample_point & (overload_cnt1 == 3'd7) & (~enable_overload_cnt2);
1539 29 mohor
 
1540
 
1541
always @ (posedge clk or posedge rst)
1542
begin
1543
  if (rst)
1544
    enable_overload_cnt2 <= 1'b0;
1545 30 mohor
  else if (reset_mode | overload_frame_ended | go_error_frame | go_overload_frame)
1546 29 mohor
    enable_overload_cnt2 <=#Tp 1'b0;
1547 30 mohor
  else if (overload_frame & (overload_flag_over & sampled_bit))
1548 29 mohor
    enable_overload_cnt2 <=#Tp 1'b1;
1549
end
1550
 
1551
 
1552
always @ (posedge clk or posedge rst)
1553
begin
1554
  if (rst)
1555 107 mohor
    overload_cnt2 <= 3'd0;
1556 30 mohor
  else if (reset_mode | overload_frame_ended | go_error_frame | go_overload_frame)
1557 107 mohor
    overload_cnt2 <=#Tp 3'd0;
1558 29 mohor
  else if (enable_overload_cnt2 & tx_point)
1559
    overload_cnt2 <=#Tp overload_cnt2 + 1'b1;
1560
end
1561
 
1562
 
1563 30 mohor
always @ (posedge clk or posedge rst)
1564
begin
1565
  if (rst)
1566 125 mohor
    overload_request_cnt <= 2'b0;
1567
  else if (reset_mode | go_error_frame | go_rx_id1)
1568
    overload_request_cnt <=#Tp 2'b0;
1569
  else if (overload_request & overload_frame)
1570
    overload_request_cnt <=#Tp overload_request_cnt + 1'b1;
1571
end
1572
 
1573
 
1574
always @ (posedge clk or posedge rst)
1575
begin
1576
  if (rst)
1577 107 mohor
    overload_frame_blocked <= 1'b0;
1578 30 mohor
  else if (reset_mode | go_error_frame | go_rx_id1)
1579 107 mohor
    overload_frame_blocked <=#Tp 1'b0;
1580 125 mohor
  else if (overload_request & overload_frame & overload_request_cnt == 2'h2)   // This is a second sequential overload_request
1581 30 mohor
    overload_frame_blocked <=#Tp 1'b1;
1582
end
1583
 
1584
 
1585 36 mohor
assign send_ack = (~tx_state) & rx_ack & (~err) & (~listen_only_mode);
1586 25 mohor
 
1587
 
1588 141 igorm
 
1589
always @ (reset_mode or node_bus_off or tx_state or go_tx or bit_de_stuff_tx or tx_bit or tx_q or
1590 126 mohor
          send_ack or go_overload_frame or overload_frame or overload_cnt1 or
1591
          go_error_frame or error_frame or error_cnt1 or node_error_passive)
1592 24 mohor
begin
1593 136 mohor
  if (reset_mode | node_bus_off)                                                // Reset or node_bus_off
1594 125 mohor
    tx_next = 1'b1;
1595
  else
1596 24 mohor
    begin
1597 126 mohor
      if (go_error_frame | error_frame)                                         // Transmitting error frame
1598 30 mohor
        begin
1599 107 mohor
          if (error_cnt1 < 3'd6)
1600 25 mohor
            begin
1601 29 mohor
              if (node_error_passive)
1602 125 mohor
                tx_next = 1'b1;
1603 25 mohor
              else
1604 125 mohor
                tx_next = 1'b0;
1605 25 mohor
            end
1606 29 mohor
          else
1607 125 mohor
            tx_next = 1'b1;
1608 24 mohor
        end
1609 126 mohor
      else if (go_overload_frame | overload_frame)                              // Transmitting overload frame
1610
        begin
1611
          if (overload_cnt1 < 3'd6)
1612
            tx_next = 1'b0;
1613
          else
1614
            tx_next = 1'b1;
1615
        end
1616 141 igorm
      else if (go_tx | tx_state)                                                        // Transmitting message
1617 126 mohor
        tx_next = ((~bit_de_stuff_tx) & tx_bit) | (bit_de_stuff_tx & (~tx_q));
1618
      else if (send_ack)                                                        // Acknowledge
1619
        tx_next = 1'b0;
1620 25 mohor
      else
1621 125 mohor
        tx_next = 1'b1;
1622 24 mohor
    end
1623
end
1624
 
1625
 
1626 125 mohor
always @ (posedge clk or posedge rst)
1627
begin
1628
  if (rst)
1629
    tx <= 1'b1;
1630
  else if (tx_point)
1631
    tx <=#Tp tx_next;
1632
end
1633 45 mohor
 
1634 125 mohor
 
1635 107 mohor
always @ (posedge clk or posedge rst)
1636 25 mohor
begin
1637 107 mohor
  if (rst)
1638
    tx_q <=#Tp 1'b0;
1639
  else if (tx_point)
1640 45 mohor
    tx_q <=#Tp tx & (~go_early_tx_latched);
1641 25 mohor
end
1642 24 mohor
 
1643
 
1644 25 mohor
/* Delayed tx point */
1645 107 mohor
always @ (posedge clk or posedge rst)
1646 25 mohor
begin
1647 107 mohor
  if (rst)
1648
    tx_point_q <=#Tp 1'b0;
1649
  else
1650
    tx_point_q <=#Tp tx_point;
1651 25 mohor
end
1652 24 mohor
 
1653
 
1654 25 mohor
/* Changing bit order from [7:0] to [0:7] */
1655
can_ibo i_ibo_tx_data_0  (.di(tx_data_0),  .do(r_tx_data_0));
1656
can_ibo i_ibo_tx_data_1  (.di(tx_data_1),  .do(r_tx_data_1));
1657
can_ibo i_ibo_tx_data_2  (.di(tx_data_2),  .do(r_tx_data_2));
1658
can_ibo i_ibo_tx_data_3  (.di(tx_data_3),  .do(r_tx_data_3));
1659
can_ibo i_ibo_tx_data_4  (.di(tx_data_4),  .do(r_tx_data_4));
1660
can_ibo i_ibo_tx_data_5  (.di(tx_data_5),  .do(r_tx_data_5));
1661
can_ibo i_ibo_tx_data_6  (.di(tx_data_6),  .do(r_tx_data_6));
1662
can_ibo i_ibo_tx_data_7  (.di(tx_data_7),  .do(r_tx_data_7));
1663
can_ibo i_ibo_tx_data_8  (.di(tx_data_8),  .do(r_tx_data_8));
1664
can_ibo i_ibo_tx_data_9  (.di(tx_data_9),  .do(r_tx_data_9));
1665
can_ibo i_ibo_tx_data_10 (.di(tx_data_10), .do(r_tx_data_10));
1666
can_ibo i_ibo_tx_data_11 (.di(tx_data_11), .do(r_tx_data_11));
1667
can_ibo i_ibo_tx_data_12 (.di(tx_data_12), .do(r_tx_data_12));
1668 24 mohor
 
1669 25 mohor
/* Changing bit order from [14:0] to [0:14] */
1670
can_ibo i_calculated_crc0 (.di(calculated_crc[14:7]), .do(r_calculated_crc[7:0]));
1671
can_ibo i_calculated_crc1 (.di({calculated_crc[6:0], 1'b0}), .do(r_calculated_crc[15:8]));
1672 24 mohor
 
1673
 
1674 25 mohor
assign basic_chain = {r_tx_data_1[7:4], 2'h0, r_tx_data_1[3:0], r_tx_data_0[7:0], 1'b0};
1675
assign basic_chain_data = {r_tx_data_9, r_tx_data_8, r_tx_data_7, r_tx_data_6, r_tx_data_5, r_tx_data_4, r_tx_data_3, r_tx_data_2};
1676
assign extended_chain_std = {r_tx_data_0[7:4], 2'h0, r_tx_data_0[1], r_tx_data_2[2:0], r_tx_data_1[7:0], 1'b0};
1677
assign extended_chain_ext = {r_tx_data_0[7:4], 2'h0, r_tx_data_0[1], r_tx_data_4[4:0], r_tx_data_3[7:0], r_tx_data_2[7:3], 1'b1, 1'b1, r_tx_data_2[2:0], r_tx_data_1[7:0], 1'b0};
1678 78 mohor
assign extended_chain_data_std = {r_tx_data_10, r_tx_data_9, r_tx_data_8, r_tx_data_7, r_tx_data_6, r_tx_data_5, r_tx_data_4, r_tx_data_3};
1679
assign extended_chain_data_ext = {r_tx_data_12, r_tx_data_11, r_tx_data_10, r_tx_data_9, r_tx_data_8, r_tx_data_7, r_tx_data_6, r_tx_data_5};
1680 25 mohor
 
1681 78 mohor
always @ (extended_mode or rx_data or tx_pointer or extended_chain_data_std or extended_chain_data_ext or rx_crc or r_calculated_crc or
1682 25 mohor
          r_tx_data_0   or extended_chain_ext or extended_chain_std or basic_chain_data or basic_chain or
1683
          finish_msg)
1684
begin
1685
  if (extended_mode)
1686
    begin
1687
      if (rx_data)  // data stage
1688 78 mohor
        if (r_tx_data_0[0])    // Extended frame
1689
          tx_bit = extended_chain_data_ext[tx_pointer];
1690
        else
1691
          tx_bit = extended_chain_data_std[tx_pointer];
1692 25 mohor
      else if (rx_crc)
1693
        tx_bit = r_calculated_crc[tx_pointer];
1694
      else if (finish_msg)
1695
        tx_bit = 1'b1;
1696
      else
1697
        begin
1698
          if (r_tx_data_0[0])    // Extended frame
1699
            tx_bit = extended_chain_ext[tx_pointer];
1700
          else
1701
            tx_bit = extended_chain_std[tx_pointer];
1702
        end
1703
    end
1704
  else  // Basic mode
1705
    begin
1706
      if (rx_data)  // data stage
1707
        tx_bit = basic_chain_data[tx_pointer];
1708
      else if (rx_crc)
1709
        tx_bit = r_calculated_crc[tx_pointer];
1710
      else if (finish_msg)
1711
        tx_bit = 1'b1;
1712
      else
1713
        tx_bit = basic_chain[tx_pointer];
1714
    end
1715
end
1716
 
1717
 
1718 112 tadejm
assign limited_tx_cnt_ext = tx_data_0[3] ? 6'h3f : ((tx_data_0[2:0] <<3) - 1'b1);
1719
assign limited_tx_cnt_std = tx_data_1[3] ? 6'h3f : ((tx_data_1[2:0] <<3) - 1'b1);
1720
 
1721
assign rst_tx_pointer = ((~bit_de_stuff_tx) & tx_point & (~rx_data) &   extended_mode  &   r_tx_data_0[0]   & tx_pointer == 6'd38             ) |   // arbitration + control for extended format
1722
                        ((~bit_de_stuff_tx) & tx_point & (~rx_data) &   extended_mode  & (~r_tx_data_0[0])  & tx_pointer == 6'd18             ) |   // arbitration + control for extended format
1723
                        ((~bit_de_stuff_tx) & tx_point & (~rx_data) & (~extended_mode)                      & tx_pointer == 6'd18             ) |   // arbitration + control for standard format
1724
                        ((~bit_de_stuff_tx) & tx_point &   rx_data  &   extended_mode                       & tx_pointer == limited_tx_cnt_ext) |   // data       (overflow is OK here)
1725
                        ((~bit_de_stuff_tx) & tx_point &   rx_data  & (~extended_mode)                      & tx_pointer == limited_tx_cnt_std) |   // data       (overflow is OK here)
1726
                        (                     tx_point &   rx_crc_lim                                                                         ) |   // crc
1727
                        (go_rx_idle                                                                                                           ) |   // at the end
1728
                        (reset_mode                                                                                                           ) |
1729
                        (overload_frame                                                                                                       ) |
1730
                        (error_frame                                                                                                          ) ;
1731
 
1732 25 mohor
always @ (posedge clk or posedge rst)
1733
begin
1734
  if (rst)
1735 107 mohor
    tx_pointer <= 6'h0;
1736 25 mohor
  else if (rst_tx_pointer)
1737 107 mohor
    tx_pointer <=#Tp 6'h0;
1738 141 igorm
  else if (go_early_tx | (tx_point & (tx_state | go_tx) & (~bit_de_stuff_tx)))
1739 25 mohor
    tx_pointer <=#Tp tx_pointer + 1'b1;
1740
end
1741
 
1742
 
1743 129 mohor
assign tx_successful = transmitter & go_rx_inter & (~go_error_frame) & (~error_frame_ended) & (~overload_frame_ended) & (~arbitration_lost);
1744 28 mohor
 
1745
 
1746 25 mohor
always @ (posedge clk or posedge rst)
1747
begin
1748
  if (rst)
1749
    need_to_tx <= 1'b0;
1750 104 tadejm
  else if (tx_successful | reset_mode | (abort_tx & (~transmitting)) | ((~tx_state) & tx_state_q & single_shot_transmission))
1751 28 mohor
    need_to_tx <=#Tp 1'h0;
1752 32 mohor
  else if (tx_request & sample_point)
1753 25 mohor
    need_to_tx <=#Tp 1'b1;
1754
end
1755
 
1756
 
1757
 
1758 141 igorm
assign go_early_tx = (~listen_only_mode) & need_to_tx & (~tx_state) & (~suspend | (susp_cnt == 3'h7)) & sample_point & (~sampled_bit) & (rx_idle | last_bit_of_inter);
1759
assign go_tx       = (~listen_only_mode) & need_to_tx & (~tx_state) & (~suspend | (sample_point & (susp_cnt == 3'h7))) & (go_early_tx | rx_idle);
1760 25 mohor
 
1761 45 mohor
// go_early_tx latched (for proper bit_de_stuff generation)
1762
always @ (posedge clk or posedge rst)
1763
begin
1764
  if (rst)
1765
    go_early_tx_latched <= 1'b0;
1766 126 mohor
  else if (tx_point)
1767 45 mohor
    go_early_tx_latched <=#Tp 1'b0;
1768
  else if (go_early_tx)
1769
    go_early_tx_latched <=#Tp 1'b1;
1770
end
1771
 
1772
 
1773
 
1774 25 mohor
// Tx state
1775
always @ (posedge clk or posedge rst)
1776
begin
1777
  if (rst)
1778
    tx_state <= 1'b0;
1779 39 mohor
  else if (reset_mode | go_rx_inter | error_frame | arbitration_lost)
1780 25 mohor
    tx_state <=#Tp 1'b0;
1781
  else if (go_tx)
1782
    tx_state <=#Tp 1'b1;
1783
end
1784
 
1785 107 mohor
always @ (posedge clk or posedge rst)
1786 104 tadejm
begin
1787 107 mohor
  if (rst)
1788
    tx_state_q <=#Tp 1'b0;
1789
  else
1790
    tx_state_q <=#Tp tx_state;
1791 104 tadejm
end
1792 25 mohor
 
1793
 
1794 104 tadejm
 
1795 28 mohor
// Node is a transmitter
1796 25 mohor
always @ (posedge clk or posedge rst)
1797
begin
1798
  if (rst)
1799 28 mohor
    transmitter <= 1'b0;
1800
  else if (go_tx)
1801
    transmitter <=#Tp 1'b1;
1802 141 igorm
  else if (reset_mode | go_rx_idle | suspend & go_rx_id1)
1803 28 mohor
    transmitter <=#Tp 1'b0;
1804
end
1805 125 mohor
 
1806 28 mohor
 
1807
 
1808
// Signal "transmitting" signals that the core is a transmitting (message, error frame or overload frame). No synchronization is done meanwhile.
1809
// Node might be both transmitter or receiver (sending error or overload frame)
1810
always @ (posedge clk or posedge rst)
1811
begin
1812
  if (rst)
1813 26 mohor
    transmitting <= 1'b0;
1814 125 mohor
  else if (go_error_frame | go_overload_frame | go_tx | send_ack)
1815 28 mohor
    transmitting <=#Tp 1'b1;
1816 141 igorm
  else if (reset_mode | go_rx_idle | (go_rx_id1 & (~tx_state)) | (arbitration_lost & tx_state))
1817 26 mohor
    transmitting <=#Tp 1'b0;
1818
end
1819
 
1820
 
1821 28 mohor
always @ (posedge clk or posedge rst)
1822
begin
1823
  if (rst)
1824 107 mohor
    suspend <= 1'b0;
1825
  else if (reset_mode | (sample_point & (susp_cnt == 3'h7)))
1826
    suspend <=#Tp 1'b0;
1827 126 mohor
  else if (not_first_bit_of_inter & transmitter & node_error_passive)
1828 28 mohor
    suspend <=#Tp 1'b1;
1829
end
1830 26 mohor
 
1831 28 mohor
 
1832 26 mohor
always @ (posedge clk or posedge rst)
1833
begin
1834
  if (rst)
1835 107 mohor
    susp_cnt_en <= 1'b0;
1836
  else if (reset_mode | (sample_point & (susp_cnt == 3'h7)))
1837
    susp_cnt_en <=#Tp 1'b0;
1838 29 mohor
  else if (suspend & sample_point & last_bit_of_inter)
1839 28 mohor
    susp_cnt_en <=#Tp 1'b1;
1840
end
1841
 
1842
 
1843
always @ (posedge clk or posedge rst)
1844
begin
1845
  if (rst)
1846 107 mohor
    susp_cnt <= 3'h0;
1847
  else if (reset_mode | (sample_point & (susp_cnt == 3'h7)))
1848
    susp_cnt <=#Tp 3'h0;
1849 28 mohor
  else if (susp_cnt_en & sample_point)
1850
    susp_cnt <=#Tp susp_cnt + 1'b1;
1851
end
1852
 
1853
 
1854
always @ (posedge clk or posedge rst)
1855
begin
1856
  if (rst)
1857 25 mohor
    finish_msg <= 1'b0;
1858 28 mohor
  else if (go_rx_idle | go_rx_id1 | error_frame | reset_mode)
1859 25 mohor
    finish_msg <=#Tp 1'b0;
1860
  else if (go_rx_crc_lim)
1861
    finish_msg <=#Tp 1'b1;
1862
end
1863
 
1864
 
1865
always @ (posedge clk or posedge rst)
1866
begin
1867
  if (rst)
1868 39 mohor
    arbitration_lost <= 1'b0;
1869 129 mohor
  else if (go_rx_idle | error_frame_ended | reset_mode)
1870 39 mohor
    arbitration_lost <=#Tp 1'b0;
1871 145 igorm
  else if (transmitter & sample_point & tx & arbitration_field & ~sampled_bit)
1872
    arbitration_lost <=#Tp 1'b1;
1873 25 mohor
end
1874
 
1875
 
1876 107 mohor
always @ (posedge clk or posedge rst)
1877 39 mohor
begin
1878 107 mohor
  if (rst)
1879 149 igorm
    begin
1880
      arbitration_lost_q <=#Tp 1'b0;
1881
      read_arbitration_lost_capture_reg_q <=#Tp 1'b0;
1882
    end
1883 107 mohor
  else
1884 149 igorm
    begin
1885
      arbitration_lost_q <=#Tp arbitration_lost;
1886
      read_arbitration_lost_capture_reg_q <=#Tp read_arbitration_lost_capture_reg;
1887
    end
1888 39 mohor
end
1889 25 mohor
 
1890 39 mohor
 
1891
assign set_arbitration_lost_irq = arbitration_lost & (~arbitration_lost_q) & (~arbitration_blocked);
1892
 
1893
 
1894 28 mohor
always @ (posedge clk or posedge rst)
1895
begin
1896
  if (rst)
1897 39 mohor
    arbitration_cnt_en <= 1'b0;
1898
  else if (arbitration_blocked)
1899
    arbitration_cnt_en <=#Tp 1'b0;
1900
  else if (rx_id1 & sample_point & (~arbitration_blocked))
1901
    arbitration_cnt_en <=#Tp 1'b1;
1902
end
1903
 
1904
 
1905
 
1906
always @ (posedge clk or posedge rst)
1907
begin
1908
  if (rst)
1909
    arbitration_blocked <= 1'b0;
1910
  else if (read_arbitration_lost_capture_reg)
1911
    arbitration_blocked <=#Tp 1'b0;
1912
  else if (set_arbitration_lost_irq)
1913
    arbitration_blocked <=#Tp 1'b1;
1914
end
1915
 
1916
 
1917
always @ (posedge clk or posedge rst)
1918
begin
1919
  if (rst)
1920
    arbitration_lost_capture <= 5'h0;
1921 149 igorm
  else if (read_arbitration_lost_capture_reg_q)
1922 39 mohor
    arbitration_lost_capture <=#Tp 5'h0;
1923
  else if (sample_point & (~arbitration_blocked) & arbitration_cnt_en & (~bit_de_stuff))
1924
    arbitration_lost_capture <=#Tp arbitration_lost_capture + 1'b1;
1925
end
1926
 
1927
 
1928
 
1929
always @ (posedge clk or posedge rst)
1930
begin
1931
  if (rst)
1932 107 mohor
    rx_err_cnt <= 9'h0;
1933 35 mohor
  else if (we_rx_err_cnt & (~node_bus_off))
1934
    rx_err_cnt <=#Tp {1'b0, data_in};
1935
  else if (set_reset_mode)
1936 107 mohor
    rx_err_cnt <=#Tp 9'h0;
1937 28 mohor
  else
1938
    begin
1939 126 mohor
      if ((~listen_only_mode) & (~transmitter | arbitration_lost))
1940 28 mohor
        begin
1941 126 mohor
          if (go_rx_ack_lim & (~go_error_frame) & (~crc_err) & (rx_err_cnt > 9'h0))
1942 36 mohor
            begin
1943 107 mohor
              if (rx_err_cnt > 9'd127)
1944
                rx_err_cnt <=#Tp 9'd127;
1945 36 mohor
              else
1946
                rx_err_cnt <=#Tp rx_err_cnt - 1'b1;
1947
            end
1948 129 mohor
          else if (rx_err_cnt < 9'd128)
1949 36 mohor
            begin
1950 141 igorm
              if (go_error_frame & (~rule5))                                                                                          // 1  (rule 5 is just the opposite then rule 1 exception
1951 36 mohor
                rx_err_cnt <=#Tp rx_err_cnt + 1'b1;
1952 141 igorm
              else if ( (error_flag_over & (~error_flag_over_latched) & sample_point & (~sampled_bit) & (error_cnt1 == 3'd7)     ) |  // 2
1953
                        (go_error_frame & rule5                                                                                  ) |  // 5
1954
                        (sample_point & (~sampled_bit) & (delayed_dominant_cnt == 3'h7)                            )                  // 6
1955 36 mohor
                      )
1956
                rx_err_cnt <=#Tp rx_err_cnt + 4'h8;
1957
            end
1958 30 mohor
        end
1959 28 mohor
    end
1960
end
1961
 
1962
 
1963
always @ (posedge clk or posedge rst)
1964
begin
1965
  if (rst)
1966 107 mohor
    tx_err_cnt <= 9'h0;
1967 35 mohor
  else if (we_tx_err_cnt)
1968
    tx_err_cnt <=#Tp {1'b0, data_in};
1969 28 mohor
  else
1970
    begin
1971 35 mohor
      if (set_reset_mode)
1972 141 igorm
        tx_err_cnt <=#Tp 9'd128;
1973 107 mohor
      else if ((tx_err_cnt > 9'd0) & (tx_successful | bus_free))
1974 30 mohor
        tx_err_cnt <=#Tp tx_err_cnt - 1'h1;
1975 126 mohor
      else if (transmitter & (~arbitration_lost))
1976 28 mohor
        begin
1977 129 mohor
          if ( (sample_point & (~sampled_bit) & (delayed_dominant_cnt == 3'h7)                                          ) |       // 6
1978
               (go_error_frame & rule5                                                                                  ) |       // 4  (rule 5 is the same as rule 4)
1979 141 igorm
               (go_error_frame & (~(transmitter & node_error_passive & ack_err)) & (~(transmitter & stuff_err &
1980
                arbitration_field & sample_point & tx & (~sampled_bit)))                                                ) |       // 3 
1981
               (error_frame & rule3_exc1_2                                                                              )         // 3
1982 28 mohor
             )
1983
            tx_err_cnt <=#Tp tx_err_cnt + 4'h8;
1984
        end
1985
    end
1986
end
1987
 
1988
 
1989
always @ (posedge clk or posedge rst)
1990
begin
1991
  if (rst)
1992
    node_error_passive <= 1'b0;
1993 126 mohor
  else if ((rx_err_cnt < 128) & (tx_err_cnt < 9'd128))
1994 28 mohor
    node_error_passive <=#Tp 1'b0;
1995 107 mohor
  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))
1996 28 mohor
    node_error_passive <=#Tp 1'b1;
1997
end
1998
 
1999
 
2000 36 mohor
assign node_error_active = ~(node_error_passive | node_bus_off);
2001
 
2002
 
2003 28 mohor
always @ (posedge clk or posedge rst)
2004
begin
2005
  if (rst)
2006
    node_bus_off <= 1'b0;
2007 107 mohor
  else if ((rx_err_cnt == 9'h0) & (tx_err_cnt == 9'd0) & (~reset_mode) | (we_tx_err_cnt & (data_in < 8'd255)))
2008 28 mohor
    node_bus_off <=#Tp 1'b0;
2009 107 mohor
  else if ((tx_err_cnt >= 9'd256) | (we_tx_err_cnt & (data_in == 8'd255)))
2010 28 mohor
    node_bus_off <=#Tp 1'b1;
2011
end
2012
 
2013
 
2014 35 mohor
 
2015 28 mohor
always @ (posedge clk or posedge rst)
2016
begin
2017
  if (rst)
2018 107 mohor
    bus_free_cnt <= 4'h0;
2019 35 mohor
  else if (reset_mode)
2020 107 mohor
    bus_free_cnt <=#Tp 4'h0;
2021 30 mohor
  else if (sample_point)
2022
    begin
2023 107 mohor
      if (sampled_bit & bus_free_cnt_en & (bus_free_cnt < 4'd10))
2024 35 mohor
        bus_free_cnt <=#Tp bus_free_cnt + 1'b1;
2025 30 mohor
      else
2026 107 mohor
        bus_free_cnt <=#Tp 4'h0;
2027 30 mohor
    end
2028 28 mohor
end
2029
 
2030
 
2031 35 mohor
always @ (posedge clk or posedge rst)
2032
begin
2033
  if (rst)
2034
    bus_free_cnt_en <= 1'b0;
2035
  else if ((~reset_mode) & reset_mode_q | node_bus_off_q & (~reset_mode))
2036
    bus_free_cnt_en <=#Tp 1'b1;
2037 121 mohor
  else if (sample_point & sampled_bit & (bus_free_cnt==4'd10) & (~node_bus_off))
2038 35 mohor
    bus_free_cnt_en <=#Tp 1'b0;
2039
end
2040 28 mohor
 
2041
 
2042 35 mohor
always @ (posedge clk or posedge rst)
2043
begin
2044
  if (rst)
2045
    bus_free <= 1'b0;
2046 107 mohor
  else if (sample_point & sampled_bit & (bus_free_cnt==4'd10))
2047 35 mohor
    bus_free <=#Tp 1'b1;
2048
  else
2049
    bus_free <=#Tp 1'b0;
2050
end
2051
 
2052
 
2053
always @ (posedge clk or posedge rst)
2054
begin
2055
  if (rst)
2056
    waiting_for_bus_free <= 1'b1;
2057
  else if (bus_free & (~node_bus_off))
2058
    waiting_for_bus_free <=#Tp 1'b0;
2059
  else if ((~reset_mode) & reset_mode_q | node_bus_off_q & (~reset_mode))
2060
    waiting_for_bus_free <=#Tp 1'b1;
2061
end
2062
 
2063
 
2064 136 mohor
assign bus_off_on = ~node_bus_off;
2065 28 mohor
 
2066 35 mohor
assign set_reset_mode = node_bus_off & (~node_bus_off_q);
2067
assign error_status = (~reset_mode) & extended_mode? ((rx_err_cnt >= error_warning_limit) | (tx_err_cnt >= error_warning_limit))    :
2068 107 mohor
                                                     ((rx_err_cnt >= 9'd96) | (tx_err_cnt >= 9'd96))                                      ;
2069 28 mohor
 
2070 35 mohor
assign transmit_status = transmitting                 | (extended_mode & waiting_for_bus_free);
2071
assign receive_status  = (~rx_idle) & (~transmitting) | (extended_mode & waiting_for_bus_free);
2072
 
2073 39 mohor
 
2074
/* Error code capture register */
2075
always @ (posedge clk or posedge rst)
2076
begin
2077
  if (rst)
2078
    error_capture_code <= 8'h0;
2079
  else if (read_error_code_capture_reg)
2080
    error_capture_code <=#Tp 8'h0;
2081
  else if (set_bus_error_irq)
2082
    error_capture_code <=#Tp {error_capture_code_type[7:6], error_capture_code_direction, error_capture_code_segment[4:0]};
2083
end
2084
 
2085
 
2086
 
2087 107 mohor
assign error_capture_code_segment[0] = rx_idle | rx_ide | (rx_id2 & (bit_cnt<6'd13)) | rx_r1 | rx_r0 | rx_dlc | rx_ack | rx_ack_lim | error_frame & node_error_active;
2088 39 mohor
assign error_capture_code_segment[1] = rx_idle | rx_id1 | rx_id2 | rx_dlc | rx_data | rx_ack_lim | rx_eof | rx_inter | error_frame & node_error_passive;
2089 107 mohor
assign error_capture_code_segment[2] = (rx_id1 & (bit_cnt>6'd7)) | rx_rtr1 | rx_ide | rx_id2 | rx_rtr2 | rx_r1 | error_frame & node_error_passive | overload_frame;
2090
assign error_capture_code_segment[3] = (rx_id2 & (bit_cnt>6'd4)) | rx_rtr2 | rx_r1 | rx_r0 | rx_dlc | rx_data | rx_crc | rx_crc_lim | rx_ack | rx_ack_lim | rx_eof | overload_frame;
2091 39 mohor
assign error_capture_code_segment[4] = rx_crc_lim | rx_ack | rx_ack_lim | rx_eof | rx_inter | error_frame | overload_frame;
2092
assign error_capture_code_direction  = ~transmitting;
2093
 
2094
 
2095
always @ (bit_err or form_err or stuff_err)
2096
begin
2097
  if (bit_err)
2098 107 mohor
    error_capture_code_type[7:6] = 2'b00;
2099 39 mohor
  else if (form_err)
2100 107 mohor
    error_capture_code_type[7:6] = 2'b01;
2101 39 mohor
  else if (stuff_err)
2102 107 mohor
    error_capture_code_type[7:6] = 2'b10;
2103 39 mohor
  else
2104 107 mohor
    error_capture_code_type[7:6] = 2'b11;
2105 39 mohor
end
2106
 
2107
 
2108
assign set_bus_error_irq = go_error_frame & (~error_capture_code_blocked);
2109
 
2110
 
2111
always @ (posedge clk or posedge rst)
2112
begin
2113
  if (rst)
2114
    error_capture_code_blocked <= 1'b0;
2115
  else if (read_error_code_capture_reg)
2116
    error_capture_code_blocked <=#Tp 1'b0;
2117
  else if (set_bus_error_irq)
2118
    error_capture_code_blocked <=#Tp 1'b1;
2119
end
2120
 
2121
 
2122 2 mohor
endmodule
2123 141 igorm
 

powered by: WebSVN 2.1.0

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