~ruther/verilog-riscv-semestral-project

ref: acf0f7243e7b45dc7db8e51c5c7ae659f7ef2bb3 verilog-riscv-semestral-project/src/program_counter.sv -rwxr-xr-x 383 bytes
acf0f724 — Rutherther feat: implement sb, sh, lb, lh support via masking 1 year, 7 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// + 4 normally
// or if should jump, jump to given address (either pc + imm or rs1 + imm)

module program_counter(
  input                    clk,
  input                    rst_n,
  input [WIDTH - 1:0]      pc_next,
  output reg [WIDTH - 1:0] pc
);
  parameter WIDTH = 12;

  always_ff @ (posedge clk)
    if (rst_n == 1'b0)
      pc <= 0;
    else
      pc <= pc_next;

endmodule
Do not follow this link