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

Subversion Repositories oms8051mini

[/] [oms8051mini/] [trunk/] [rtl/] [uart/] [uart_core.v] - Diff between revs 2 and 6

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 2 Rev 6
Line 12... Line 12...
////    nothing                                                   ////
////    nothing                                                   ////
////                                                              ////
////                                                              ////
////  Author(s):                                                  ////
////  Author(s):                                                  ////
////      - Dinesh Annayya, dinesha@opencores.org                 ////
////      - Dinesh Annayya, dinesha@opencores.org                 ////
////                                                              ////
////                                                              ////
////  Revision : Nov 26, 2016                                      //// 
////  Revision :                                                  //// 
 
////     v-0.0 : NOV 26, 2016                                     ////
 
////        1. initial version picked from                        ////
 
////          http://www.opencores.org/cores/turbo8051/           ////
 
////     v-0.1 : NOV 28, 2016                                     ////
 
////        2.  Register access correction                        ////
////                                                              ////
////                                                              ////
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
////                                                              ////
////                                                              ////
//// Copyright (C) 2000 Authors and OPENCORES.ORG                 ////
//// Copyright (C) 2000 Authors and OPENCORES.ORG                 ////
////                                                              ////
////                                                              ////
Line 43... Line 48...
////                                                              ////
////                                                              ////
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
module uart_core
module uart_core
 
 
     (
     (
        line_reset_n ,
 
        line_clk_16x ,
 
 
 
        app_reset_n ,
        app_reset_n ,
        app_clk ,
        app_clk ,
 
 
        // Reg Bus Interface Signal
        // Reg Bus Interface Signal
Line 82... Line 85...
               (DP == 128) ? 7 :
               (DP == 128) ? 7 :
               (DP == 256) ? 8 : 0;
               (DP == 256) ? 8 : 0;
 
 
 
 
 
 
input        line_reset_n         ; // line reset
 
input        line_clk_16x         ; // line clock
 
 
 
input        app_reset_n          ; // application reset
input        app_reset_n          ; // application reset
input        app_clk              ; // application clock
input        app_clk              ; // application clock
 
 
//---------------------------------
//---------------------------------
// Reg Bus Interface Signal
// Reg Bus Interface Signal
Line 109... Line 109...
 
 
// Wire Declaration
// Wire Declaration
 
 
wire [W-1: 0]   tx_fifo_rd_data;
wire [W-1: 0]   tx_fifo_rd_data;
wire [W-1: 0]   rx_fifo_wr_data;
wire [W-1: 0]   rx_fifo_wr_data;
wire [W-1: 0]   app_rxfifo_rddata;
wire [W-1: 0]   app_rxfifo_data;
 
wire [W-1: 0]   app_txfifo_data;
wire [1  : 0]   error_ind;
wire [1  : 0]   error_ind;
 
 
// Wire 
// Wire 
wire         cfg_tx_enable        ; // Tx Enable
wire         cfg_tx_enable        ; // Tx Enable
wire         cfg_rx_enable        ; // Rx Enable
wire         cfg_rx_enable        ; // Rx Enable
Line 121... Line 122...
wire   [1:0] cfg_pri_mod          ; // priority mode, 0 -> nop, 1 -> Even, 2 -> Odd
wire   [1:0] cfg_pri_mod          ; // priority mode, 0 -> nop, 1 -> Even, 2 -> Odd
 
 
wire        frm_error_o          ; // framing error
wire        frm_error_o          ; // framing error
wire        par_error_o          ; // par error
wire        par_error_o          ; // par error
wire        rx_fifo_full_err_o   ; // rx fifo full error
wire        rx_fifo_full_err_o   ; // rx fifo full error
 
 
 
wire   [11:0] cfg_baud_16x        ; // 16x Baud clock generation
wire        rx_fifo_wr_full      ;
wire        rx_fifo_wr_full      ;
wire        app_rxfifo_empty     ;
wire        app_rxfifo_empty     ;
 
 
 
 
uart_cfg u_cfg (
uart_cfg u_cfg (
Line 148... Line 151...
            . cfg_tx_enable       (cfg_tx_enable),
            . cfg_tx_enable       (cfg_tx_enable),
            . cfg_rx_enable       (cfg_rx_enable),
            . cfg_rx_enable       (cfg_rx_enable),
            . cfg_stop_bit        (cfg_stop_bit),
            . cfg_stop_bit        (cfg_stop_bit),
            . cfg_pri_mod         (cfg_pri_mod),
            . cfg_pri_mod         (cfg_pri_mod),
 
 
 
            . cfg_baud_16x        (cfg_baud_16x),
 
 
 
            . tx_fifo_full        (app_tx_fifo_full),
 
            . tx_fifo_wr_en       (tx_fifo_wr_en),
 
            . tx_fifo_data        (app_txfifo_data),
 
 
 
            . rx_fifo_empty       (app_rxfifo_empty),
 
            . rx_fifo_rd_en       (app_rxfifo_rd_en),
 
            . rx_fifo_data        (app_rxfifo_data) ,
 
 
            . frm_error_o         (frm_error_o),
            . frm_error_o         (frm_error_o),
            . par_error_o         (par_error_o),
            . par_error_o         (par_error_o),
            . rx_fifo_full_err_o  (rx_fifo_full_err_o)
            . rx_fifo_full_err_o  (rx_fifo_full_err_o)
 
 
        );
        );
 
 
 
 
 
 
 
// 16x Baud clock generation
 
// Example: to generate 19200 Baud clock from 50Mhz Link clock
 
//    50 * 1000 * 1000 / (2 + cfg_baud_16x) = 19200 * 16
 
//    cfg_baud_16x = 0xA0 (160)
 
 
 
wire line_clk_16x;
 
 
 
clk_ctl #(11) u_clk_ctl (
 
   // Outputs
 
       .clk_o          (line_clk_16x),
 
 
 
   // Inputs
 
       .mclk           (app_clk),
 
       .reset_n        (app_reset_n),
 
       .clk_div_ratio  (cfg_baud_16x)
 
   );
 
 
 
wire line_reset_n = app_reset_n; // todo-> create synchronised reset w.r.t line clock
 
 
uart_txfsm u_txfsm (
uart_txfsm u_txfsm (
               . reset_n           ( line_reset_n      ),
               . reset_n           ( line_reset_n      ),
               . baud_clk_16x      ( line_clk_16x      ),
               . baud_clk_16x      ( line_clk_16x      ),
 
 
Line 205... Line 235...
               .full               (rx_fifo_wr_full    ), // sync'ed to wr_clk
               .full               (rx_fifo_wr_full    ), // sync'ed to wr_clk
               .wr_total_free_space(                   ),
               .wr_total_free_space(                   ),
 
 
               .rd_clk             (app_clk            ),
               .rd_clk             (app_clk            ),
               .rd_reset_n         (app_reset_n        ),
               .rd_reset_n         (app_reset_n        ),
               .rd_en              (!app_rxfifo_empty  ),
               .rd_en              (app_rxfifo_rd_en   ),
               .empty              (app_rxfifo_empty   ),  // sync'ed to rd_clk
               .empty              (app_rxfifo_empty   ),  // sync'ed to rd_clk
               .rd_total_aval      (                   ),
               .rd_total_aval      (                   ),
               .rd_data            (app_rxfifo_rddata  )
               .rd_data            (app_rxfifo_data    )
                   );
                   );
 
 
async_fifo #(W,DP,0,0) u_txfifo  (
async_fifo #(W,DP,0,0) u_txfifo  (
               .wr_clk             (app_clk            ),
               .wr_clk             (app_clk            ),
               .wr_reset_n         (app_reset_n        ),
               .wr_reset_n         (app_reset_n        ),
               .wr_en              (!app_rxfifo_empty  ),
               .wr_en              (tx_fifo_wr_en      ),
               .wr_data            (app_rxfifo_rddata  ),
               .wr_data            (app_txfifo_data    ),
               .full               (                   ), // sync'ed to wr_clk
               .full               (app_tx_fifo_full   ), // sync'ed to wr_clk
               .wr_total_free_space(                   ),
               .wr_total_free_space(                   ),
 
 
               .rd_clk             (line_clk_16x       ),
               .rd_clk             (line_clk_16x       ),
               .rd_reset_n         (line_reset_n       ),
               .rd_reset_n         (line_reset_n       ),
               .rd_en              (tx_fifo_rd         ),
               .rd_en              (tx_fifo_rd         ),

powered by: WebSVN 2.1.0

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