uarts.v
来自「很好的一个东西,希望能对大家有所帮助.关于PWM的编程.」· Verilog 代码 · 共 61 行
V
61 行
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 + =
减小字号Ctrl + -
显示快捷键?