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

📄 baudselect.v

📁 FPGA上实现UART串口原程序
💻 V
字号:
module baudselect(baud,clk,key);
    input clk;
    output [13:0] baud;
    input key;


	 reg [13:0] baud;
	 reg[13:0] count;
	 reg scan;
	 reg[9:0] keyshift;
	 reg[3:0] select;



always @(posedge clk)
begin
 if(count==5000) begin
   count<=0;
	scan<=1;
 end
 else  begin
  count<=count+1;
  scan<=0;
  end
end

always @(posedge scan)
begin
 keyshift<={keyshift[8:0],key};
 if(keyshift==512) begin
  if(select<4)
    select<=select+1;
	 else
	 select<=0;
 end  
 end
 

always @(posedge clk)
begin
 case(select)
 1: baud=10416;
 2: baud=325;	//9600
 3: baud=162;
 4: baud=26;
 default: baud=325;
 endcase
end



endmodule

⌨️ 快捷键说明

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