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

Subversion Repositories osdvu

[/] [osdvu/] [trunk/] [uart.v] - Diff between revs 2 and 3

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

Rev 2 Rev 3
Line 51... Line 51...
// Constants - do not override.
// Constants - do not override.
parameter TX_IDLE = 0;
parameter TX_IDLE = 0;
parameter TX_SENDING = 1;
parameter TX_SENDING = 1;
parameter TX_DELAY_RESTART = 2;
parameter TX_DELAY_RESTART = 2;
 
 
reg [10:0] clk_divider = CLOCK_DIVIDE;
reg [10:0] rx_clk_divider = CLOCK_DIVIDE;
 
reg [10:0] tx_clk_divider = CLOCK_DIVIDE;
 
 
reg [2:0] recv_state = RX_IDLE;
reg [2:0] recv_state = RX_IDLE;
reg [5:0] rx_countdown;
reg [5:0] rx_countdown;
reg [3:0] rx_bits_remaining;
reg [3:0] rx_bits_remaining;
reg [7:0] rx_data;
reg [7:0] rx_data;
Line 83... Line 84...
        // The clk_divider counter counts down from
        // The clk_divider counter counts down from
        // the CLOCK_DIVIDE constant. Whenever it
        // the CLOCK_DIVIDE constant. Whenever it
        // reaches 0, 1/16 of the bit period has elapsed.
        // reaches 0, 1/16 of the bit period has elapsed.
   // Countdown timers for the receiving and transmitting
   // Countdown timers for the receiving and transmitting
        // state machines are decremented.
        // state machines are decremented.
        clk_divider = clk_divider - 1;
        rx_clk_divider = rx_clk_divider - 1;
        if (!clk_divider) begin
        if (!rx_clk_divider) begin
                clk_divider = CLOCK_DIVIDE;
                rx_clk_divider = CLOCK_DIVIDE;
                rx_countdown = rx_countdown - 1;
                rx_countdown = rx_countdown - 1;
 
        end
 
        tx_clk_divider = tx_clk_divider - 1;
 
        if (!tx_clk_divider) begin
 
                tx_clk_divider = CLOCK_DIVIDE;
                tx_countdown = tx_countdown - 1;
                tx_countdown = tx_countdown - 1;
        end
        end
 
 
        // Receive state machine
        // Receive state machine
        case (recv_state)
        case (recv_state)
Line 98... Line 103...
                        // A low pulse on the receive line indicates the
                        // A low pulse on the receive line indicates the
                        // start of data.
                        // start of data.
                        if (!rx) begin
                        if (!rx) begin
                                // Wait half the period - should resume in the
                                // Wait half the period - should resume in the
                                // middle of this first pulse.
                                // middle of this first pulse.
 
                                rx_clk_divider = CLOCK_DIVIDE;
                                rx_countdown = 8;
                                rx_countdown = 8;
                                recv_state = RX_CHECK_START;
                                recv_state = RX_CHECK_START;
                        end
                        end
                end
                end
                RX_CHECK_START: begin
                RX_CHECK_START: begin
Line 176... Line 182...
                                // state, start transmitting the current content
                                // state, start transmitting the current content
                                // of the tx_byte input.
                                // of the tx_byte input.
                                tx_data = tx_byte;
                                tx_data = tx_byte;
                                // Send the initial, low pulse of 1 bit period
                                // Send the initial, low pulse of 1 bit period
                                // to signal the start, followed by the data
                                // to signal the start, followed by the data
 
                                tx_clk_divider = CLOCK_DIVIDE;
                                tx_countdown = 16;
                                tx_countdown = 16;
                                tx_out = 0;
                                tx_out = 0;
                                tx_bits_remaining = 8;
                                tx_bits_remaining = 8;
                                tx_state = TX_SENDING;
                                tx_state = TX_SENDING;
                        end
                        end

powered by: WebSVN 2.1.0

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