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

Subversion Repositories turbo8051

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

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
 
125
 
126
 
127
uart_cfg u_cfg (
128
 
129
             . mclk          (app_clk),
130
             . reset_n       (app_reset_n),
131
 
132
        // Reg Bus Interface Signal
133
             . reg_cs        (reg_cs),
134
             . reg_wr        (reg_wr),
135
             . reg_addr      (reg_addr),
136
             . reg_wdata     (reg_wdata),
137
             . reg_be        (reg_be),
138
 
139
            // Outputs
140
            . reg_rdata      (reg_rdata),
141
            . reg_ack        (reg_ack),
142
 
143
 
144
       // configuration
145
            . cfg_tx_enable       (cfg_tx_enable),
146
            . cfg_rx_enable       (cfg_rx_enable),
147
            . cfg_stop_bit        (cfg_stop_bit),
148
            . cfg_pri_mod         (cfg_pri_mod),
149
 
150
            . frm_error_o         (frm_error_o),
151
            . par_error_o         (par_error_o),
152
            . rx_fifo_full_err_o  (rx_fifo_full_err_o)
153
 
154
        );
155
 
156
 
157
 
158
 
159
 
160
uart_txfsm u_txfsm (
161
               . reset_n           ( line_reset_n      ),
162
               . baud_clk_16x      ( line_clk_16x      ),
163
 
164
               . cfg_tx_enable     ( cfg_tx_enable     ),
165
               . cfg_stop_bit      ( cfg_stop_bit      ),
166
               . cfg_pri_mod       ( cfg_pri_mod       ),
167
 
168
       // FIFO control signal
169
               . fifo_empty        ( tx_fifo_rd_empty  ),
170
               . fifo_rd           ( tx_fifo_rd        ),
171
               . fifo_data         ( tx_fifo_rd_data   ),
172
 
173
          // Line Interface
174
               . so                ( so                )
175
          );
176
 
177
 
178
uart_rxfsm u_rxfsm (
179
               . reset_n           (  line_reset_n     ),
180
               . baud_clk_16x      (  line_clk_16x     ) ,
181
 
182
               . cfg_rx_enable     (  cfg_rx_enable    ),
183
               . cfg_stop_bit      (  cfg_stop_bit     ),
184
               . cfg_pri_mod       (  cfg_pri_mod      ),
185
 
186
               . error_ind         (  error_ind        ),
187
 
188
       // FIFO control signal
189
               .  fifo_aval        ( !rx_fifo_wr_full  ),
190
               .  fifo_wr          ( rx_fifo_wr        ),
191
               .  fifo_data        ( rx_fifo_wr_data   ),
192
 
193
          // Line Interface
194
               .  si               (si_ss              )
195
          );
196
 
197
async_fifo #(W,DP,0,0) u_rxfifo (
198
               .wr_clk             (line_clk_16x       ),
199
               .wr_reset_n         (line_reset_n       ),
200
               .wr_en              (rx_fifo_wr         ),
201
               .wr_data            (rx_fifo_wr_data    ),
202
               .full               (rx_fifo_wr_full    ), // sync'ed to wr_clk
203
               .wr_total_free_space(                   ),
204
 
205
               .rd_clk             (app_clk            ),
206
               .rd_reset_n         (app_reset_n        ),
207
               .rd_en              (!app_rxfifo_empty  ),
208
               .empty              (app_rxfifo_empty   ),  // sync'ed to rd_clk
209
               .rd_total_aval      (                   ),
210
               .rd_data            (app_rxfifo_rddata  )
211
                   );
212
 
213
async_fifo #(W,DP,0,0) u_txfifo  (
214
               .wr_clk             (app_clk            ),
215
               .wr_reset_n         (app_reset_n        ),
216
               .wr_en              (!app_rxfifo_empty  ),
217
               .wr_data            (app_rxfifo_rddata  ),
218
               .full               (                   ), // sync'ed to wr_clk
219
               .wr_total_free_space(                   ),
220
 
221
               .rd_clk             (line_clk_16x       ),
222
               .rd_reset_n         (line_reset_n       ),
223
               .rd_en              (tx_fifo_rd         ),
224
               .empty              (tx_fifo_rd_empty   ),  // sync'ed to rd_clk
225
               .rd_total_aval      (                   ),
226
               .rd_data            (tx_fifo_rd_data    )
227
                   );
228
 
229
 
230
double_sync_low   u_si_sync (
231
               . in_data           ( si                ),
232
               . out_clk           (line_clk_16x       ),
233
               . out_rst_n         (line_reset_n       ),
234
               . out_data          (si_ss              )
235
          );
236
 
237
wire   frm_error          = (error_ind == 2'b01);
238
wire   par_error          = (error_ind == 2'b10);
239
wire   rx_fifo_full_err   = (error_ind == 2'b11);
240
 
241
double_sync_low   u_frm_err (
242
               . in_data           ( frm_error        ),
243
               . out_clk           ( app_clk          ),
244
               . out_rst_n         ( app_reset_n      ),
245
               . out_data          ( frm_error_o      )
246
          );
247
 
248
double_sync_low   u_par_err (
249
               . in_data           ( par_error        ),
250
               . out_clk           ( app_clk          ),
251
               . out_rst_n         ( app_reset_n      ),
252
               . out_data          ( par_error_o      )
253
          );
254
 
255
double_sync_low   u_rxfifo_err (
256
               . in_data           ( rx_fifo_full_err ),
257
               . out_clk           ( app_clk          ),
258
               . out_rst_n         ( app_reset_n      ),
259
               . out_data          ( rx_fifo_full_err_o  )
260
          );
261
 
262
 
263
endmodule

powered by: WebSVN 2.1.0

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