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

Subversion Repositories wbuart32

[/] [wbuart32/] [trunk/] [bench/] [cpp/] [uartsim.cpp] - Diff between revs 2 and 3

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

Rev 2 Rev 3
Line 150... Line 150...
        m_last_tx = i_tx;
        m_last_tx = i_tx;
 
 
        if (m_rx_state == RXIDLE) {
        if (m_rx_state == RXIDLE) {
                if (!i_tx) {
                if (!i_tx) {
                        m_rx_state = RXDATA;
                        m_rx_state = RXDATA;
                        m_rx_baudcounter =m_baud_counts+m_baud_counts/2;
                        m_rx_baudcounter =m_baud_counts+m_baud_counts/2-1;
                        m_rx_baudcounter -= m_rx_changectr;
                        m_rx_baudcounter -= m_rx_changectr;
                        m_rx_busy    = 0;
                        m_rx_busy    = 0;
                        m_rx_data    = 0;
                        m_rx_data    = 0;
                }
                }
        } else if (m_rx_baudcounter <= 0) {
        } else if (m_rx_baudcounter <= 0) {
Line 180... Line 180...
                        //      bit N-1
                        //      bit N-1
                        //      (possible parity bit)
                        //      (possible parity bit)
                        //      stop bit
                        //      stop bit
                        //      (possible secondary stop bit)
                        //      (possible secondary stop bit)
                        m_rx_data = ((i_tx&1)<<31) | (m_rx_data>>1);
                        m_rx_data = ((i_tx&1)<<31) | (m_rx_data>>1);
                } m_rx_baudcounter = m_baud_counts;
                } m_rx_baudcounter = m_baud_counts-1;
        } else
        } else
                m_rx_baudcounter--;
                m_rx_baudcounter--;
 
 
        if (m_tx_state == TXIDLE) {
        if (m_tx_state == TXIDLE) {
                struct  pollfd  pb;
                struct  pollfd  pb;
Line 216... Line 216...
                                        m_tx_data |= (p<<(m_nbits+m_nparity));
                                        m_tx_data |= (p<<(m_nbits+m_nparity));
                                }
                                }
                                m_tx_busy = (1<<(m_nbits+m_nparity+m_nstop+1))-1;
                                m_tx_busy = (1<<(m_nbits+m_nparity+m_nstop+1))-1;
                                m_tx_state = TXDATA;
                                m_tx_state = TXDATA;
                                o_rx = 0;
                                o_rx = 0;
                                m_tx_baudcounter = m_baud_counts;
                                m_tx_baudcounter = m_baud_counts-1;
                        }
                        }
                }
                }
        } else if (m_tx_baudcounter == 0) {
        } else if (m_tx_baudcounter <= 0) {
                m_tx_data >>= 1;
                m_tx_data >>= 1;
                m_tx_busy >>= 1;
                m_tx_busy >>= 1;
                if (!m_tx_busy)
                if (!m_tx_busy)
                        m_tx_state = TXIDLE;
                        m_tx_state = TXIDLE;
                else
                else
                        m_tx_baudcounter = m_baud_counts;
                        m_tx_baudcounter = m_baud_counts-1;
                o_rx = m_tx_data&1;
                o_rx = m_tx_data&1;
        } else {
        } else {
                m_tx_baudcounter--;
                m_tx_baudcounter--;
                o_rx = m_tx_data&1;
                o_rx = m_tx_data&1;
        }
        }
Line 246... Line 246...
        m_last_tx = i_tx;
        m_last_tx = i_tx;
 
 
        if (m_rx_state == RXIDLE) {
        if (m_rx_state == RXIDLE) {
                if (!i_tx) {
                if (!i_tx) {
                        m_rx_state = RXDATA;
                        m_rx_state = RXDATA;
                        m_rx_baudcounter =m_baud_counts+m_baud_counts/2;
                        m_rx_baudcounter =m_baud_counts+m_baud_counts/2-1;
                        m_rx_baudcounter -= m_rx_changectr;
                        m_rx_baudcounter -= m_rx_changectr;
                        m_rx_busy    = 0;
                        m_rx_busy    = 0;
                        m_rx_data    = 0;
                        m_rx_data    = 0;
                }
                }
        } else if (m_rx_baudcounter <= 0) {
        } else if (m_rx_baudcounter <= 0) {
Line 277... Line 277...
                        //      bit N-1
                        //      bit N-1
                        //      (possible parity bit)
                        //      (possible parity bit)
                        //      stop bit
                        //      stop bit
                        //      (possible secondary stop bit)
                        //      (possible secondary stop bit)
                        m_rx_data = ((i_tx&1)<<31) | (m_rx_data>>1);
                        m_rx_data = ((i_tx&1)<<31) | (m_rx_data>>1);
                } m_rx_baudcounter = m_baud_counts;
                } m_rx_baudcounter = m_baud_counts-1;
        } else
        } else
                m_rx_baudcounter--;
                m_rx_baudcounter--;
 
 
        if ((m_tx_state == TXIDLE)&&(m_conrd >= 0)) {
        if ((m_tx_state == TXIDLE)&&(m_conrd >= 0)) {
                struct  pollfd  pb;
                struct  pollfd  pb;
Line 314... Line 314...
                                        m_tx_data |= (p<<(m_nbits+m_nparity));
                                        m_tx_data |= (p<<(m_nbits+m_nparity));
                                }
                                }
                                m_tx_busy = (1<<(m_nbits+m_nparity+m_nstop+1))-1;
                                m_tx_busy = (1<<(m_nbits+m_nparity+m_nstop+1))-1;
                                m_tx_state = TXDATA;
                                m_tx_state = TXDATA;
                                o_rx = 0;
                                o_rx = 0;
                                m_tx_baudcounter = m_baud_counts;
                                m_tx_baudcounter = m_baud_counts-1;
                        } else if (nr < 0) {
                        } else if (nr < 0) {
                                fprintf(stderr, "ERR while attempting to read in--closing input port\n");
                                fprintf(stderr, "ERR while attempting to read in--closing input port\n");
                                perror("UARTSIM::read() ");
                                perror("UARTSIM::read() ");
                                m_conrd = -1;
                                m_conrd = -1;
                        } // and we really don't care if nr == 0 except that
                        } // and we really don't care if nr == 0 except that
Line 328... Line 328...
                m_tx_data >>= 1;
                m_tx_data >>= 1;
                m_tx_busy >>= 1;
                m_tx_busy >>= 1;
                if (!m_tx_busy)
                if (!m_tx_busy)
                        m_tx_state = TXIDLE;
                        m_tx_state = TXIDLE;
                else
                else
                        m_tx_baudcounter = m_baud_counts;
                        m_tx_baudcounter = m_baud_counts-1;
                o_rx = m_tx_data&1;
                o_rx = m_tx_data&1;
        } else {
        } else {
                m_tx_baudcounter--;
                m_tx_baudcounter--;
                o_rx = m_tx_data&1;
                o_rx = m_tx_data&1;
        }
        }

powered by: WebSVN 2.1.0

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