This repository has been archived on 2024-02-21. You can view files and clone it, but cannot push or open issues or pull requests.
2020-06-09 15:48:03 +08:00

57 lines
933 B
Verilog

module uart_tx_top(
clk,
rst_n,
tx
);
input clk;
input rst_n;
output tx;
wire tx_done;
reg [7:0] data;
reg [4:0] str_cnt;
uart_tx uart0 (
.baud_set(2'b00),
.clk(clk),
.tx_data(data),
.en(1'b1),
.rst_n(rst_n),
.tx(tx),
.tx_done(tx_done)
);
always @ (posedge clk or negedge rst_n)
if(!rst_n)
str_cnt <= 4'd0;
else if(str_cnt == 13)
str_cnt <= 4'd0;
else if(tx_done)
str_cnt <= str_cnt + 4'd1;
always @ (posedge clk or negedge rst_n)
if(!rst_n)
data <=8'hff;
else if(tx_done)
case(str_cnt)
4'd00 : data <= "H";
4'd01 : data <= "e";
4'd02 : data <= "l";
4'd03 : data <= "l";
4'd04 : data <= "o";
4'd05 : data <= " ";
4'd06 : data <= "F";
4'd07 : data <= "P";
4'd08 : data <= "G";
4'd09 : data <= "A";
4'd10 : data <= ".";
4'd11 : data <= "\r";
4'd12 : data <= "\n";
default: data <= 8'hff;
endcase
endmodule