Some bugs need to be fixed.
This commit is contained in:
85
testbench.sv
Executable file
85
testbench.sv
Executable file
@ -0,0 +1,85 @@
|
||||
`timescale 1ns / 1ps
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
// Company:
|
||||
// Engineer:
|
||||
//
|
||||
// Create Date: 2024/12/28 11:36:13
|
||||
// Design Name:
|
||||
// Module Name: testbench
|
||||
// Project Name:
|
||||
// Target Devices:
|
||||
// Tool Versions:
|
||||
// Description:
|
||||
//
|
||||
// Dependencies:
|
||||
//
|
||||
// Revision:
|
||||
// Revision 0.01 - File Created
|
||||
// Additional Comments:
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
module Top_tb;
|
||||
|
||||
// 输入信号
|
||||
reg clock;
|
||||
reg reset;
|
||||
|
||||
// 输出信号
|
||||
wire io_exit;
|
||||
wire [3:0] io_anodes;
|
||||
wire [6:0] io_segments;
|
||||
|
||||
// 内部信号(用于监视)
|
||||
wire [31:0] pc; // 程序计数器
|
||||
wire [31:0] instruction; // 当前指令
|
||||
|
||||
// 实例化 Top 模块
|
||||
Top uut (
|
||||
.clock (clock),
|
||||
.reset (reset),
|
||||
.io_exit (io_exit),
|
||||
.io_anodes (io_anodes),
|
||||
.io_segments(io_segments)
|
||||
);
|
||||
|
||||
// 连接到 Core 模块的内部信号
|
||||
assign pc = uut.core.if_reg_pc; // 假设 if_reg_pc 是 Core 模块中的 pc 寄存器
|
||||
assign instruction = uut.core.id_reg_inst; // 假设 id_reg_inst 是 Core 模块中的当前指令
|
||||
|
||||
// 时钟生成
|
||||
initial begin
|
||||
clock = 0;
|
||||
forever #5 clock = ~clock; // 10ns 周期时钟
|
||||
end
|
||||
|
||||
// 测试逻辑
|
||||
initial begin
|
||||
// 初始化信号
|
||||
reset = 1;
|
||||
#20; // 等待 20ns
|
||||
|
||||
// 释放复位信号
|
||||
reset = 0;
|
||||
#200; // 等待 200ns
|
||||
|
||||
// 观察 io_exit 信号
|
||||
if (io_exit) begin
|
||||
$display("Test Passed: io_exit is high.");
|
||||
end else begin
|
||||
$display("Test Failed: io_exit is low.");
|
||||
end
|
||||
|
||||
// 结束仿真
|
||||
$finish;
|
||||
end
|
||||
|
||||
// 监视信号变化
|
||||
initial begin
|
||||
$monitor("Time: %0t | Reset: %b | PC: %h | Instruction: %h | io_exit: %b",
|
||||
$time, reset, pc, instruction, io_exit);
|
||||
end
|
||||
|
||||
endmodule
|
||||
Reference in New Issue
Block a user