📄 rs232_receive.txt
字号:
module rs232_receive(clk,rxd,dout,into);
input clk,rxd;
output into;
output[7:0] dout;
reg bt_cp,cy_cp,into;
reg[3:0] rxd_st; //the staute of receiving
reg[2:0] cy_st; //1/8 time using
reg[9:0] bt; //the speed of every bit to rs232
reg[7:0] dout;
always @(posedge clk)
begin
bt=(bt!=71)?bt+1:0; //edit speed 19200 bit/s
bt_cp=(bt==71)?1:0;
end
always @(posedge bt_cp)
begin
if((rxd==1)&&(rxd_st==0)) cy_st=0;
else cy_st=cy_st+1;
cy_cp=(cy_st==4)?1:0; //the forth clect point
end
always @(posedge cy_cp)
begin
case(rxd_st)
0:begin rxd_st=(rxd==0)?1:0;into=1;end
1:begin rxd_st=2;dout[0]=rxd;end
2:begin rxd_st=3;dout[1]=rxd;end
3:begin rxd_st=4;dout[2]=rxd;end
4:begin rxd_st=5;dout[3]=rxd;end
5:begin rxd_st=6;dout[4]=rxd;end
6:begin rxd_st=7;dout[5]=rxd;end
7:begin rxd_st=8;dout[6]=rxd;end
8:begin rxd_st=0;dout[7]=rxd;into=0;end
default:rxd_st=0;
endcase
end
endmodule
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -