Line 36... |
Line 36... |
//
|
//
|
//
|
//
|
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
//
|
//
|
//
|
//
|
|
`default_nettype none
|
|
//
|
`define UART_SETUP 2'b00
|
`define UART_SETUP 2'b00
|
`define UART_FIFO 2'b01
|
`define UART_FIFO 2'b01
|
`define UART_RXREG 2'b10
|
`define UART_RXREG 2'b10
|
`define UART_TXREG 2'b11
|
`define UART_TXREG 2'b11
|
module wbuart(i_clk, i_rst,
|
module wbuart(i_clk, i_rst,
|
Line 58... |
Line 60... |
// sure its within the bounds we can support with our current
|
// sure its within the bounds we can support with our current
|
// interface.
|
// interface.
|
localparam [3:0] LCLLGFLEN = (LGFLEN > 4'ha)? 4'ha
|
localparam [3:0] LCLLGFLEN = (LGFLEN > 4'ha)? 4'ha
|
: ((LGFLEN < 4'h2) ? 4'h2 : LGFLEN);
|
: ((LGFLEN < 4'h2) ? 4'h2 : LGFLEN);
|
//
|
//
|
input i_clk, i_rst;
|
input wire i_clk, i_rst;
|
// Wishbone inputs
|
// Wishbone inputs
|
input i_wb_cyc, i_wb_stb, i_wb_we;
|
input wire i_wb_cyc, i_wb_stb, i_wb_we;
|
input [1:0] i_wb_addr;
|
input wire [1:0] i_wb_addr;
|
input [31:0] i_wb_data;
|
input wire [31:0] i_wb_data;
|
output reg o_wb_ack;
|
output reg o_wb_ack;
|
output wire o_wb_stall;
|
output wire o_wb_stall;
|
output reg [31:0] o_wb_data;
|
output reg [31:0] o_wb_data;
|
//
|
//
|
input i_uart_rx;
|
input wire i_uart_rx;
|
output wire o_uart_tx;
|
output wire o_uart_tx;
|
// RTS is used for hardware flow control. According to Wikipedia, it
|
// RTS is used for hardware flow control. According to Wikipedia, it
|
// should probably be renamed RTR for "ready to receive". It tell us
|
// should probably be renamed RTR for "ready to receive". It tell us
|
// whether or not the receiving hardware is ready to accept another
|
// whether or not the receiving hardware is ready to accept another
|
// byte. If low, the transmitter will pause.
|
// byte. If low, the transmitter will pause.
|
//
|
//
|
// If you don't wish to use hardware flow control, just set i_cts_n to
|
// If you don't wish to use hardware flow control, just set i_cts_n to
|
// 1'b0 and let the optimizer simply remove this logic.
|
// 1'b0 and let the optimizer simply remove this logic.
|
input i_cts_n;
|
input wire i_cts_n;
|
// CTS is the "Clear-to-send" signal. We set it anytime our FIFO
|
// CTS is the "Clear-to-send" signal. We set it anytime our FIFO
|
// isn't full. Feel free to ignore this output if you do not wish to
|
// isn't full. Feel free to ignore this output if you do not wish to
|
// use flow control.
|
// use flow control.
|
output reg o_rts_n;
|
output reg o_rts_n;
|
output wire o_uart_rx_int, o_uart_tx_int,
|
output wire o_uart_rx_int, o_uart_tx_int,
|
Line 338... |
Line 340... |
tx_uart_reset <= i_wb_data[12];
|
tx_uart_reset <= i_wb_data[12];
|
else
|
else
|
tx_uart_reset <= 1'b0;
|
tx_uart_reset <= 1'b0;
|
|
|
`ifdef USE_LITE_UART
|
`ifdef USE_LITE_UART
|
txuart #(INITIAL_SETUP[23:0]) tx(i_clk, (tx_empty_n), tx_data,
|
txuartlite #(INITIAL_SETUP[23:0]) tx(i_clk, (tx_empty_n), tx_data,
|
o_uart_tx, tx_busy);
|
o_uart_tx, tx_busy);
|
`else
|
`else
|
wire cts_n;
|
wire cts_n;
|
assign cts_n = (HARDWARE_FLOW_CONTROL_PRESENT)&&(i_cts_n);
|
assign cts_n = (HARDWARE_FLOW_CONTROL_PRESENT)&&(i_cts_n);
|
// Finally, the UART transmitter module itself. Note that we haven't
|
// Finally, the UART transmitter module itself. Note that we haven't
|