久久ER99热精品一区二区-久久精品99国产精品日本-久久精品免费一区二区三区-久久综合九色综合欧美狠狠

新聞中心

EEPW首頁 > EDA/PCB > 設計應用 > 基于FPGA的UART、USB接口協議設計

基于FPGA的UART、USB接口協議設計

作者: 時間:2012-03-13 來源:網絡 收藏

//-------------------------------------

//Capture the falling of data transfer over

reg txd_flag_r0,txd_flag_r1;

always@(posedge clk or negedge rst_n)

begin

if(!rst_n)

begin

txd_flag_r0 = 0;

txd_flag_r1 = 0;

end

else

begin

txd_flag_r0 = txd_flag_r;

txd_flag_r1 = txd_flag_r0;

end

end

assign txd_flag = txd_flag_r1 ~txd_flag_r0;

(3)RXD發送模塊

由于接收數據的時候,主控是PC,從機是,因此需要采樣數據。以上波特率發生器中講到過,采樣時鐘clk_bps = 16*clk_bps。硬件描述,通過計數,當采樣到RXD數據起始位信號有效時,0-7-15開始計數,,其中7為數據的中點,最穩定的時刻。因此在此時采樣數據,能夠達到最穩定的效果。Bingo設計代碼如下:

always@(posedge clk or negedge rst_n)

begin

if(!rst_n)

begin

smp_cnt = 0;

rxd_cnt = 0;

rxd_data = 0;

rxd_state = R_IDLE;

end

else if(clk_smp == 1)

begin

case(rxd_state)

R_IDLE:

begin

rxd_cnt = 0;

if(rxd_sync == 1'b0)

begin

smp_cnt = smp_cnt + 1'b1;

if(smp_cnt == 4'd7) //8 clk_smp enable

rxd_state = R_SAMPLE;

end

else

smp_cnt = 0;

end

R_SAMPLE:

begin

smp_cnt = smp_cnt +1'b1;

if(smp_cnt == 4'd7)

begin

rxd_cnt = rxd_cnt +1'b1;

if(rxd_cnt == 4'd7)

rxd_state = R_IDLE;

case(rxd_cnt)

3'd0: rxd_data[0] = rxd_sync;

3'd1: rxd_data[1] = rxd_sync;

3'd2: rxd_data[2] = rxd_sync;

3'd3: rxd_data[3] = rxd_sync;

3'd4: rxd_data[4] = rxd_sync;

3'd5: rxd_data[5] = rxd_sync;

3'd6: rxd_data[6] = rxd_sync;

3'd7: rxd_data[7] = rxd_sync;

endcase

end

end

endcase

end

end

c++相關文章:c++教程




關鍵詞: FPGA UART USB 接口

評論


相關推薦

技術專區

關閉