资源描述
FA电路设计FIF源代码fine ADD_WIDTH8 /地址位宽defie TA_WIT8 /数据位宽defieR_WIDH 8 /数据位宽efine AM_EPTH26 /RAM深度mole ff_est(clk_100M,/写时钟clk_5M,/读时钟rst_n,/ 全局复位信号wre,/ 写使能低有效rd_n,/读使能低有效w_dat,/8位数据输入rd_dta,/8位数据输出wr_fl, 写满标志 高有效r_empy);/ 读空标志 高有效/输入信号 nput clk10M; ptl5M; inpt rn; inut wr_en; ipu r_n; nputDAAWITH-1:0wrdta; tput e ATA_WIDTH-1:0 rddta; outpu reg wu; upt regrd_pty; reg RAWIDTH-: meRAMDEH1:0;/ 位2单元eDDR_IDT1: wr_dd; / 8位写地址 egADDR_WIDTH-:0r_dr; /8读地址e rfla;regwrflag;/写地址产生逻辑 alays (osdge ck_100Moegeg s_) begin f(!r_)einr_ar = h0;wrla 0;ed else if(!wren)binif(!wr_ful& (rddr!=(wr_addr+1))beginw_flag = ;wradr = wr_ad +11;enelsewflag =0;end end/ 写数据产生逻辑 aws(posdge clk_00M) begin if(!w_n&!wr_ful& wr_flg) emwraddr= wr_a; end/写满产生标志 always (osdg clk_100or egedge r_n) egin if(!s_)wr_ful ; elsif(d_addr = (r_adr+1))wr_full =11;elsewrull= b0; d/读地址产生逻辑 lwas (poedge clM nedg rtn) bein f(!rst_n)begid_flag = ;r_addr = 80;e e f(!rd_en)beinif(!rempty & (_addr!=(dadr+1)))eginrd_fag = ;rd_ rdr + 1b1;endeed_fla = 0;ed n/读数据产生逻辑 alay (osedge clk5M) bgn if(!rden &!d_mty & r_flag) rd_data = mrdd; ed/读空产生标志 alwas (pedgec_M orngeger_n) egin if(!rt_)d_emty 1b; else if((r_a= (rd_adr+1)|(wraddr = d_addr)d_mpy =1b1;el d_empt = 1b0; endndodue/ 鼓励源代码:modle fo_tes_IB; reglk_0M;reg clk_M; rg rst_n; / 全局复位信号 er_e; / 写使能 g rd_en; /读使能 regDATA_WDTH-:0 wr_dt; wi:0 rd_dat;ewul;wi r_mpty;g7: nt;fio_tstffo1(clk100M,clk_5M, rs_,wr_en,rd_en,wr_daa,rd_data,wll,r_mty);alwys clk5M = clk_5M; /读时钟alays # cl100 =!k10; /写时钟inilbegin rst_n 0; clk_100M=0; clk_5M = ; wr_n 0; rden 0; #2 r =1; dlway (sge clk_10M rnegege rst_n)beginif(!rst_n)r_ta = d0;els wr_dta ct;endalways (posedge l_00M or eede st_)egiif(!rst_)ct d38;elt = cn 11;eneddule
展开阅读全文