2023-01-04 02:26:45 +00:00
|
|
|
module pc(
|
|
|
|
input clk,
|
2023-02-17 03:25:05 +00:00
|
|
|
input rst,
|
2023-01-04 02:26:45 +00:00
|
|
|
input inc,
|
2023-02-17 03:25:05 +00:00
|
|
|
output[7:0] out
|
2023-01-04 02:26:45 +00:00
|
|
|
);
|
|
|
|
|
2023-02-17 03:25:05 +00:00
|
|
|
reg[3:0] pc;
|
2023-01-04 02:26:45 +00:00
|
|
|
|
2023-02-17 03:25:05 +00:00
|
|
|
always @(posedge clk, posedge rst) begin
|
|
|
|
if (rst) begin
|
2023-01-04 02:26:45 +00:00
|
|
|
pc <= 4'b0;
|
|
|
|
end else if (inc) begin
|
|
|
|
pc <= pc + 1;
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2023-02-17 03:25:05 +00:00
|
|
|
assign out = pc;
|
2023-01-04 02:26:45 +00:00
|
|
|
|
|
|
|
endmodule
|
|
|
|
|