Files
IC_PRJ/tb/tb_array_ref.v

103 lines
2.6 KiB
Verilog
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

`timescale 1ns/1ps
module tb_array_ref();
// 输入信号定义
reg clk;
reg rst_n;
reg array_ref_start;
reg [7:0] array_inner_tras;
reg [7:0] array_inner_trp;
// 输出信号定义
wire array_ref_done;
wire array_ref_csn;
wire [15:0] array_ref_raddr;
// 实例化待测试模块
array_ref uut (
.clk (clk),
.rst_n (rst_n),
.array_ref_start (array_ref_start),
.array_ref_done (array_ref_done),
.array_ref_csn (array_ref_csn),
.array_ref_raddr (array_ref_raddr),
.array_inner_tras (array_inner_tras),
.array_inner_trp (array_inner_trp)
);
// 时钟生成10ns周期100MHz
initial begin
clk = 0;
forever #1.25 clk = ~clk;
end
// 主测试流程
initial begin
// 初始化信号
rst_n = 0;
array_ref_start = 0;
array_inner_tras = 8'd2; // RAS周期为2个时钟
array_inner_trp = 8'd1; // RP周期为1个时钟
// 复位释放
#20;
rst_n = 1;
#10;
// 启动刷新操作
@(posedge clk);
array_ref_start = 1;
@(posedge clk);
array_ref_start = 0; // 释放启动信号
// 等待刷新完成(全地址遍历)
wait(array_ref_done);
$display("=== 第一次完整刷新完成 ===");
#50;
// // 测试不同的tras和trp参数
// array_inner_tras = 8'd3;
// array_inner_trp = 8'd2;
// @(posedge clk);
// array_ref_start = 1;
// @(posedge clk);
// array_ref_start = 0;
// wait(array_ref_done);
// $display("=== 第二次完整刷新完成 ===");
// #50;
// // 测试中途复位
// @(posedge clk);
// array_ref_start = 1;
// @(posedge clk);
// array_ref_start = 0;
// #30;
// rst_n = 0;
// #20;
// rst_n = 1;
// $display("=== 复位测试完成 ===");
// 结束仿真
#100;
$display("=== 仿真结束 ===");
$finish;
end
initial begin
$fsdbDumpfile("tb.fsdb");
$fsdbDumpvars(0,tb_array_ref,"+all");
$vcdpluson;
$vcdplusmemon;
end
// 监控信号变化
initial begin
$monitor(
"Time: %0t, State: %b, raddr: %h, csn: %b, done: %b, ras_cnt: %h, rp_cnt: %h",
$time, uut.cur_state, array_ref_raddr, array_ref_csn, array_ref_done,
uut.ref_ras_cnt, uut.ref_rp_cnt
);
end
endmodule