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

Subversion Repositories turbo8051

[/] [turbo8051/] [trunk/] [rtl/] [uart/] [uart_core.v] - Blame information for rev 75

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

Line No. Rev Author Line
1 9 dinesha
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  Tubo 8051 cores UART Interface Module                       ////
4
////                                                              ////
5
////  This file is part of the Turbo 8051 cores project           ////
6
////  http://www.opencores.org/cores/turbo8051/                   ////
7
////                                                              ////
8
////  Description                                                 ////
9
////  Turbo 8051 definitions.                                     ////
10
////                                                              ////
11
////  To Do:                                                      ////
12
////    nothing                                                   ////
13
////                                                              ////
14
////  Author(s):                                                  ////
15
////      - Dinesh Annayya, dinesha@opencores.org                 ////
16
////                                                              ////
17
//////////////////////////////////////////////////////////////////////
18
////                                                              ////
19
//// Copyright (C) 2000 Authors and OPENCORES.ORG                 ////
20
////                                                              ////
21
//// This source file may be used and distributed without         ////
22
//// restriction provided that this copyright statement is not    ////
23
//// removed from the file and that any derivative work contains  ////
24
//// the original copyright notice and the associated disclaimer. ////
25
////                                                              ////
26
//// This source file is free software; you can redistribute it   ////
27
//// and/or modify it under the terms of the GNU Lesser General   ////
28
//// Public License as published by the Free Software Foundation; ////
29
//// either version 2.1 of the License, or (at your option) any   ////
30
//// later version.                                               ////
31
////                                                              ////
32
//// This source is distributed in the hope that it will be       ////
33
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
34
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
35
//// PURPOSE.  See the GNU Lesser General Public License for more ////
36
//// details.                                                     ////
37
////                                                              ////
38
//// You should have received a copy of the GNU Lesser General    ////
39
//// Public License along with this source; if not, download it   ////
40
//// from http://www.opencores.org/lgpl.shtml                     ////
41
////                                                              ////
42
//////////////////////////////////////////////////////////////////////
43
module uart_core
44
 
45
     (
46
        line_reset_n ,
47
        line_clk_16x ,
48
 
49
        app_reset_n ,
50
        app_clk ,
51
 
52
        // Reg Bus Interface Signal
53
        reg_cs,
54
        reg_wr,
55
        reg_addr,
56
        reg_wdata,
57
        reg_be,
58
 
59
        // Outputs
60
        reg_rdata,
61
        reg_ack,
62
 
63
       // Line Interface
64
        si,
65
        so
66
 
67
     );
68
 
69
 
70
 
71
 
72
parameter W  = 8'd8;
73
parameter DP = 8'd16;
74
parameter AW = (DP == 2)   ? 1 :
75
               (DP == 4)   ? 2 :
76
               (DP == 8)   ? 3 :
77
               (DP == 16)  ? 4 :
78
               (DP == 32)  ? 5 :
79
               (DP == 64)  ? 6 :
80
               (DP == 128) ? 7 :
81
               (DP == 256) ? 8 : 0;
82
 
83
 
84
 
85
input        line_reset_n         ; // line reset
86
input        line_clk_16x         ; // line clock
87
 
88
input        app_reset_n          ; // application reset
89
input        app_clk              ; // application clock
90
 
91
//---------------------------------
92
// Reg Bus Interface Signal
93
//---------------------------------
94
input             reg_cs         ;
95
input             reg_wr         ;
96
input [3:0]       reg_addr       ;
97
input [31:0]      reg_wdata      ;
98
input [3:0]       reg_be         ;
99
 
100
// Outputs
101
output [31:0]     reg_rdata      ;
102
output            reg_ack     ;
103
 
104
// Line Interface
105
input         si                  ; // uart si
106
output        so                  ; // uart so
107
 
108
// Wire Declaration
109
 
110
wire [W-1: 0]   tx_fifo_rd_data;
111
wire [W-1: 0]   rx_fifo_wr_data;
112
wire [W-1: 0]   app_rxfifo_rddata;
113
wire [1  : 0]   error_ind;
114
 
115
// Wire 
116
wire         cfg_tx_enable        ; // Tx Enable
117
wire         cfg_rx_enable        ; // Rx Enable
118
wire         cfg_stop_bit         ; // 0 -> 1 Stop, 1 -> 2 Stop
119
wire   [1:0] cfg_pri_mod          ; // priority mode, 0 -> nop, 1 -> Even, 2 -> Odd
120
 
121
wire        frm_error_o          ; // framing error
122
wire        par_error_o          ; // par error
123
wire        rx_fifo_full_err_o   ; // rx fifo full error
124 75 dinesha
wire        rx_fifo_wr_full      ;
125
wire        app_rxfifo_empty     ;
126 9 dinesha
 
127
 
128
uart_cfg u_cfg (
129
 
130
             . mclk          (app_clk),
131
             . reset_n       (app_reset_n),
132
 
133
        // Reg Bus Interface Signal
134
             . reg_cs        (reg_cs),
135
             . reg_wr        (reg_wr),
136
             . reg_addr      (reg_addr),
137
             . reg_wdata     (reg_wdata),
138
             . reg_be        (reg_be),
139
 
140
            // Outputs
141
            . reg_rdata      (reg_rdata),
142
            . reg_ack        (reg_ack),
143
 
144
 
145
       // configuration
146
            . cfg_tx_enable       (cfg_tx_enable),
147
            . cfg_rx_enable       (cfg_rx_enable),
148
            . cfg_stop_bit        (cfg_stop_bit),
149
            . cfg_pri_mod         (cfg_pri_mod),
150
 
151
            . frm_error_o         (frm_error_o),
152
            . par_error_o         (par_error_o),
153
            . rx_fifo_full_err_o  (rx_fifo_full_err_o)
154
 
155
        );
156
 
157
 
158
 
159
 
160
 
161
uart_txfsm u_txfsm (
162
               . reset_n           ( line_reset_n      ),
163
               . baud_clk_16x      ( line_clk_16x      ),
164
 
165
               . cfg_tx_enable     ( cfg_tx_enable     ),
166
               . cfg_stop_bit      ( cfg_stop_bit      ),
167
               . cfg_pri_mod       ( cfg_pri_mod       ),
168
 
169
       // FIFO control signal
170
               . fifo_empty        ( tx_fifo_rd_empty  ),
171
               . fifo_rd           ( tx_fifo_rd        ),
172
               . fifo_data         ( tx_fifo_rd_data   ),
173
 
174
          // Line Interface
175
               . so                ( so                )
176
          );
177
 
178
 
179
uart_rxfsm u_rxfsm (
180
               . reset_n           (  line_reset_n     ),
181
               . baud_clk_16x      (  line_clk_16x     ) ,
182
 
183
               . cfg_rx_enable     (  cfg_rx_enable    ),
184
               . cfg_stop_bit      (  cfg_stop_bit     ),
185
               . cfg_pri_mod       (  cfg_pri_mod      ),
186
 
187
               . error_ind         (  error_ind        ),
188
 
189
       // FIFO control signal
190
               .  fifo_aval        ( !rx_fifo_wr_full  ),
191
               .  fifo_wr          ( rx_fifo_wr        ),
192
               .  fifo_data        ( rx_fifo_wr_data   ),
193
 
194
          // Line Interface
195
               .  si               (si_ss              )
196
          );
197
 
198
async_fifo #(W,DP,0,0) u_rxfifo (
199
               .wr_clk             (line_clk_16x       ),
200
               .wr_reset_n         (line_reset_n       ),
201
               .wr_en              (rx_fifo_wr         ),
202
               .wr_data            (rx_fifo_wr_data    ),
203
               .full               (rx_fifo_wr_full    ), // sync'ed to wr_clk
204
               .wr_total_free_space(                   ),
205
 
206
               .rd_clk             (app_clk            ),
207
               .rd_reset_n         (app_reset_n        ),
208
               .rd_en              (!app_rxfifo_empty  ),
209
               .empty              (app_rxfifo_empty   ),  // sync'ed to rd_clk
210
               .rd_total_aval      (                   ),
211
               .rd_data            (app_rxfifo_rddata  )
212
                   );
213
 
214
async_fifo #(W,DP,0,0) u_txfifo  (
215
               .wr_clk             (app_clk            ),
216
               .wr_reset_n         (app_reset_n        ),
217
               .wr_en              (!app_rxfifo_empty  ),
218
               .wr_data            (app_rxfifo_rddata  ),
219
               .full               (                   ), // sync'ed to wr_clk
220
               .wr_total_free_space(                   ),
221
 
222
               .rd_clk             (line_clk_16x       ),
223
               .rd_reset_n         (line_reset_n       ),
224
               .rd_en              (tx_fifo_rd         ),
225
               .empty              (tx_fifo_rd_empty   ),  // sync'ed to rd_clk
226
               .rd_total_aval      (                   ),
227
               .rd_data            (tx_fifo_rd_data    )
228
                   );
229
 
230
 
231
double_sync_low   u_si_sync (
232
               . in_data           ( si                ),
233
               . out_clk           (line_clk_16x       ),
234
               . out_rst_n         (line_reset_n       ),
235
               . out_data          (si_ss              )
236
          );
237
 
238
wire   frm_error          = (error_ind == 2'b01);
239
wire   par_error          = (error_ind == 2'b10);
240
wire   rx_fifo_full_err   = (error_ind == 2'b11);
241
 
242
double_sync_low   u_frm_err (
243
               . in_data           ( frm_error        ),
244
               . out_clk           ( app_clk          ),
245
               . out_rst_n         ( app_reset_n      ),
246
               . out_data          ( frm_error_o      )
247
          );
248
 
249
double_sync_low   u_par_err (
250
               . in_data           ( par_error        ),
251
               . out_clk           ( app_clk          ),
252
               . out_rst_n         ( app_reset_n      ),
253
               . out_data          ( par_error_o      )
254
          );
255
 
256
double_sync_low   u_rxfifo_err (
257
               . in_data           ( rx_fifo_full_err ),
258
               . out_clk           ( app_clk          ),
259
               . out_rst_n         ( app_reset_n      ),
260
               . out_data          ( rx_fifo_full_err_o  )
261
          );
262
 
263
 
264
endmodule

powered by: WebSVN 2.1.0

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