This commit is contained in:
2025-08-20 05:07:46 +03:00
parent 679282782b
commit 3c2407543d
4 changed files with 683 additions and 0 deletions

40
chapter5/RISCcore2TB.v Normal file
View File

@@ -0,0 +1,40 @@
module RISCcore2TB;
reg clk;
reg rst;
wire [31:0] pc;
wire [31:0] next_pc;
wire [31:0] instr;
// Instantiate RISC core
RISCcore2 uut (
.rst(rst),
.clk(clk),
.pc(pc),
.next_pc(next_pc),
.instr(instr)
);
// Clock generation
always #5 clk = ~clk;
// Monitor
always @(posedge clk) begin
if (!rst) begin
$display("Time=%0t, PC=%h, Next_PC=%h, Instr=%h", $time, pc, next_pc, instr);
if (pc >= 32'h100) begin // Safety stop
$display("Simulation completed!");
$finish;
end
end
end
// Initialize
initial begin
clk = 0;
rst = 1;
#15 rst = 0;
#500;
$display("Test completed");
$finish;
end
endmodule