uart232串口之二——fpg内部回环仿真
该模块功能, 接收数据。 module rs232_rx_cnt( clk, rst_n, sel_bps, uart_rx, rx_done, data_recv); input clk; input rst_n; input uart_rx; input [2:0] sel_bps; output rx_done; output [7:0] data_recv; reg [11:0] cnt1;//第一阶段计数器 reg [12:0] cnt2; reg [12:0] Time; always @(*) begin if (sel_bps == 3'd0) Time <= 5208; //9600 else if (sel_bps == 3'd1) Time <= 1302; //38400 else if (sel_bps == 3'd2) Time <= 434; //115200 else Time <= 5208; end reg rx1,rx2; always @ (posedge clk or negedge rst_n) begin if ( rst_n == 1'b0) begin rx1 <= 1'b0; rx2 <= 1'b0; end else if (sta ==IDLE) begin rx1 <= uart_rx; rx2 <= rx1; end