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

Subversion Repositories rtfsimpleuart

[/] [rtfsimpleuart/] [trunk/] [rtl/] [verilog/] [rtfSimpleUartTx.v] - Diff between revs 4 and 12

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

Rev 4 Rev 12
Line 47... Line 47...
        |Data port, maximum operand size:       8 bit
        |Data port, maximum operand size:       8 bit
        |Data transfer ordering:                        Undefined
        |Data transfer ordering:                        Undefined
        |Data transfer sequencing:                      Undefined
        |Data transfer sequencing:                      Undefined
        +- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        +- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        |Clock frequency constraints:           none
        |Clock frequency constraints:           none
 
    |      Baud Generates by X16 or X8 CLK_I depends on baud8x pin
        +- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        +- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        |Supported signal list and                      Signal Name             WISHBONE equiv.
        |Supported signal list and                      Signal Name             WISHBONE equiv.
        |cross reference to equivalent          ack_o                   ACK_O
        |cross reference to equivalent          ack_o                   ACK_O
        |WISHBONE signals
        |WISHBONE signals
        |                                                                       clk_i                   CLK_I
        |                                                                       clk_i                   CLK_I
Line 79... Line 80...
        input we_i,                     // write transmitter
        input we_i,                     // write transmitter
        input [7:0] dat_i,       // data in
        input [7:0] dat_i,       // data in
        //--------------------
        //--------------------
        input cs_i,                     // chip select
        input cs_i,                     // chip select
        input baud16x_ce,       // baud rate clock enable
        input baud16x_ce,       // baud rate clock enable
 
    input tri0 baud8x,       // switches to mode baudX8
        input cts,                      // clear to send
        input cts,                      // clear to send
        output txd,                     // external serial output
        output txd,                     // external serial output
        output reg empty        // buffer is empty
        output reg empty,       // buffer is empty
 
    output reg txc          // tx complete flag
);
);
 
 
reg [9:0] tx_data;       // transmit data working reg (raw)
reg [9:0] tx_data;       // transmit data working reg (raw)
reg [7:0] fdo;           // data output
reg [7:0] fdo;           // data output
reg [7:0] cnt;           // baud clock counter
reg [7:0] cnt;           // baud clock counter
reg rd;
reg rd;
 
 
 
wire isX8;
 
buf(isX8, baud8x);
 
reg  modeX8;
 
 
assign ack_o = cyc_i & stb_i & cs_i;
assign ack_o = cyc_i & stb_i & cs_i;
assign txd = tx_data[0];
assign txd = tx_data[0];
 
 
always @(posedge clk_i)
always @(posedge clk_i)
        if (ack_o & we_i) fdo <= dat_i;
        if (ack_o & we_i) fdo <= dat_i;
Line 103... Line 110...
        else begin
        else begin
        if (ack_o & we_i) empty <= 0;
        if (ack_o & we_i) empty <= 0;
        else if (rd) empty <= 1;
        else if (rd) empty <= 1;
        end
        end
 
 
 
`define CNT_FINISH (8'h9F)
always @(posedge clk_i)
always @(posedge clk_i)
        if (rst_i) begin
        if (rst_i) begin
                cnt <= 8'h00;
                cnt <= `CNT_FINISH;
                rd <= 0;
                rd <= 0;
                tx_data <= 10'h3FF;
                tx_data <= 10'h3FF;
 
        txc <= 1'b1;
 
        modeX8 <= 1'b0;
        end
        end
        else begin
        else begin
 
 
                rd <= 0;
                rd <= 0;
 
 
                if (baud16x_ce) begin
                if (baud16x_ce) begin
 
 
                        cnt <= cnt + 1;
 
                        // Load next data ?
                        // Load next data ?
                        if (cnt==8'h9F) begin
                        if (cnt==`CNT_FINISH) begin
                                cnt <= 0;
                modeX8 <= isX8;
                                if (!empty && cts) begin
                                if (!empty && cts) begin
                                        tx_data <= {1'b1,fdo,1'b0};
                                        tx_data <= {1'b1,fdo,1'b0};
                                        rd <= 1;
                                        rd <= 1;
 
                    cnt <= modeX8;
 
                    txc <= 1'b0;
                                end
                                end
 
                else
 
                    txc <= 1'b1;
                        end
                        end
                        // Shift the data out. LSB first.
                        // Shift the data out. LSB first.
                        else if (cnt[3:0]==4'hF)
                        else begin
                                tx_data <= {1'b1,tx_data[9:1]};
                cnt[7:1] <= cnt[7:1] + cnt[0];
 
                cnt[0] <= ~cnt[0] | (modeX8);
 
 
 
                if (cnt[3:0]==4'hF)
 
                    tx_data <= {1'b1,tx_data[9:1]};
 
            end
                end
                end
        end
        end
 
 
endmodule
endmodule
 
 
 No newline at end of file
 No newline at end of file

powered by: WebSVN 2.1.0

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