|
楼主 |
发表于 2014-7-31 12:32:22
|
显示全部楼层
回复 4# haitaox
module tb_ddr3_ctrl;
// Inputs
reg sys_clk_p;
reg sys_clk_n;
reg clk_ref_p;
reg clk_ref_n;
reg app_wdf_wren;
reg [31:0] app_wdf_data;
reg [3:0] app_wdf_mask;
reg app_wdf_end;
reg [28:0] app_addr;
reg [2:0] app_cmd;
reg app_en;
reg sys_rst;
// Outputs
wire [14:0] ddr3_addr;
wire [2:0] ddr3_ba;
wire ddr3_ras_n;
wire ddr3_cas_n;
wire ddr3_we_n;
wire ddr3_reset_n;
wire [0:0] ddr3_cs_n;
wire [0:0] ddr3_odt;
wire [0:0] ddr3_cke;
wire [0:0] ddr3_dm;
wire [0:0] ddr3_ck_p;
wire [0:0] ddr3_ck_n;
wire app_rdy;
wire app_wdf_rdy;
wire [31:0] app_rd_data;
wire app_rd_data_end;
wire app_rd_data_valid;
wire ui_clk_sync_rst;
wire ui_clk;
wire phy_init_done;
// Bidirs
wire [7:0] ddr3_dq;
wire [0:0] ddr3_dqs_p;
wire [0:0] ddr3_dqs_n;
// Instantiate the Unit Under Test (UUT)
ddr3_ctrl uut (
.sys_clk_p(sys_clk_p),
.sys_clk_n(sys_clk_n),
.clk_ref_p(clk_ref_p),
.clk_ref_n(clk_ref_n),
.ddr3_dq(ddr3_dq),
.ddr3_addr(ddr3_addr),
.ddr3_ba(ddr3_ba),
.ddr3_ras_n(ddr3_ras_n),
.ddr3_cas_n(ddr3_cas_n),
.ddr3_we_n(ddr3_we_n),
.ddr3_reset_n(ddr3_reset_n),
.ddr3_cs_n(ddr3_cs_n),
.ddr3_odt(ddr3_odt),
.ddr3_cke(ddr3_cke),
.ddr3_dm(ddr3_dm),
.ddr3_dqs_p(ddr3_dqs_p),
.ddr3_dqs_n(ddr3_dqs_n),
.ddr3_ck_p(ddr3_ck_p),
.ddr3_ck_n(ddr3_ck_n),
.app_wdf_wren(app_wdf_wren),
.app_wdf_data(app_wdf_data),
.app_wdf_mask(app_wdf_mask),
.app_wdf_end(app_wdf_end),
.app_addr(app_addr),
.app_cmd(app_cmd),
.app_en(app_en),
.app_rdy(app_rdy),
.app_wdf_rdy(app_wdf_rdy),
.app_rd_data(app_rd_data),
.app_rd_data_end(app_rd_data_end),
.app_rd_data_valid(app_rd_data_valid),
.ui_clk_sync_rst(ui_clk_sync_rst),
.ui_clk(ui_clk),
.phy_init_done(phy_init_done),
.sys_rst(sys_rst)
);
initial begin
// Initialize Inputs
sys_clk_p = 0;
sys_clk_n = 0;
clk_ref_p = 0;
clk_ref_n = 0;
app_wdf_wren = 0;
app_wdf_data = 0;
app_wdf_mask = 0;
app_wdf_end = 0;
app_addr = 0;
app_cmd = 0;
app_en = 0;
sys_rst = 0;
//sys_rst = 0;
#300000
sys_rst = 1'b1;
#660000
sys_rst = 1'b1;
// Wait 100 ns for global reset to finish
#100;
// Add stimulus here
end
reg sys_clk;
reg clk_ref;
initial begin
sys_clk = 1'b0;
clk_ref = 1'b1;
end
// Generate system clock = twice rate of CLK
always
sys_clk = #1.25 ~sys_clk;
// Generate IDELAYCTRL reference clock (200MHz)
always
clk_ref = #2.5 ~clk_ref;
always @(*)
begin
sys_clk_p = sys_clk;
sys_clk_n = ~sys_clk;
end
always @(*)
begin
clk_ref_p = clk_ref;
clk_ref_n = ~clk_ref;
end
endmodule
这就是我的TB文件 |
|