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

Subversion Repositories can

[/] [can/] [tags/] [rel_10/] [rtl/] [verilog/] [can_top.v] - Blame information for rev 100

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

powered by: WebSVN 2.1.0

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