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

Subversion Repositories oms8051mini

[/] [oms8051mini/] [trunk/] [rtl/] [uart/] [uart_core_nf.v] - Blame information for rev 37

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

Line No. Rev Author Line
1 19 dinesha
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  UART CORE without FIFO                                      ////
4
////                                                              ////
5
////  This file is part of the oms8051mini cores project          ////
6
////  http://www.opencores.org/cores/oms8051min/                  ////
7
////                                                              ////
8
////  Description                                                 ////
9
////  Uart FIFO.                                                  ////
10
////                                                              ////
11
////  To Do:                                                      ////
12
////    nothing                                                   ////
13
////                                                              ////
14
////  Author(s):                                                  ////
15
////      - Dinesh Annayya, dinesha@opencores.org                 ////
16
////                                                              ////
17
//////////////////////////////////////////////////////////////////////
18
////  Revision:                                                   ////
19
////  v-0: 27 Nov 2016                                            ////
20
////       A. rtl file picked from                                ////
21
////           http://www.opencores.org/cores/uart2spi/           ////
22
//////////////////////////////////////////////////////////////////////
23
////                                                              ////
24
//// Copyright (C) 2000 Authors and OPENCORES.ORG                 ////
25
////                                                              ////
26
//// This source file may be used and distributed without         ////
27
//// restriction provided that this copyright statement is not    ////
28
//// removed from the file and that any derivative work contains  ////
29
//// the original copyright notice and the associated disclaimer. ////
30
////                                                              ////
31
//// This source file is free software; you can redistribute it   ////
32
//// and/or modify it under the terms of the GNU Lesser General   ////
33
//// Public License as published by the Free Software Foundation; ////
34
//// either version 2.1 of the License, or (at your option) any   ////
35
//// later version.                                               ////
36
////                                                              ////
37
//// This source is distributed in the hope that it will be       ////
38
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
39
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
40
//// PURPOSE.  See the GNU Lesser General Public License for more ////
41
//// details.                                                     ////
42
////                                                              ////
43
//// You should have received a copy of the GNU Lesser General    ////
44
//// Public License along with this source; if not, download it   ////
45
//// from http://www.opencores.org/lgpl.shtml                     ////
46
////                                                              ////
47
//////////////////////////////////////////////////////////////////////
48
module uart_core_nf (
49
        line_reset_n ,
50
        line_clk ,
51
 
52
        // configuration control
53
        cfg_tx_enable  , // Enable Transmit Path
54
        cfg_rx_enable  , // Enable Received Path
55
        cfg_stop_bit   , // 0 -> 1 Start , 1 -> 2 Stop Bits
56
        cfg_pri_mod    , // priority mode, 0 -> nop, 1 -> Even, 2 -> Odd
57
        cfg_baud_16x   ,
58
 
59
    // TXD Information
60
        tx_data_avail,
61
        tx_rd,
62
        tx_data,
63
 
64
 
65
    // RXD Information
66
        rx_ready,
67
        rx_wr,
68
        rx_data,
69
 
70
       // Status information
71
        frm_error,
72
        par_error,
73
 
74
        baud_clk_16x,
75
 
76
       // Line Interface
77
        rxd,
78
        txd
79
 
80
     );
81
 
82
 
83
 
84
//---------------------------------
85
// Global Dec
86
// ---------------------------------
87
 
88
input        line_reset_n         ; // line reset
89
input        line_clk             ; // line clock
90
 
91
//-------------------------------------
92
// Configuration 
93
// -------------------------------------
94
input         cfg_tx_enable        ; // Tx Enable
95
input         cfg_rx_enable        ; // Rx Enable
96
input         cfg_stop_bit         ; // 0 -> 1 Stop, 1 -> 2 Stop
97
input   [1:0] cfg_pri_mod          ; // priority mode, 0 -> nop, 1 -> Even, 2 -> Odd
98
input   [11:0] cfg_baud_16x        ; // 16x Baud clock generation
99
 
100
//--------------------------------------
101
// TXD Path
102
// -------------------------------------
103
input         tx_data_avail        ; // Indicate valid TXD Data 
104
input [7:0]   tx_data              ; // TXD Data to be transmited
105
output        tx_rd                ; // Indicate TXD Data Been Read
106
 
107
 
108
//--------------------------------------
109
// RXD Path
110
// -------------------------------------
111
input         rx_ready            ; // Indicate Ready to accept the Read Data
112
output [7:0]  rx_data             ; // RXD Data 
113
output        rx_wr               ; // Valid RXD Data
114
 
115
 
116
//--------------------------------------
117
// ERROR Indication
118
// -------------------------------------
119
output        frm_error            ; // framing error
120
output        par_error            ; // par error
121
 
122
output        baud_clk_16x         ; // 16x Baud clock
123
 
124
 
125
//-------------------------------------
126
// Line Interface
127
// -------------------------------------
128
input         rxd                  ; // uart rxd
129
output        txd                  ; // uart txd
130
 
131
// Wire Declaration
132
 
133
wire [1  : 0]   error_ind          ;
134
 
135
 
136
// 16x Baud clock generation
137
// Example: to generate 19200 Baud clock from 50Mhz Link clock
138
//    50 * 1000 * 1000 / (2 + cfg_baud_16x) = 19200 * 16
139
//    cfg_baud_16x = 0xA0 (160)
140
 
141
clk_ctl #(11) u_clk_ctl (
142
   // Outputs
143
       .clk_o          (baud_clk_16x),
144
 
145
   // Inputs
146
       .mclk           (line_clk),
147
       .reset_n        (line_reset_n),
148
       .clk_div_ratio  (cfg_baud_16x)
149
   );
150
 
151
 
152
uart_txfsm u_txfsm (
153
               . reset_n           ( line_reset_n      ),
154
               . baud_clk_16x      ( baud_clk_16x      ),
155
 
156
               . cfg_tx_enable     ( cfg_tx_enable     ),
157
               . cfg_stop_bit      ( cfg_stop_bit      ),
158
               . cfg_pri_mod       ( cfg_pri_mod       ),
159
 
160
       // FIFO control signal
161
               . fifo_empty        ( !tx_data_avail    ),
162
               . fifo_rd           ( tx_rd             ),
163
               . fifo_data         ( tx_data           ),
164
 
165
          // Line Interface
166
               . so                ( txd                )
167
          );
168
 
169
 
170
uart_rxfsm u_rxfsm (
171
               . reset_n           (  line_reset_n     ),
172
               . baud_clk_16x      (  baud_clk_16x     ) ,
173
 
174
               . cfg_rx_enable     (  cfg_rx_enable    ),
175
               . cfg_stop_bit      (  cfg_stop_bit     ),
176
               . cfg_pri_mod       (  cfg_pri_mod      ),
177
 
178
               . error_ind         (  error_ind        ),
179
 
180
       // FIFO control signal
181
               .  fifo_aval        ( rx_ready          ),
182
               .  fifo_wr          ( rx_wr             ),
183
               .  fifo_data        ( rx_data           ),
184
 
185
          // Line Interface
186
               .  si               (rxd_ss             )
187
          );
188
 
189
// Double Sync the Rxd
190
double_sync_low   u_rxd_sync (
191
               . in_data           ( rxd               ),
192
               . out_clk           (baud_clk_16x       ),
193
               . out_rst_n         (line_reset_n       ),
194
               . out_data          (rxd_ss             )
195
          );
196
 
197
wire   frm_error          = (error_ind == 2'b01);
198
wire   par_error          = (error_ind == 2'b10);
199
 
200
 
201
 
202
endmodule

powered by: WebSVN 2.1.0

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