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

Subversion Repositories can

[/] [can/] [tags/] [rel_9/] [rtl/] [verilog/] [can_top.v] - Blame information for rev 161

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

powered by: WebSVN 2.1.0

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