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

Subversion Repositories mips32r1

[/] [mips32r1/] [trunk/] [Hardware/] [XUPV5-LX110T_SoC/] [MIPS32-Pipelined-Hw/] [src/] [UART/] [uart_tx.v] - Blame information for rev 2

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 ayersg
`timescale 1ns / 1ps
2
/*
3
 * File         : uart_tx.v
4
 * Project      : University of Utah, XUM Project MIPS32 core
5
 * Creator(s)   : Grant Ayers (ayers@cs.utah.edu)
6
 *
7
 * Modification History:
8
 *   Rev   Date         Initials  Description of Change
9
 *   1.0   25-Mar-2010  GEA       Initial design.
10
 *
11
 * Standards/Formatting:
12
 *   Verilog 2001, 4 soft tab, wide column.
13
 *
14
 * Description:
15
 *   Transmits bytes of data from the serial port. Capable of back-to-back
16
 *   transmission of data for maximum bandwidth utilization.
17
 *   'TxD_start' must only pulse with a 'uart_tick' pulse. 8N1.
18
 */
19
module uart_tx (
20
    input clock,
21
    input reset,
22
    input uart_tick,
23
    input [7:0] TxD_data,
24
    input TxD_start,    // Must happen with a uart_tick
25
    output ready,
26
    output reg TxD
27
    );
28
 
29
    localparam [3:0] IDLE=0, START=1, BIT_0=2, BIT_1=3, BIT_2=4, BIT_3=5,
30
                     BIT_4=6, BIT_5=7, BIT_6=8, BIT_7=9, STOP=10;
31
 
32
    reg [3:0] tx_state = IDLE;
33
    reg [7:0] TxD_data_r = 8'h00;    // Registered input data so it doesn't need to be held
34
 
35
    assign ready = (tx_state == IDLE) || (tx_state == STOP);
36
 
37
    always @(posedge clock) begin
38
        TxD_data_r <= (ready & TxD_start) ? TxD_data : TxD_data_r;
39
    end
40
 
41
    always @(posedge clock) begin
42
        if (reset) tx_state <= IDLE;
43
        else begin
44
            case (tx_state)
45
                IDLE:   if (TxD_start) tx_state <= START;
46
                START:  if (uart_tick) tx_state <= BIT_0;
47
                BIT_0:  if (uart_tick) tx_state <= BIT_1;
48
                BIT_1:  if (uart_tick) tx_state <= BIT_2;
49
                BIT_2:  if (uart_tick) tx_state <= BIT_3;
50
                BIT_3:  if (uart_tick) tx_state <= BIT_4;
51
                BIT_4:  if (uart_tick) tx_state <= BIT_5;
52
                BIT_5:  if (uart_tick) tx_state <= BIT_6;
53
                BIT_6:  if (uart_tick) tx_state <= BIT_7;
54
                BIT_7:  if (uart_tick) tx_state <= STOP;
55
                STOP:   if (uart_tick) tx_state <= (TxD_start) ? START : IDLE;
56
                default: tx_state <= 4'bxxxx;
57
            endcase
58
        end
59
    end
60
 
61
    always @(tx_state, TxD_data_r) begin
62
        case (tx_state)
63
            IDLE:   TxD <= 1;
64
            START:  TxD <= 0;
65
            BIT_0:  TxD <= TxD_data_r[0];
66
            BIT_1:  TxD <= TxD_data_r[1];
67
            BIT_2:  TxD <= TxD_data_r[2];
68
            BIT_3:  TxD <= TxD_data_r[3];
69
            BIT_4:  TxD <= TxD_data_r[4];
70
            BIT_5:  TxD <= TxD_data_r[5];
71
            BIT_6:  TxD <= TxD_data_r[6];
72
            BIT_7:  TxD <= TxD_data_r[7];
73
            STOP:   TxD <= 1;
74
            default: TxD <= 1'bx;
75
        endcase
76
    end
77
 
78
endmodule

powered by: WebSVN 2.1.0

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