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 78

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

powered by: WebSVN 2.1.0

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