This commit is contained in:
2025-11-06 10:44:25 +08:00
parent 949396519e
commit 40ddda13c4
25 changed files with 66164 additions and 74 deletions

View File

@@ -31,8 +31,6 @@
** - "program.hex" 的路径在 `instruction_memory.v` 模块中指定
*******************************************************************************/
`timescale 1ns / 1ps
module cpu_tb;
// --- 信号声明 ---
@@ -66,7 +64,7 @@ module cpu_tb;
// 2. 设定仿真运行时间后停止
// 由于测试程序末尾通常是无限循环因此需要手动设置仿真停止时间
#500; // 仿真运行500纳秒
#5000; // 仿真运行5000纳秒
// 3. 仿真结束前打印寄存器堆的最终状态
$display("\n------------------------------------------------------------");
@@ -89,13 +87,10 @@ module cpu_tb;
// 在每个时钟周期的下降沿采样并显示信息以确保在该时刻所有待显示的信号值均已稳定
always @(negedge clk) begin
if (!rst) begin //仅在非复位状态下显示
$display("时间: %0t ns | PC: 0x%08h | 指令: 0x%08h | R4=0x%h R5=0x%h R6=0x%h",
$display("时间: %0t ns | PC: 0x%08h | 指令: 0x%08h",
$time, // 当前仿真时间
uut.pc_out, // PC的当前值
uut.instr, // 当前PC指向的指令
uut.u_reg_file.registers[4], // R4寄存器的值
uut.u_reg_file.registers[5], // R5寄存器的值
uut.u_reg_file.registers[6] // R6寄存器的值
uut.instr // 当前PC指向的指令
);
end
end