1
0
Fork 0
2023-fpga-computer/src/sap2/pc.v

26 lines
320 B
Coq
Raw Normal View History

2023-01-04 02:26:45 +00:00
module pc(
input clk,
input clr,
input inc,
2023-01-15 21:57:23 +00:00
input load,
2023-01-04 02:26:45 +00:00
input en,
2023-01-15 21:57:23 +00:00
output[15:0] bus
2023-01-04 02:26:45 +00:00
);
2023-01-15 21:57:23 +00:00
reg[15:0] pc = 0;
2023-01-04 02:26:45 +00:00
always @(posedge clk or posedge clr) begin
if (clr) begin
2023-01-15 21:57:23 +00:00
pc <= 16'b0;
end else if (load) begin
pc <= bus;
2023-01-04 02:26:45 +00:00
end else if (inc) begin
pc <= pc + 1;
end
end
2023-01-15 21:57:23 +00:00
assign bus = (en) ? pc : 16'bz;
2023-01-04 02:26:45 +00:00
endmodule