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

Subversion Repositories can

[/] [can/] [tags/] [rel_22/] [rtl/] [verilog/] [can_top.v] - Blame information for rev 81

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

powered by: WebSVN 2.1.0

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