名稱:FIFO設(shè)計(jì)16*8,數(shù)據(jù)顯示在數(shù)碼管(代碼在文末付費(fèi)下載)
軟件:Quartus
語(yǔ)言:Verilog
代碼功能:
使用verilog語(yǔ)言設(shè)計(jì)一個(gè)16*8的FIFO,深度16,寬度為8??蓪?duì)FIFO進(jìn)行寫(xiě)和讀,并將FIFO讀出的數(shù)據(jù)顯示到數(shù)碼管。
演示視頻:
FPGA代碼資源下載網(wǎng):hdlcode.com
部分代碼展示
//fifo?16×8fifo module?fifo_top ( input?clk, input?rst, input?[7:0]?din,//fifo寫(xiě)數(shù)據(jù) input?wr_en,//寫(xiě)使能 input?rd_en,//讀使能 output?empty,//空信號(hào) output?full,//滿信號(hào) output?[7:0]?bit_select,//數(shù)碼管位選,高電平選通 output?[7:0]?seg_select//數(shù)碼管段選,低電平點(diǎn)亮 ); wire?[7:0]?dout;//讀數(shù)據(jù) //fifo模塊 a_fifo?i_a_fifo ( .?clk(clk), .?rst(rst), .?din(din),//fifo寫(xiě)數(shù)據(jù) .?wr_en(wr_en),//寫(xiě)使能 .?rd_en(rd_en),//讀使能 .?dout(dout),//讀數(shù)據(jù) .?empty(empty),//空信號(hào) .?full(full)//滿信號(hào) ); //數(shù)碼管顯示模塊 display?i_display( .?clk(clk), .?din(din),//fifo寫(xiě)數(shù)據(jù) .?dout(dout),//讀數(shù)據(jù) .?bit_select(bit_select),//數(shù)碼管位選,高電平選中 .?seg_select(seg_select)//數(shù)碼管段選 ); endmodule //fifo?16×8fifo module?a_fifo ( input?clk, input?rst, input?[7:0]?din,//fifo寫(xiě)數(shù)據(jù) input?wr_en,//寫(xiě)使能 input?rd_en,//讀使能 output?reg?[7:0]?dout,//讀數(shù)據(jù) output?empty,//空信號(hào) output?full//滿信號(hào) ); reg?[7:0]?ram?[15:0];//RAM。深度16,寬度8 reg?[6:0]?count=7'd0; reg?[6:0]?rp=7'd0; reg?[6:0]?wp=7'd0; integer?i; always@(posedge?clk) if(rst)begin//復(fù)位 wp<=7'd0; rp<=7'd0; dout<=8'd0; count<=7'd0; for(i=0;i<16;i=i+1) ram[i]<=8'b00000000;//清零 end else case({rd_en,wr_en}) 2'b00:count<=count; 2'b01://單寫(xiě)FIFO if(~full)begin//未滿 ram[wp]<=din;//存入fifo if(wp>=7'd15) wp<=7'd0;//寫(xiě)地址循環(huán)累加 else wp<=wp+7'd1; count<=count+7'd1; rp<=rp; end 2'b10://單讀FIFO if(~empty)begin//未空 dout<=ram[rp];//讀fifo
設(shè)計(jì)文檔:
1. 工程文件
2. 程序文件
3. 程序編譯
4. RTL圖
5. Testbench
6. 仿真圖
整體仿真圖
Fifo模塊仿真圖
數(shù)碼管顯示模塊仿真圖
閱讀全文