41 lines
		
	
	
		
			719 B
		
	
	
	
		
			Verilog
		
	
	
	
	
	
			
		
		
	
	
			41 lines
		
	
	
		
			719 B
		
	
	
	
		
			Verilog
		
	
	
	
	
	
| 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
 |