Files
FPGA_Uni/modules/instruction_counter.sv
T

27 lines
511 B
Systemverilog

`ifndef INSTRUCTION_COUNTER_H
`define INSTRUCTION_COUNTER_H
module instruction_counter #(parameter width=5)(
input logic [0:0] clk, input logic [0:0] we,
input logic [2**width-1:0] W,
output logic [2**width-1:0] addr
);
logic [2**width-1:0] pc;
initial begin
pc = {(2**width){1'b0}};
end
always_ff @(posedge clk) begin
if (we) begin
pc <= W;
end else begin
pc <= pc + 4;
end
end
assign addr = pc;
endmodule
`endif