Program Counter - Untested

This commit is contained in:
jc4419 2020-11-30 16:08:58 +04:00 committed by GitHub
parent 841081c152
commit 02f3f1cbba
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

43
rtl/mips_cpu_pc.v Normal file
View file

@ -0,0 +1,43 @@
module ProgramCounter(
input logic rst,
input logic clk,
input logic[31:0] pcWriteAddr,
input logic pcWriteEn,
output logic[31:0] pcRes,
);
logic[31:0] pcIncr;
initial begin
pcRes <= 32'h00000000;
end
always_comb begin
pcIncr = pcRes + 32'h00000004
end
always @(posedge clk)
begin
if (rst == 1)
begin
pcRes <= 32'h00000000;
end
else
begin
if (pcWriteEn == 1) begin
pcRes <= pcWriteAddr;
end
else begin
pcRes <= pcIncr;
end
end
$display("pc = %h",pcRes);
end
endmodule