📄 uarts.v
字号:
module uarts(clk,rst,txd,in,ti,s);
input clk,rst;
output txd;
input[7:0] in;
output ti;
input s;
reg txd,ti;
reg[11:0] cnt;
reg[3:0] m;
reg[7:0] sft;
always@(posedge(clk))
begin
if(rst==1)begin
m=0;
ti=1;
end else begin
case(m)
0:begin
if(s==1)begin
m=1;
sft=in;
ti=0;
end
end
1:begin
txd=0;
cnt=0;
m=2;
end
2,3,4,5,6,7,8,9:begin
cnt=cnt+1;
if(cnt>=3437)begin
cnt=0;
txd=sft[0];
sft=sft>>1;
m=m+1;
end
end
10:begin
cnt=cnt+1;
if(cnt>=3437)begin
txd=1;
m=m+1;
end
end
11:begin
if(s==0)begin
m=0;
ti=1;
end
end
endcase
end
end
endmodule
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -