1 Star 5 Fork 5

yhp/basic_verilog

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
UartTxExtreme.v 1.48 KB
一键复制 编辑 原始数据 按行查看 历史
//--------------------------------------------------------------------------------
// UartTxExtreme.v
// Konstantin Pavlov, pavlovconst@gmail.com
//--------------------------------------------------------------------------------
// INFO --------------------------------------------------------------------------------
// Extreme minimal UART transmitter
//
// CAUTION:
// optimized for 20MHz/115200
// tx_busy has been made asynchronous to tx_do_sample
// tx_start has no internal protection and should be rised only when tx_busy is low
/* --- INSTANTIATION TEMPLATE BEGIN ---
reg [7:0] tx_sample_cntr = 0;
always @ (posedge clk20) begin
if (tx_sample_cntr[7:0] == 0) begin
tx_sample_cntr[7:0] <= (173-1);
end else begin
tx_sample_cntr[7:0] <= tx_sample_cntr[7:0] - 1;
end
end
wire tx_do_sample = (tx_sample_cntr[7:0] == 0);
UartTxExtreme UT1 (
.clk(),
//.tx_do_sample(),
.tx_data(),
.tx_start(),
.tx_busy(),
.txd()
);
--- INSTANTIATION TEMPLATE END ---*/
module UartTxExtreme(clk, tx_do_sample, tx_data, tx_start, tx_busy, txd);
input wire clk;
input wire tx_do_sample;
input wire [7:0] tx_data;
input wire tx_start;
output wire tx_busy;
output reg txd = 1;
reg [9:0] tx_shifter = 0;
always @ (posedge clk) begin
if (tx_start && ~tx_busy) begin
tx_shifter[9:0] <= {1'b1,tx_data[7:0],1'b0};
end // tx_start
if (tx_do_sample && tx_busy) begin
{tx_shifter[9:0],txd} <= {tx_shifter[9:0],txd} >> 1;
end // tx_do_sample
end
assign
tx_busy = (tx_shifter[9:0] != 0);
endmodule
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/yuan_hp/basic_verilog.git
git@gitee.com:yuan_hp/basic_verilog.git
yuan_hp
basic_verilog
basic_verilog
master

搜索帮助