⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 uartr.v

📁 很好的一个东西,希望能对大家有所帮助.关于PWM的编程.
💻 V
字号:
module uartr(clk,rst,rxd,out,ri,cri);

input clk,rst;
input rxd;
output[7:0] out;
output ri;
input cri;

reg ri;
reg[7:0] out;

reg[11:0] cnt;
reg[3:0] m;
reg rip;
reg[7:0] sft;

always@(posedge(clk))
begin
  if(rst==1)begin
    m=0;
    rip=0;
  end else begin
    case(m)
      0:begin
        if(rxd==0)begin
          cnt=0;
          m=1;
        end
      end
      1:begin
        cnt=cnt+1;
        if(cnt>=1719)begin
          cnt=0;
          m=2;
        end
      end
      2,3,4,5,6,7,8,9:begin
        cnt=cnt+1;
        if(cnt>=3437)begin
          cnt=0;
          sft=sft>>1;
          sft[7]=rxd;
          m=m+1;
        end
      end
      10:begin
        cnt=cnt+1;
        if(cnt>=3437)begin
          m=m+1;
        end
      end
      11:begin
        if(rxd==1)begin
          rip=1;
          out=sft;
          m=0;
        end
      end
    endcase
  end
end

always@(posedge(clk))
begin
  if(cri==1)begin
    ri=0;
  end else if(rip==1)begin
    ri=1;
  end
end

endmodule

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -