mirror of
https://github.com/supleed2/ELEC50010-IAC-CW.git
synced 2024-12-23 05:45:47 +00:00
Program Counter - Untested
This commit is contained in:
parent
841081c152
commit
02f3f1cbba
43
rtl/mips_cpu_pc.v
Normal file
43
rtl/mips_cpu_pc.v
Normal 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
|
Loading…
Reference in a new issue