Line 61... |
Line 61... |
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
//
|
//
|
// CVS Revision History
|
// CVS Revision History
|
//
|
//
|
// $Log: not supported by cvs2svn $
|
// $Log: not supported by cvs2svn $
|
|
// Revision 1.24 2001/12/19 08:03:34 mohor
|
|
// Warnings cleared.
|
|
//
|
// Revision 1.23 2001/12/19 07:33:54 mohor
|
// Revision 1.23 2001/12/19 07:33:54 mohor
|
// Synplicity was having troubles with the comment.
|
// Synplicity was having troubles with the comment.
|
//
|
//
|
// Revision 1.22 2001/12/17 14:46:48 mohor
|
// Revision 1.22 2001/12/17 14:46:48 mohor
|
// overrun signal was moved to separate block because many sequential lsr
|
// overrun signal was moved to separate block because many sequential lsr
|
Line 162... |
Line 165... |
// synopsys translate_on
|
// synopsys translate_on
|
|
|
`include "uart_defines.v"
|
`include "uart_defines.v"
|
|
|
module uart_receiver (clk, wb_rst_i, lcr, rf_pop, srx_pad_i, enable,
|
module uart_receiver (clk, wb_rst_i, lcr, rf_pop, srx_pad_i, enable,
|
counter_t, rf_count, rf_data_out, rf_error_bit, rf_overrun, rx_reset, lsr_mask, rstate, rf_push);
|
counter_t, rf_count, rf_data_out, rf_error_bit, rf_overrun, rx_reset, lsr_mask, rstate, rf_push_pulse);
|
|
|
input clk;
|
input clk;
|
input wb_rst_i;
|
input wb_rst_i;
|
input [7:0] lcr;
|
input [7:0] lcr;
|
input rf_pop;
|
input rf_pop;
|
Line 179... |
Line 182... |
output [`UART_FIFO_COUNTER_W-1:0] rf_count;
|
output [`UART_FIFO_COUNTER_W-1:0] rf_count;
|
output [`UART_FIFO_REC_WIDTH-1:0] rf_data_out;
|
output [`UART_FIFO_REC_WIDTH-1:0] rf_data_out;
|
output rf_overrun;
|
output rf_overrun;
|
output rf_error_bit;
|
output rf_error_bit;
|
output [3:0] rstate;
|
output [3:0] rstate;
|
output rf_push;
|
output rf_push_pulse;
|
|
|
reg [3:0] rstate;
|
reg [3:0] rstate;
|
reg [3:0] rcounter16;
|
reg [3:0] rcounter16;
|
reg [2:0] rbit_counter;
|
reg [2:0] rbit_counter;
|
reg [7:0] rshift; // receiver shift register
|
reg [7:0] rshift; // receiver shift register
|
Line 195... |
Line 198... |
reg [7:0] counter_b; // counts the 0 (low) signals
|
reg [7:0] counter_b; // counts the 0 (low) signals
|
|
|
// RX FIFO signals
|
// RX FIFO signals
|
reg [`UART_FIFO_REC_WIDTH-1:0] rf_data_in;
|
reg [`UART_FIFO_REC_WIDTH-1:0] rf_data_in;
|
wire [`UART_FIFO_REC_WIDTH-1:0] rf_data_out;
|
wire [`UART_FIFO_REC_WIDTH-1:0] rf_data_out;
|
|
wire rf_push_pulse;
|
reg rf_push;
|
reg rf_push;
|
wire rf_pop;
|
wire rf_pop;
|
wire rf_overrun;
|
wire rf_overrun;
|
wire [`UART_FIFO_COUNTER_W-1:0] rf_count;
|
wire [`UART_FIFO_COUNTER_W-1:0] rf_count;
|
wire rf_error_bit; // an error (parity or framing) is inside the fifo
|
wire rf_error_bit; // an error (parity or framing) is inside the fifo
|
Line 208... |
Line 212... |
uart_fifo #(`UART_FIFO_REC_WIDTH) fifo_rx(
|
uart_fifo #(`UART_FIFO_REC_WIDTH) fifo_rx(
|
.clk( clk ),
|
.clk( clk ),
|
.wb_rst_i( wb_rst_i ),
|
.wb_rst_i( wb_rst_i ),
|
.data_in( rf_data_in ),
|
.data_in( rf_data_in ),
|
.data_out( rf_data_out ),
|
.data_out( rf_data_out ),
|
.push( rf_push ),
|
.push( rf_push_pulse ),
|
.pop( rf_pop ),
|
.pop( rf_pop ),
|
.overrun( rf_overrun ),
|
.overrun( rf_overrun ),
|
.count( rf_count ),
|
.count( rf_count ),
|
.error_bit( rf_error_bit ),
|
.error_bit( rf_error_bit ),
|
.fifo_reset( rx_reset ),
|
.fifo_reset( rx_reset ),
|
Line 390... |
Line 394... |
default : rstate <= #1 sr_idle;
|
default : rstate <= #1 sr_idle;
|
endcase
|
endcase
|
end // if (enable)
|
end // if (enable)
|
end // always of receiver
|
end // always of receiver
|
|
|
|
always @ (posedge clk or posedge wb_rst_i)
|
|
begin
|
|
if(wb_rst_i)
|
|
rf_push_q <= 0;
|
|
else
|
|
rf_push_q <= #1 rf_push;
|
|
end
|
|
|
|
assign rf_push_pulse = rf_push & ~rf_push_q;
|
|
|
|
|
//
|
//
|
// Break condition detection.
|
// Break condition detection.
|
// Works in conjuction with the receiver state machine
|
// Works in conjuction with the receiver state machine
|
|
|
reg [9:0] toc_value; // value to be set to timeout counter
|
reg [9:0] toc_value; // value to be set to timeout counter
|
Line 436... |
Line 451... |
always @(posedge clk or posedge wb_rst_i)
|
always @(posedge clk or posedge wb_rst_i)
|
begin
|
begin
|
if (wb_rst_i)
|
if (wb_rst_i)
|
counter_t <= #1 10'd639; // 10 bits for the default 8N1
|
counter_t <= #1 10'd639; // 10 bits for the default 8N1
|
else
|
else
|
if(rf_push || rf_pop || rf_count == 0) // counter is reset when RX FIFO is empty, accessed or above trigger level
|
if(rf_push_pulse || rf_pop || rf_count == 0) // counter is reset when RX FIFO is empty, accessed or above trigger level
|
counter_t <= #1 toc_value;
|
counter_t <= #1 toc_value;
|
else
|
else
|
if (enable && counter_t != 10'b0) // we don't want to underflow
|
if (enable && counter_t != 10'b0) // we don't want to underflow
|
counter_t <= #1 counter_t - 1;
|
counter_t <= #1 counter_t - 1;
|
end
|
end
|