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

Subversion Repositories can

[/] [can/] [tags/] [asyst_2/] [rtl/] [verilog/] [can_top.v] - Blame information for rev 104

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

Line No. Rev Author Line
1 66 mohor
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  can_top.v                                                   ////
4
////                                                              ////
5
////                                                              ////
6
////  This file is part of the CAN Protocol Controller            ////
7
////  http://www.opencores.org/projects/can/                      ////
8
////                                                              ////
9
////                                                              ////
10
////  Author(s):                                                  ////
11
////       Igor Mohor                                             ////
12
////       igorm@opencores.org                                    ////
13
////                                                              ////
14
////                                                              ////
15
////  All additional information is available in the README.txt   ////
16
////  file.                                                       ////
17
////                                                              ////
18
//////////////////////////////////////////////////////////////////////
19
////                                                              ////
20
//// Copyright (C) 2002, 2003 Authors                             ////
21
////                                                              ////
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
//// 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
//////////////////////////////////////////////////////////////////////
49
//
50
// CVS Revision History
51
//
52
// $Log: not supported by cvs2svn $
53 104 tadejm
// Revision 1.39  2003/07/07 11:21:37  mohor
54
// Little fixes (to fix warnings).
55
//
56 102 mohor
// Revision 1.38  2003/07/03 09:32:20  mohor
57
// Synchronization changed.
58
//
59 100 mohor
// Revision 1.37  2003/06/27 20:56:15  simons
60
// Virtual silicon ram instances added.
61
//
62 95 simons
// Revision 1.36  2003/06/17 14:30:30  mohor
63
// "chip select" signal cs_can_i is used only when not using WISHBONE
64
// interface.
65
//
66 81 mohor
// Revision 1.35  2003/06/16 13:57:58  mohor
67
// tx_point generated one clk earlier. rx_i registered. Data corrected when
68
// using extended mode.
69
//
70 78 mohor
// Revision 1.34  2003/06/13 15:02:24  mohor
71
// Synchronization is also needed when transmitting a message.
72
//
73 77 mohor
// Revision 1.33  2003/06/11 14:21:35  mohor
74
// When switching to tx, sync stage is overjumped.
75
//
76 75 mohor
// Revision 1.32  2003/06/09 11:32:36  mohor
77
// Ports added for the CAN_BIST.
78
//
79 71 mohor
// Revision 1.31  2003/03/26 11:19:46  mohor
80
// CAN interrupt is active low.
81
//
82 67 mohor
// Revision 1.30  2003/03/20 17:01:17  mohor
83
// unix.
84
//
85 66 mohor
// Revision 1.28  2003/03/14 19:36:48  mohor
86
// can_cs signal used for generation of the cs.
87
//
88
// Revision 1.27  2003/03/12 05:56:33  mohor
89
// Bidirectional port_0_i changed to port_0_io.
90
// input cs_can changed to cs_can_i.
91
//
92
// Revision 1.26  2003/03/12 04:39:40  mohor
93
// rd_i and wr_i are active high signals. If 8051 is connected, these two signals
94
// need to be negated one level higher.
95
//
96
// Revision 1.25  2003/03/12 04:17:36  mohor
97
// 8051 interface added (besides WISHBONE interface). Selection is made in
98
// can_defines.v file.
99
//
100
// Revision 1.24  2003/03/10 17:24:40  mohor
101
// wire declaration added.
102
//
103
// Revision 1.23  2003/03/05 15:33:13  mohor
104
// tx_o is now tristated signal. tx_oen and tx_o combined together.
105
//
106
// Revision 1.22  2003/03/05 15:01:56  mohor
107
// Top level signal names changed.
108
//
109
// Revision 1.21  2003/03/01 22:53:33  mohor
110
// Actel APA ram supported.
111
//
112
// Revision 1.20  2003/02/19 15:09:02  mohor
113
// Incomplete sensitivity list fixed.
114
//
115
// Revision 1.19  2003/02/19 15:04:14  mohor
116
// Typo fixed.
117
//
118
// Revision 1.18  2003/02/19 14:44:03  mohor
119
// CAN core finished. Host interface added. Registers finished.
120
// Synchronization to the wishbone finished.
121
//
122
// Revision 1.17  2003/02/18 00:10:15  mohor
123
// Most of the registers added. Registers "arbitration lost capture", "error code
124
// capture" + few more still need to be added.
125
//
126
// Revision 1.16  2003/02/14 20:17:01  mohor
127
// Several registers added. Not finished, yet.
128
//
129
// Revision 1.15  2003/02/12 14:25:30  mohor
130
// abort_tx added.
131
//
132
// Revision 1.14  2003/02/11 00:56:06  mohor
133
// Wishbone interface added.
134
//
135
// Revision 1.13  2003/02/09 18:40:29  mohor
136
// Overload fixed. Hard synchronization also enabled at the last bit of
137
// interframe.
138
//
139
// Revision 1.12  2003/02/09 02:24:33  mohor
140
// Bosch license warning added. Error counters finished. Overload frames
141
// still need to be fixed.
142
//
143
// Revision 1.11  2003/02/04 14:34:52  mohor
144
// *** empty log message ***
145
//
146
// Revision 1.10  2003/01/31 01:13:38  mohor
147
// backup.
148
//
149
// Revision 1.9  2003/01/15 13:16:48  mohor
150
// When a frame with "remote request" is received, no data is stored to
151
// fifo, just the frame information (identifier, ...). Data length that
152
// is stored is the received data length and not the actual data length
153
// that is stored to fifo.
154
//
155
// Revision 1.8  2003/01/14 17:25:09  mohor
156
// Addresses corrected to decimal values (previously hex).
157
//
158
// Revision 1.7  2003/01/10 17:51:34  mohor
159
// Temporary version (backup).
160
//
161
// Revision 1.6  2003/01/09 21:54:45  mohor
162
// rx fifo added. Not 100 % verified, yet.
163
//
164
// Revision 1.5  2003/01/08 02:10:56  mohor
165
// Acceptance filter added.
166
//
167
// Revision 1.4  2002/12/28 04:13:23  mohor
168
// Backup version.
169
//
170
// Revision 1.3  2002/12/27 00:12:52  mohor
171
// Header changed, testbench improved to send a frame (crc still missing).
172
//
173
// Revision 1.2  2002/12/26 16:00:34  mohor
174
// Testbench define file added. Clock divider register added.
175
//
176
// Revision 1.1.1.1  2002/12/20 16:39:21  mohor
177
// Initial
178
//
179
//
180
//
181
 
182
// synopsys translate_off
183
`include "timescale.v"
184
// synopsys translate_on
185
`include "can_defines.v"
186
 
187
module can_top
188
(
189
  `ifdef CAN_WISHBONE_IF
190
    wb_clk_i,
191
    wb_rst_i,
192
    wb_dat_i,
193
    wb_dat_o,
194
    wb_cyc_i,
195
    wb_stb_i,
196
    wb_we_i,
197
    wb_adr_i,
198
    wb_ack_o,
199
  `else
200
    rst_i,
201
    ale_i,
202
    rd_i,
203
    wr_i,
204
    port_0_io,
205 81 mohor
    cs_can_i,
206 66 mohor
  `endif
207
  clk_i,
208
  rx_i,
209
  tx_o,
210 67 mohor
  irq_on,
211 66 mohor
  clkout_o
212 71 mohor
  // Bist
213
`ifdef CAN_BIST
214
  ,
215
  // debug chain signals
216
  scanb_rst,      // bist scan reset
217
  scanb_clk,      // bist scan clock
218
  scanb_si,       // bist scan serial in
219
  scanb_so,       // bist scan serial out
220
  scanb_en        // bist scan shift enable
221
`endif
222 66 mohor
);
223
 
224
parameter Tp = 1;
225
 
226 81 mohor
 
227 66 mohor
`ifdef CAN_WISHBONE_IF
228
  input        wb_clk_i;
229
  input        wb_rst_i;
230
  input  [7:0] wb_dat_i;
231
  output [7:0] wb_dat_o;
232
  input        wb_cyc_i;
233
  input        wb_stb_i;
234
  input        wb_we_i;
235
  input  [7:0] wb_adr_i;
236
  output       wb_ack_o;
237
 
238
  reg          wb_ack_o;
239
  reg          cs_sync1;
240
  reg          cs_sync2;
241
  reg          cs_sync3;
242
 
243
  reg          cs_ack1;
244
  reg          cs_ack2;
245
  reg          cs_ack3;
246
  reg          cs_sync_rst1;
247
  reg          cs_sync_rst2;
248 81 mohor
  wire         cs_can_i;
249 66 mohor
`else
250
  input        rst_i;
251
  input        ale_i;
252
  input        rd_i;
253
  input        wr_i;
254
  inout  [7:0] port_0_io;
255 81 mohor
  input        cs_can_i;
256 66 mohor
 
257
  reg    [7:0] addr_latched;
258
  reg          wr_i_q;
259
  reg          rd_i_q;
260
`endif
261
 
262
input        clk_i;
263
input        rx_i;
264
output       tx_o;
265 67 mohor
output       irq_on;
266 66 mohor
output       clkout_o;
267
 
268 71 mohor
// Bist
269
`ifdef CAN_BIST
270
input   scanb_rst;      // bist scan reset
271
input   scanb_clk;      // bist scan clock
272
input   scanb_si;       // bist scan serial in
273
output  scanb_so;       // bist scan serial out
274
input   scanb_en;       // bist scan shift enable
275
`endif
276
 
277 66 mohor
reg          data_out_fifo_selected;
278
 
279
 
280 67 mohor
wire         irq_o;
281 66 mohor
wire   [7:0] data_out_fifo;
282
wire   [7:0] data_out_regs;
283
 
284
 
285
/* Mode register */
286
wire         reset_mode;
287
wire         listen_only_mode;
288
wire         acceptance_filter_mode;
289
wire         self_test_mode;
290
 
291
/* Command register */
292
wire         release_buffer;
293
wire         tx_request;
294
wire         abort_tx;
295
wire         self_rx_request;
296
wire         single_shot_transmission;
297 104 tadejm
wire         tx_state;
298
wire         tx_state_q;
299 66 mohor
 
300
/* Arbitration Lost Capture Register */
301
wire         read_arbitration_lost_capture_reg;
302
 
303
/* Error Code Capture Register */
304
wire         read_error_code_capture_reg;
305
wire   [7:0] error_capture_code;
306
 
307
/* Bus Timing 0 register */
308
wire   [5:0] baud_r_presc;
309
wire   [1:0] sync_jump_width;
310
 
311
/* Bus Timing 1 register */
312
wire   [3:0] time_segment1;
313
wire   [2:0] time_segment2;
314
wire         triple_sampling;
315
 
316
/* Error Warning Limit register */
317
wire   [7:0] error_warning_limit;
318
 
319
/* Rx Error Counter register */
320
wire         we_rx_err_cnt;
321
 
322
/* Tx Error Counter register */
323
wire         we_tx_err_cnt;
324
 
325
/* Clock Divider register */
326
wire         extended_mode;
327
 
328
/* This section is for BASIC and EXTENDED mode */
329
/* Acceptance code register */
330
wire   [7:0] acceptance_code_0;
331
 
332
/* Acceptance mask register */
333
wire   [7:0] acceptance_mask_0;
334
/* End: This section is for BASIC and EXTENDED mode */
335
 
336
 
337
/* This section is for EXTENDED mode */
338
/* Acceptance code register */
339
wire   [7:0] acceptance_code_1;
340
wire   [7:0] acceptance_code_2;
341
wire   [7:0] acceptance_code_3;
342
 
343
/* Acceptance mask register */
344
wire   [7:0] acceptance_mask_1;
345
wire   [7:0] acceptance_mask_2;
346
wire   [7:0] acceptance_mask_3;
347
/* End: This section is for EXTENDED mode */
348
 
349
/* Tx data registers. Holding identifier (basic mode), tx frame information (extended mode) and data */
350
wire   [7:0] tx_data_0;
351
wire   [7:0] tx_data_1;
352
wire   [7:0] tx_data_2;
353
wire   [7:0] tx_data_3;
354
wire   [7:0] tx_data_4;
355
wire   [7:0] tx_data_5;
356
wire   [7:0] tx_data_6;
357
wire   [7:0] tx_data_7;
358
wire   [7:0] tx_data_8;
359
wire   [7:0] tx_data_9;
360
wire   [7:0] tx_data_10;
361
wire   [7:0] tx_data_11;
362
wire   [7:0] tx_data_12;
363
/* End: Tx data registers */
364
 
365
wire         cs;
366
 
367
/* Output signals from can_btl module */
368
wire         sample_point;
369
wire         sampled_bit;
370
wire         sampled_bit_q;
371
wire         tx_point;
372
wire         hard_sync;
373
 
374
/* output from can_bsp module */
375
wire         rx_idle;
376
wire         transmitting;
377 104 tadejm
wire         not_first_bit_of_inter;
378 66 mohor
wire         set_reset_mode;
379
wire         node_bus_off;
380
wire         error_status;
381
wire   [7:0] rx_err_cnt;
382
wire   [7:0] tx_err_cnt;
383
wire         rx_err_cnt_dummy;  // The MSB is not displayed. It is just used for easier calculation (no counter overflow).
384
wire         tx_err_cnt_dummy;  // The MSB is not displayed. It is just used for easier calculation (no counter overflow).
385
wire         transmit_status;
386
wire         receive_status;
387
wire         tx_successful;
388
wire         need_to_tx;
389
wire         overrun;
390
wire         info_empty;
391
wire         set_bus_error_irq;
392
wire         set_arbitration_lost_irq;
393
wire   [4:0] arbitration_lost_capture;
394
wire         node_error_passive;
395
wire         node_error_active;
396
wire   [6:0] rx_message_counter;
397
wire         tx_out;
398
wire         tx_oen;
399
 
400
wire         rst;
401
wire         we;
402
wire   [7:0] addr;
403
wire   [7:0] data_in;
404
reg    [7:0] data_out;
405 78 mohor
reg          rx_registered;
406 66 mohor
 
407
/* Connecting can_registers module */
408
can_registers i_can_registers
409
(
410
  .clk(clk_i),
411
  .rst(rst),
412
  .cs(cs),
413
  .we(we),
414
  .addr(addr),
415
  .data_in(data_in),
416
  .data_out(data_out_regs),
417
  .irq(irq_o),
418
 
419
  .sample_point(sample_point),
420
  .transmitting(transmitting),
421
  .set_reset_mode(set_reset_mode),
422
  .node_bus_off(node_bus_off),
423
  .error_status(error_status),
424
  .rx_err_cnt(rx_err_cnt),
425
  .tx_err_cnt(tx_err_cnt),
426
  .transmit_status(transmit_status),
427
  .receive_status(receive_status),
428
  .tx_successful(tx_successful),
429
  .need_to_tx(need_to_tx),
430
  .overrun(overrun),
431
  .info_empty(info_empty),
432
  .set_bus_error_irq(set_bus_error_irq),
433
  .set_arbitration_lost_irq(set_arbitration_lost_irq),
434
  .arbitration_lost_capture(arbitration_lost_capture),
435
  .node_error_passive(node_error_passive),
436
  .node_error_active(node_error_active),
437
  .rx_message_counter(rx_message_counter),
438
 
439
 
440
  /* Mode register */
441
  .reset_mode(reset_mode),
442
  .listen_only_mode(listen_only_mode),
443
  .acceptance_filter_mode(acceptance_filter_mode),
444
  .self_test_mode(self_test_mode),
445
 
446
  /* Command register */
447
  .clear_data_overrun(),
448
  .release_buffer(release_buffer),
449
  .abort_tx(abort_tx),
450
  .tx_request(tx_request),
451
  .self_rx_request(self_rx_request),
452
  .single_shot_transmission(single_shot_transmission),
453 104 tadejm
  .tx_state(tx_state),
454
  .tx_state_q(tx_state_q),
455 66 mohor
 
456
  /* Arbitration Lost Capture Register */
457
  .read_arbitration_lost_capture_reg(read_arbitration_lost_capture_reg),
458
 
459
  /* Error Code Capture Register */
460
  .read_error_code_capture_reg(read_error_code_capture_reg),
461
  .error_capture_code(error_capture_code),
462
 
463
  /* Bus Timing 0 register */
464
  .baud_r_presc(baud_r_presc),
465
  .sync_jump_width(sync_jump_width),
466
 
467
  /* Bus Timing 1 register */
468
  .time_segment1(time_segment1),
469
  .time_segment2(time_segment2),
470
  .triple_sampling(triple_sampling),
471
 
472
  /* Error Warning Limit register */
473
  .error_warning_limit(error_warning_limit),
474
 
475
  /* Rx Error Counter register */
476
  .we_rx_err_cnt(we_rx_err_cnt),
477
 
478
  /* Tx Error Counter register */
479
  .we_tx_err_cnt(we_tx_err_cnt),
480
 
481
  /* Clock Divider register */
482
  .extended_mode(extended_mode),
483
  .clkout(clkout_o),
484
 
485
  /* This section is for BASIC and EXTENDED mode */
486
  /* Acceptance code register */
487
  .acceptance_code_0(acceptance_code_0),
488
 
489
  /* Acceptance mask register */
490
  .acceptance_mask_0(acceptance_mask_0),
491
  /* End: This section is for BASIC and EXTENDED mode */
492
 
493
  /* This section is for EXTENDED mode */
494
  /* Acceptance code register */
495
  .acceptance_code_1(acceptance_code_1),
496
  .acceptance_code_2(acceptance_code_2),
497
  .acceptance_code_3(acceptance_code_3),
498
 
499
  /* Acceptance mask register */
500
  .acceptance_mask_1(acceptance_mask_1),
501
  .acceptance_mask_2(acceptance_mask_2),
502
  .acceptance_mask_3(acceptance_mask_3),
503
  /* End: This section is for EXTENDED mode */
504
 
505
  /* Tx data registers. Holding identifier (basic mode), tx frame information (extended mode) and data */
506
  .tx_data_0(tx_data_0),
507
  .tx_data_1(tx_data_1),
508
  .tx_data_2(tx_data_2),
509
  .tx_data_3(tx_data_3),
510
  .tx_data_4(tx_data_4),
511
  .tx_data_5(tx_data_5),
512
  .tx_data_6(tx_data_6),
513
  .tx_data_7(tx_data_7),
514
  .tx_data_8(tx_data_8),
515
  .tx_data_9(tx_data_9),
516
  .tx_data_10(tx_data_10),
517
  .tx_data_11(tx_data_11),
518
  .tx_data_12(tx_data_12)
519
  /* End: Tx data registers */
520
);
521
 
522
 
523 67 mohor
assign irq_on = ~irq_o;
524 66 mohor
 
525
 
526
/* Connecting can_btl module */
527
can_btl i_can_btl
528
(
529
  .clk(clk_i),
530
  .rst(rst),
531 78 mohor
  .rx(rx_registered),
532 66 mohor
 
533
  /* Bus Timing 0 register */
534
  .baud_r_presc(baud_r_presc),
535
  .sync_jump_width(sync_jump_width),
536
 
537
  /* Bus Timing 1 register */
538
  .time_segment1(time_segment1),
539
  .time_segment2(time_segment2),
540
  .triple_sampling(triple_sampling),
541
 
542
  /* Output signals from this module */
543
  .sample_point(sample_point),
544
  .sampled_bit(sampled_bit),
545
  .sampled_bit_q(sampled_bit_q),
546
  .tx_point(tx_point),
547
  .hard_sync(hard_sync),
548
 
549
 
550
  /* output from can_bsp module */
551
  .rx_idle(rx_idle),
552 104 tadejm
  .not_first_bit_of_inter(not_first_bit_of_inter),
553 100 mohor
  .transmitting(transmitting),
554
  .go_rx_inter(go_rx_inter)
555 66 mohor
 
556
 
557
 
558
);
559
 
560
 
561
 
562
can_bsp i_can_bsp
563
(
564
  .clk(clk_i),
565
  .rst(rst),
566
 
567
  /* From btl module */
568
  .sample_point(sample_point),
569
  .sampled_bit(sampled_bit),
570
  .sampled_bit_q(sampled_bit_q),
571
  .tx_point(tx_point),
572
  .hard_sync(hard_sync),
573
 
574
  .addr(addr),
575
  .data_in(data_in),
576
  .data_out(data_out_fifo),
577
  .fifo_selected(data_out_fifo_selected),
578
 
579
  /* Mode register */
580
  .reset_mode(reset_mode),
581
  .listen_only_mode(listen_only_mode),
582
  .acceptance_filter_mode(acceptance_filter_mode),
583
  .self_test_mode(self_test_mode),
584
 
585
  /* Command register */
586
  .release_buffer(release_buffer),
587
  .tx_request(tx_request),
588
  .abort_tx(abort_tx),
589
  .self_rx_request(self_rx_request),
590
  .single_shot_transmission(single_shot_transmission),
591 104 tadejm
  .tx_state(tx_state),
592
  .tx_state_q(tx_state_q),
593 66 mohor
 
594
  /* Arbitration Lost Capture Register */
595
  .read_arbitration_lost_capture_reg(read_arbitration_lost_capture_reg),
596
 
597
  /* Error Code Capture Register */
598
  .read_error_code_capture_reg(read_error_code_capture_reg),
599
  .error_capture_code(error_capture_code),
600
 
601
  /* Error Warning Limit register */
602
  .error_warning_limit(error_warning_limit),
603
 
604
  /* Rx Error Counter register */
605
  .we_rx_err_cnt(we_rx_err_cnt),
606
 
607
  /* Tx Error Counter register */
608
  .we_tx_err_cnt(we_tx_err_cnt),
609
 
610
  /* Clock Divider register */
611
  .extended_mode(extended_mode),
612
 
613
  /* output from can_bsp module */
614
  .rx_idle(rx_idle),
615
  .transmitting(transmitting),
616 100 mohor
  .go_rx_inter(go_rx_inter),
617 104 tadejm
  .not_first_bit_of_inter(not_first_bit_of_inter),
618 66 mohor
  .set_reset_mode(set_reset_mode),
619
  .node_bus_off(node_bus_off),
620
  .error_status(error_status),
621
  .rx_err_cnt({rx_err_cnt_dummy, rx_err_cnt[7:0]}),   // The MSB is not displayed. It is just used for easier calculation (no counter overflow).
622
  .tx_err_cnt({tx_err_cnt_dummy, tx_err_cnt[7:0]}),   // The MSB is not displayed. It is just used for easier calculation (no counter overflow).
623
  .transmit_status(transmit_status),
624
  .receive_status(receive_status),
625
  .tx_successful(tx_successful),
626
  .need_to_tx(need_to_tx),
627
  .overrun(overrun),
628
  .info_empty(info_empty),
629
  .set_bus_error_irq(set_bus_error_irq),
630
  .set_arbitration_lost_irq(set_arbitration_lost_irq),
631
  .arbitration_lost_capture(arbitration_lost_capture),
632
  .node_error_passive(node_error_passive),
633
  .node_error_active(node_error_active),
634
  .rx_message_counter(rx_message_counter),
635
 
636
  /* This section is for BASIC and EXTENDED mode */
637
  /* Acceptance code register */
638
  .acceptance_code_0(acceptance_code_0),
639
 
640
  /* Acceptance mask register */
641
  .acceptance_mask_0(acceptance_mask_0),
642
  /* End: This section is for BASIC and EXTENDED mode */
643
 
644
  /* This section is for EXTENDED mode */
645
  /* Acceptance code register */
646
  .acceptance_code_1(acceptance_code_1),
647
  .acceptance_code_2(acceptance_code_2),
648
  .acceptance_code_3(acceptance_code_3),
649
 
650
  /* Acceptance mask register */
651
  .acceptance_mask_1(acceptance_mask_1),
652
  .acceptance_mask_2(acceptance_mask_2),
653
  .acceptance_mask_3(acceptance_mask_3),
654
  /* End: This section is for EXTENDED mode */
655
 
656
  /* Tx data registers. Holding identifier (basic mode), tx frame information (extended mode) and data */
657
  .tx_data_0(tx_data_0),
658
  .tx_data_1(tx_data_1),
659
  .tx_data_2(tx_data_2),
660
  .tx_data_3(tx_data_3),
661
  .tx_data_4(tx_data_4),
662
  .tx_data_5(tx_data_5),
663
  .tx_data_6(tx_data_6),
664
  .tx_data_7(tx_data_7),
665
  .tx_data_8(tx_data_8),
666
  .tx_data_9(tx_data_9),
667
  .tx_data_10(tx_data_10),
668
  .tx_data_11(tx_data_11),
669
  .tx_data_12(tx_data_12),
670
  /* End: Tx data registers */
671
 
672
  /* Tx signal */
673
  .tx(tx_out),
674
  .tx_oen(tx_oen)
675 95 simons
 
676
`ifdef CAN_BIST
677
  ,
678
  /* BIST signals */
679
  .scanb_rst(scanb_rst),
680
  .scanb_clk(scanb_clk),
681
  .scanb_si(scanb_si),
682
  .scanb_so(scanb_so),
683
  .scanb_en(scanb_en)
684
`endif
685 66 mohor
);
686
 
687
assign tx_o = tx_oen? 1'bz : tx_out;
688
 
689
 
690
// Multiplexing wb_dat_o from registers and rx fifo
691
always @ (extended_mode or addr or reset_mode)
692
begin
693
  if (extended_mode & (~reset_mode) & ((addr >= 8'd16) && (addr <= 8'd28)) | (~extended_mode) & ((addr >= 8'd20) && (addr <= 8'd29)))
694
    data_out_fifo_selected <= 1'b1;
695
  else
696
    data_out_fifo_selected <= 1'b0;
697
end
698
 
699
 
700
always @ (posedge clk_i)
701
begin
702
//  if (wb_cyc_i & (~wb_we_i))
703
  if (cs & (~we))
704
    begin
705
      if (data_out_fifo_selected)
706
        data_out <=#Tp data_out_fifo;
707
      else
708
        data_out <=#Tp data_out_regs;
709
    end
710
end
711
 
712
 
713
 
714 78 mohor
always @ (posedge clk_i or posedge rst)
715
begin
716
  if (rst)
717
    rx_registered <= 1'b1;
718
  else
719
    rx_registered <=#Tp rx_i;
720
end
721
 
722
 
723
 
724 66 mohor
`ifdef CAN_WISHBONE_IF
725 81 mohor
 
726
  assign cs_can_i = 1'b1;
727
 
728 66 mohor
  // Combining wb_cyc_i and wb_stb_i signals to cs signal. Than synchronizing to clk_i clock domain. 
729
  always @ (posedge clk_i or posedge rst)
730
  begin
731
    if (rst)
732
      begin
733
        cs_sync1     <= 1'b0;
734
        cs_sync2     <= 1'b0;
735
        cs_sync3     <= 1'b0;
736
        cs_sync_rst1 <= 1'b0;
737
        cs_sync_rst2 <= 1'b0;
738
      end
739
    else
740
      begin
741
        cs_sync1     <=#Tp wb_cyc_i & wb_stb_i & (~cs_sync_rst2) & cs_can_i;
742
        cs_sync2     <=#Tp cs_sync1            & (~cs_sync_rst2);
743
        cs_sync3     <=#Tp cs_sync2            & (~cs_sync_rst2);
744
        cs_sync_rst1 <=#Tp cs_ack3;
745
        cs_sync_rst2 <=#Tp cs_sync_rst1;
746
      end
747
  end
748
 
749
 
750
  assign cs = cs_sync2 & (~cs_sync3);
751
 
752
 
753
  always @ (posedge wb_clk_i)
754
  begin
755
    cs_ack1 <=#Tp cs_sync3;
756
    cs_ack2 <=#Tp cs_ack1;
757
    cs_ack3 <=#Tp cs_ack2;
758
  end
759
 
760
 
761
 
762
  // Generating acknowledge signal
763
  always @ (posedge wb_clk_i)
764
  begin
765
    wb_ack_o <=#Tp (cs_ack2 & (~cs_ack3));
766
  end
767
 
768
 
769
  assign rst      = wb_rst_i;
770
  assign we       = wb_we_i;
771
  assign addr     = wb_adr_i;
772
  assign data_in  = wb_dat_i;
773
  assign wb_dat_o = data_out;
774
 
775
 
776
`else
777
 
778
  // Latching address
779
  always @ (negedge clk_i or posedge rst)
780
  begin
781
    if (rst)
782
      addr_latched <= 8'h0;
783
    else if (ale_i)
784
      addr_latched <=#Tp port_0_io;
785
  end
786
 
787
 
788
  // Generating delayed wr_i and rd_i signals
789
  always @ (posedge clk_i or posedge rst)
790
  begin
791
    if (rst)
792
      begin
793
        wr_i_q <= 1'b0;
794
        rd_i_q <= 1'b0;
795
      end
796
    else
797
      begin
798
        wr_i_q <=#Tp wr_i;
799
        rd_i_q <=#Tp rd_i;
800
      end
801
  end
802
 
803
 
804
  assign cs = ((wr_i & (~wr_i_q)) | (rd_i & (~rd_i_q))) & cs_can_i;
805
 
806
 
807
  assign rst       = rst_i;
808
  assign we        = wr_i;
809
  assign addr      = addr_latched;
810
  assign data_in   = port_0_io;
811
  assign port_0_io = (cs_can_i & rd_i)? data_out : 8'hz;
812
 
813
`endif
814
 
815 78 mohor
 
816 66 mohor
endmodule

powered by: WebSVN 2.1.0

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