一、读写模块代码
`timescale 1ns / 1ps
module DDR3_w_r(
input init_calib_complete, //ddr3初始化完成
input ui_clk , //用户时钟
input ui_clk_sync_rst , //用户复位
input app_rdy , //ready信号
input app_wdf_rdy , //写ready信号
input [127:0] app_rd_data ,
input app_rd_data_valid ,
output reg [27:0] app_addr , //地址
output [2:0] app_cmd , //读写命令
output app_en , //使能
output reg [127:0] app_wdf_data , //写数据
output app_wdf_end , //一次突发时的最后一位数据的突发标志,在最后一位时拉高
output app_wdf_wren //写使能
);
//状态空间定义
parameter no1=4'b0001;
parameter wr =4'b0010;
parameter no2=4'b0100;
parameter rd =4'b1000;
parameter data_length = 8'd99;
reg [3:0] c_state;
reg [3:0] n_state;
reg [7:0] wr_cnt;
reg [7:0] rd_cnt;
always @(posedge ui_clk or negedge ui_clk_sync_rst)begin
if(ui_clk_sync_rst)begin
c_state <= no1;
end
else begin
c_state <= n_state;
end