bugfix
This commit is contained in:
40
chapter5/RISCcore2TB.v
Normal file
40
chapter5/RISCcore2TB.v
Normal 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
|
Reference in New Issue
Block a user