特权同学SDRAM中datagene模块,640ns是怎么产生的,clk明明是25M
时间:10-02
整理:3721RD
点击:
reg[13:0] delay; //500us延时计数器
always @(posedge clk or negedge rst_n)
if(!rst_n) delay <= 14'd0;
else if(delay < 14'd12500) delay <= delay+1'b1;
wire delay_done = (delay == 14'd12500); //1ms延时结束
//------------------------------------------
//每640ns写入8个16bit数据到sdram,
//上电后所有地址写入完毕时间需要不到360ms时间
reg[5:0] cntwr; //写sdram定时计数器
always @(posedge clk or negedge rst_n)
if(!rst_n) cntwr <= 6'd0;
else if(delay_done) cntwr <= cntwr+1'b1;
//------------------------------------------
//读写sdram地址产生
reg[18:0] addr; //sdram地址寄存器
always @(posedge clk or negedge rst_n)
if(!rst_n) addr <= 19'd0;
else if(!wr_done && cntwr == 6'h3f) addr <= addr+1'b1;//写地址产生
else if(wr_done && neg_rdack) addr <= addr+1'b1; //读地址产生 ////////////test
assign moni_addr = {addr,3'b000};
always @(posedge clk or negedge rst_n)
if(!rst_n) delay <= 14'd0;
else if(delay < 14'd12500) delay <= delay+1'b1;
wire delay_done = (delay == 14'd12500); //1ms延时结束
//------------------------------------------
//每640ns写入8个16bit数据到sdram,
//上电后所有地址写入完毕时间需要不到360ms时间
reg[5:0] cntwr; //写sdram定时计数器
always @(posedge clk or negedge rst_n)
if(!rst_n) cntwr <= 6'd0;
else if(delay_done) cntwr <= cntwr+1'b1;
//------------------------------------------
//读写sdram地址产生
reg[18:0] addr; //sdram地址寄存器
always @(posedge clk or negedge rst_n)
if(!rst_n) addr <= 19'd0;
else if(!wr_done && cntwr == 6'h3f) addr <= addr+1'b1;//写地址产生
else if(wr_done && neg_rdack) addr <= addr+1'b1; //读地址产生 ////////////test
assign moni_addr = {addr,3'b000};
奖励2积分