Line 29... |
Line 29... |
//
|
//
|
// *Author(s):
|
// *Author(s):
|
// - Olivier Girard, olgirard@gmail.com
|
// - Olivier Girard, olgirard@gmail.com
|
//
|
//
|
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
// $Rev: 106 $
|
// $Rev: 111 $
|
// $LastChangedBy: olivier.girard $
|
// $LastChangedBy: olivier.girard $
|
// $LastChangedDate: 2011-03-25 23:01:03 +0100 (Fri, 25 Mar 2011) $
|
// $LastChangedDate: 2011-05-20 22:39:02 +0200 (Fri, 20 May 2011) $
|
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
`ifdef OMSP_NO_INCLUDE
|
`ifdef OMSP_NO_INCLUDE
|
`else
|
`else
|
`include "openMSP430_defines.v"
|
`include "openMSP430_defines.v"
|
`endif
|
`endif
|
Line 86... |
Line 86... |
|
|
//=============================================================================
|
//=============================================================================
|
// 1) UART RECEIVE LINE SYNCHRONIZTION & FILTERING
|
// 1) UART RECEIVE LINE SYNCHRONIZTION & FILTERING
|
//=============================================================================
|
//=============================================================================
|
|
|
// Synchronize RXD input & buffer
|
// Synchronize RXD input
|
//--------------------------------
|
//--------------------------------
|
reg [3:0] rxd_sync;
|
`ifdef SYNC_DBG_UART_RXD
|
|
|
|
wire uart_rxd_n;
|
|
|
|
omsp_sync_cell sync_cell_uart_rxd (
|
|
.data_out (uart_rxd_n),
|
|
.clk (dbg_clk),
|
|
.data_in (~dbg_uart_rxd),
|
|
.rst (dbg_rst)
|
|
);
|
|
wire uart_rxd = ~uart_rxd_n;
|
|
`else
|
|
wire uart_rxd = dbg_uart_rxd;
|
|
`endif
|
|
|
|
// RXD input buffer
|
|
//--------------------------------
|
|
reg [1:0] rxd_buf;
|
always @ (posedge dbg_clk or posedge dbg_rst)
|
always @ (posedge dbg_clk or posedge dbg_rst)
|
if (dbg_rst) rxd_sync <= 4'hf;
|
if (dbg_rst) rxd_buf <= 2'h3;
|
else rxd_sync <= {rxd_sync[2:0], dbg_uart_rxd};
|
else rxd_buf <= {rxd_buf[0], uart_rxd};
|
|
|
// Majority decision
|
// Majority decision
|
//------------------------
|
//------------------------
|
reg rxd_maj;
|
reg rxd_maj;
|
|
|
wire [1:0] rxd_maj_cnt = {1'b0, rxd_sync[1]} +
|
wire [1:0] rxd_maj_cnt = {1'b0, uart_rxd} +
|
{1'b0, rxd_sync[2]} +
|
{1'b0, rxd_buf[0]} +
|
{1'b0, rxd_sync[3]};
|
{1'b0, rxd_buf[1]};
|
wire rxd_maj_nxt = (rxd_maj_cnt>=2'b10);
|
wire rxd_maj_nxt = (rxd_maj_cnt>=2'b10);
|
|
|
always @ (posedge dbg_clk or posedge dbg_rst)
|
always @ (posedge dbg_clk or posedge dbg_rst)
|
if (dbg_rst) rxd_maj <= 1'b0;
|
if (dbg_rst) rxd_maj <= 1'b0;
|
else rxd_maj <= rxd_maj_nxt;
|
else rxd_maj <= rxd_maj_nxt;
|