0% found this document useful (0 votes)
6 views2 pages

Testbench

Uploaded by

engrmm101
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views2 pages

Testbench

Uploaded by

engrmm101
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

// Code your testbench here

// or browse Examples
module pc_tb();

reg clk;
reg rst;
reg branch_flag;
reg [31:0] instruction_in;

wire [31:0] pc_value;

reg [31:0] instruction_memory [0:255];

Program_Counter uut (
.clk(clk),
.rst(rst),
.branch_flag(branch_flag),
.instruction_in(instruction_in),
.pc_value(pc_value)
);

always #5 clk = ~clk;

initial begin

clk = 0;
rst = 0;
branch_flag = 0;
instruction_in = 32'b0;

$readmemh("C:\Users\MUHAMMAD MUZZAMIL\Documents\IM.txt", instruction_memory);

rst = 1;
#10;
rst = 0;

#10;
instruction_in = instruction_memory[0];

#20;
branch_flag = 1;
instruction_in = instruction_memory[1];
#10;

branch_flag = 0;
instruction_in = instruction_memory[2];
#10;
instruction_in = instruction_memory[3];
#10;

$finish;
end

initial begin
$monitor("At time %t, PC Value = %h, Instruction = %h", $time, pc_value,
instruction_in);
end

endmodule

You might also like