RISC-V Program Counter
Build the 32-bit program-counter register used by the guided RISC-V CPU project.
Task
Complete rv32_pc so reset returns the PC to address 0 and every rising edge otherwise loads pc_next.
Examples
- reset=1 at a rising edge → pc=0
- reset=0, pc_next=0x00000004 → pc=0x00000004 after the edge
Constraints
- Use always_ff on the rising edge of clk.
- Reset is active high.
- Use non-blocking assignment for pc.
What this problem is testing
A strong answer translates the requirement into synthesizable state and combinational logic, states reset and update semantics precisely, and handles boundary conditions rather than only the nominal case.
Interview habit: before coding, state reset behavior, the state that must be stored, and the conditions that update each output.
Verification plan
- Check reset or initialization before normal operation.
- Exercise the nominal sequence cycle by cycle.
- Test boundaries such as zero, maximum count, wraparound, full/empty, or simultaneous controls when they apply.
- Prove the design holds state when an enable or qualifying condition is absent.
Common mistakes
- Incomplete combinational assignments that infer a latch.
- Blocking/non-blocking assignments that do not match combinational versus sequential intent.
- Parameter-width and boundary errors.
- Passing the happy path while missing reset, overflow, simultaneous operations, or illegal requests.
Interview follow-up questions
- How would you parameterize this design without introducing width or boundary bugs?
- What changes if reset timing or polarity changes?
Concepts to review
RISC-V, CPU, program-counter
Open RISC-V Program Counter in the HDLForge interactive editor.
Related problems
- 2:1 Multiplexer — Easy
- Parameterized Counter — Easy
- Priority Encoder — Medium
- Synchronous FIFO — Hard
- Shift Register — Easy
Explore the RTL Design Practice & Interview Preparation hub.