|
|
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
//// ////
|
//// ////
|
//// UART2SPI Top Module ////
|
//// UART2SPI Top Module ////
|
//// ////
|
//// ////
|
//// This file is part of the uart2spi cores project ////
|
//// This file is part of the uart2spi cores project ////
|
//// http://www.opencores.org/cores/uart2spi/ ////
|
//// http://www.opencores.org/cores/uart2spi/ ////
|
//// ////
|
//// ////
|
//// Description ////
|
//// Description ////
|
//// Uart2SPI top level integration. ////
|
//// Uart2SPI top level integration. ////
|
//// 1. spi_core ////
|
//// 1. spi_core ////
|
//// 2. uart_core ////
|
//// 2. uart_core ////
|
//// 3. uart_msg_handler ////
|
//// 3. uart_msg_handler ////
|
//// ////
|
//// ////
|
//// To Do: ////
|
//// To Do: ////
|
//// nothing ////
|
//// nothing ////
|
//// ////
|
//// ////
|
//// Author(s): ////
|
//// Author(s): ////
|
//// - Dinesh Annayya, dinesha@opencores.org ////
|
//// - Dinesh Annayya, dinesha@opencores.org ////
|
//// ////
|
//// ////
|
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
//// ////
|
//// ////
|
//// Copyright (C) 2000 Authors and OPENCORES.ORG ////
|
//// Copyright (C) 2000 Authors and OPENCORES.ORG ////
|
//// ////
|
//// ////
|
//// This source file may be used and distributed without ////
|
//// This source file may be used and distributed without ////
|
//// restriction provided that this copyright statement is not ////
|
//// restriction provided that this copyright statement is not ////
|
//// removed from the file and that any derivative work contains ////
|
//// removed from the file and that any derivative work contains ////
|
//// the original copyright notice and the associated disclaimer. ////
|
//// the original copyright notice and the associated disclaimer. ////
|
//// ////
|
//// ////
|
//// This source file is free software; you can redistribute it ////
|
//// This source file is free software; you can redistribute it ////
|
//// and/or modify it under the terms of the GNU Lesser General ////
|
//// and/or modify it under the terms of the GNU Lesser General ////
|
//// Public License as published by the Free Software Foundation; ////
|
//// Public License as published by the Free Software Foundation; ////
|
//// either version 2.1 of the License, or (at your option) any ////
|
//// either version 2.1 of the License, or (at your option) any ////
|
//// later version. ////
|
//// later version. ////
|
//// ////
|
//// ////
|
//// This source is distributed in the hope that it will be ////
|
//// This source is distributed in the hope that it will be ////
|
//// useful, but WITHOUT ANY WARRANTY; without even the implied ////
|
//// useful, but WITHOUT ANY WARRANTY; without even the implied ////
|
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ////
|
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ////
|
//// PURPOSE. See the GNU Lesser General Public License for more ////
|
//// PURPOSE. See the GNU Lesser General Public License for more ////
|
//// details. ////
|
//// details. ////
|
//// ////
|
//// ////
|
//// You should have received a copy of the GNU Lesser General ////
|
//// You should have received a copy of the GNU Lesser General ////
|
//// Public License along with this source; if not, download it ////
|
//// Public License along with this source; if not, download it ////
|
//// from http://www.opencores.org/lgpl.shtml ////
|
//// from http://www.opencores.org/lgpl.shtml ////
|
//// ////
|
//// ////
|
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
|
|
module top (
|
module top (
|
line_reset_n ,
|
line_reset_n ,
|
line_clk ,
|
line_clk ,
|
|
|
// configuration control
|
// configuration control
|
cfg_tx_enable , // Enable Transmit Path
|
cfg_tx_enable , // Enable Transmit Path
|
cfg_rx_enable , // Enable Received Path
|
cfg_rx_enable , // Enable Received Path
|
cfg_stop_bit , // 0 -> 1 Start , 1 -> 2 Stop Bits
|
cfg_stop_bit , // 0 -> 1 Start , 1 -> 2 Stop Bits
|
cfg_pri_mod , // priority mode, 0 -> nop, 1 -> Even, 2 -> Odd
|
cfg_pri_mod , // priority mode, 0 -> nop, 1 -> Even, 2 -> Odd
|
cfg_baud_16x ,
|
cfg_baud_16x ,
|
|
|
// Status information
|
// Status information
|
frm_error ,
|
frm_error ,
|
par_error ,
|
par_error ,
|
|
|
baud_clk_16x,
|
baud_clk_16x,
|
|
|
// Line Interface
|
// Line Interface
|
rxd,
|
rxd,
|
txd,
|
txd,
|
|
|
// Spi I/F
|
// Spi I/F
|
sck,
|
sck,
|
so,
|
so,
|
si,
|
si,
|
cs_n
|
cs_n
|
|
|
);
|
);
|
|
|
|
|
|
|
//---------------------------------
|
//---------------------------------
|
// Global Dec
|
// Global Dec
|
// ---------------------------------
|
// ---------------------------------
|
|
|
input line_reset_n ; // line reset
|
input line_reset_n ; // line reset
|
input line_clk ; // line clock
|
input line_clk ; // line clock
|
|
|
//-------------------------------------
|
//-------------------------------------
|
// Configuration
|
// Configuration
|
// -------------------------------------
|
// -------------------------------------
|
input cfg_tx_enable ; // Tx Enable
|
input cfg_tx_enable ; // Tx Enable
|
input cfg_rx_enable ; // Rx Enable
|
input cfg_rx_enable ; // Rx Enable
|
input cfg_stop_bit ; // 0 -> 1 Stop, 1 -> 2 Stop
|
input cfg_stop_bit ; // 0 -> 1 Stop, 1 -> 2 Stop
|
input [1:0] cfg_pri_mod ; // priority mode, 0 -> nop, 1 -> Even, 2 -> Odd
|
input [1:0] cfg_pri_mod ; // priority mode, 0 -> nop, 1 -> Even, 2 -> Odd
|
input [11:0] cfg_baud_16x ; // 16x Baud clock generation
|
input [11:0] cfg_baud_16x ; // 16x Baud clock generation
|
|
|
//--------------------------------------
|
//--------------------------------------
|
// ERROR Indication
|
// ERROR Indication
|
// -------------------------------------
|
// -------------------------------------
|
output frm_error ; // framing error
|
output frm_error ; // framing error
|
output par_error ; // par error
|
output par_error ; // par error
|
|
|
output baud_clk_16x ; // 16x Baud clock
|
output baud_clk_16x ; // 16x Baud clock
|
|
|
|
|
//-------------------------------------
|
//-------------------------------------
|
// Line Interface
|
// Line Interface
|
// -------------------------------------
|
// -------------------------------------
|
input rxd ; // uart rxd
|
input rxd ; // uart rxd
|
output txd ; // uart txd
|
output txd ; // uart txd
|
|
|
//-------------------------------------
|
//-------------------------------------
|
// Spi I/F
|
// Spi I/F
|
//-------------------------------------
|
//-------------------------------------
|
output sck ; // clock out
|
output sck ; // clock out
|
output so ; // serial data out
|
output so ; // serial data out
|
input si ; // serial data in
|
input si ; // serial data in
|
output [3:0] cs_n ; // cs_n
|
output [3:0] cs_n ; // cs_n
|
//---------------------------------------
|
//---------------------------------------
|
// Control Unit interface
|
// Control Unit interface
|
// --------------------------------------
|
// --------------------------------------
|
|
|
wire [15:0] reg_addr ; // Register Address
|
wire [15:0] reg_addr ; // Register Address
|
wire [31:0] reg_wdata ; // Register Wdata
|
wire [31:0] reg_wdata ; // Register Wdata
|
wire reg_req ; // Register Request
|
wire reg_req ; // Register Request
|
wire reg_wr ; // 1 -> write; 0 -> read
|
wire reg_wr ; // 1 -> write; 0 -> read
|
wire reg_ack ; // Register Ack
|
wire reg_ack ; // Register Ack
|
wire [31:0] reg_rdata ;
|
wire [31:0] reg_rdata ;
|
//--------------------------------------
|
//--------------------------------------
|
// TXD Path
|
// TXD Path
|
// -------------------------------------
|
// -------------------------------------
|
wire tx_data_avail ; // Indicate valid TXD Data
|
wire tx_data_avail ; // Indicate valid TXD Data
|
wire [7:0] tx_data ; // TXD Data to be transmited
|
wire [7:0] tx_data ; // TXD Data to be transmited
|
wire tx_rd ; // Indicate TXD Data Been Read
|
wire tx_rd ; // Indicate TXD Data Been Read
|
|
|
|
|
//--------------------------------------
|
//--------------------------------------
|
// RXD Path
|
// RXD Path
|
// -------------------------------------
|
// -------------------------------------
|
wire rx_ready ; // Indicate Ready to accept the Read Data
|
wire rx_ready ; // Indicate Ready to accept the Read Data
|
wire [7:0] rx_data ; // RXD Data
|
wire [7:0] rx_data ; // RXD Data
|
wire rx_wr ; // Valid RXD Data
|
wire rx_wr ; // Valid RXD Data
|
|
|
spi_core u_spi (
|
spi_core u_spi (
|
|
|
.clk (baud_clk_16x),
|
.clk (baud_clk_16x),
|
.reset_n (line_reset_n),
|
.reset_n (line_reset_n),
|
|
|
// Reg Bus Interface Signal
|
// Reg Bus Interface Signal
|
.reg_cs (reg_req ),
|
.reg_cs (reg_req ),
|
.reg_wr (reg_wr ),
|
.reg_wr (reg_wr ),
|
.reg_addr (reg_addr[5:2]),
|
.reg_addr (reg_addr[5:2]),
|
.reg_wdata (reg_wdata ),
|
.reg_wdata (reg_wdata ),
|
.reg_be (4'b1111 ),
|
.reg_be (4'b1111 ),
|
|
|
// Outputs
|
// Outputs
|
.reg_rdata (reg_rdata ),
|
.reg_rdata (reg_rdata ),
|
.reg_ack (reg_ack ),
|
.reg_ack (reg_ack ),
|
|
|
// line interface
|
// line interface
|
.sck (sck ),
|
.sck (sck ),
|
.so (so ),
|
.so (so ),
|
.si (si ),
|
.si (si ),
|
.cs_n (cs_n )
|
.cs_n (cs_n )
|
|
|
);
|
);
|
|
|
uart_core u_core (
|
uart_core u_core (
|
.line_reset_n (line_reset_n) ,
|
.line_reset_n (line_reset_n) ,
|
.line_clk (line_clk) ,
|
.line_clk (line_clk) ,
|
|
|
// configuration control
|
// configuration control
|
.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) ,
|
.cfg_baud_16x (cfg_baud_16x) ,
|
|
|
// TXD Information
|
// TXD Information
|
.tx_data_avail (tx_data_avail) ,
|
.tx_data_avail (tx_data_avail) ,
|
.tx_rd (tx_rd) ,
|
.tx_rd (tx_rd) ,
|
.tx_data (tx_data) ,
|
.tx_data (tx_data) ,
|
|
|
|
|
// RXD Information
|
// RXD Information
|
.rx_ready (rx_ready) ,
|
.rx_ready (rx_ready) ,
|
.rx_wr (rx_wr) ,
|
.rx_wr (rx_wr) ,
|
.rx_data (rx_data) ,
|
.rx_data (rx_data) ,
|
|
|
// Status information
|
// Status information
|
.frm_error (frm_error) ,
|
.frm_error (frm_error) ,
|
.par_error (par_error) ,
|
.par_error (par_error) ,
|
|
|
.baud_clk_16x (baud_clk_16x) ,
|
.baud_clk_16x (baud_clk_16x) ,
|
|
|
// Line Interface
|
// Line Interface
|
.rxd (rxd) ,
|
.rxd (rxd) ,
|
.txd (txd)
|
.txd (txd)
|
|
|
);
|
);
|
|
|
|
|
|
|
uart_msg_handler u_msg (
|
uart_msg_handler u_msg (
|
.reset_n (line_reset_n ) ,
|
.reset_n (line_reset_n ) ,
|
.sys_clk (baud_clk_16x ) ,
|
.sys_clk (baud_clk_16x ) ,
|
|
|
|
|
// UART-TX Information
|
// UART-TX Information
|
.tx_data_avail (tx_data_avail) ,
|
.tx_data_avail (tx_data_avail) ,
|
.tx_rd (tx_rd) ,
|
.tx_rd (tx_rd) ,
|
.tx_data (tx_data) ,
|
.tx_data (tx_data) ,
|
|
|
|
|
// UART-RX Information
|
// UART-RX Information
|
.rx_ready (rx_ready) ,
|
.rx_ready (rx_ready) ,
|
.rx_wr (rx_wr) ,
|
.rx_wr (rx_wr) ,
|
.rx_data (rx_data) ,
|
.rx_data (rx_data) ,
|
|
|
// Towards Control Unit
|
// Towards Control Unit
|
.reg_addr (reg_addr),
|
.reg_addr (reg_addr),
|
.reg_wr (reg_wr),
|
.reg_wr (reg_wr),
|
.reg_wdata (reg_wdata),
|
.reg_wdata (reg_wdata),
|
.reg_req (reg_req),
|
.reg_req (reg_req),
|
.reg_ack (reg_ack),
|
.reg_ack (reg_ack),
|
.reg_rdata (reg_rdata)
|
.reg_rdata (reg_rdata)
|
|
|
);
|
);
|
|
|
endmodule
|
endmodule
|
|
|