Replies: 1 comment
-
Hey there!
Great to hear! :)
Actually, there are two program counters:
neorv32/rtl/core/neorv32_cpu_control.vhd Line 400 in a004fb5
neorv32/rtl/core/neorv32_cpu_control.vhd Line 682 in a004fb5 The instruction fetch program counter ("PC") will keep increasing by 4 with each now instruction fetch. The fetched instruction data is stored into a FIFO (the "instruction prefetch buffer (IPB)"). As soon as there is a taken branch, a jump, an interrupts, ..., the actual program counter ("PC2") will get updated and copied to the instruction fetch PC will also clearing the instruction prefetch buffer: neorv32/rtl/core/neorv32_cpu_control.vhd Lines 416 to 420 in a004fb5 The application program counter ("PC2") is the one visible to the ISA / to the actual program being executed. It will increment by 4 (or by 2 when executing a compressed instruction) whenever the CPU's "execution engine" is in the neorv32/rtl/core/neorv32_cpu_control.vhd Lines 734 to 735 in a004fb5 Additionally, the PC from the previous instruction is backup-ed in case we encounter an exception (for example an illegal instruction word: neorv32/rtl/core/neorv32_cpu_control.vhd Lines 704 to 707 in a004fb5 In this case the RISC-V If we encounter an interrupt we need to store the address of the interrupted instruction (that has not been executed yet) to the neorv32/rtl/core/neorv32_cpu_control.vhd Lines 1571 to 1573 in a004fb5 As mentioned above, whenever we encounter a trap (exception or interrupt) we update the neorv32/rtl/core/neorv32_cpu_control.vhd Lines 1906 to 1912 in a004fb5 I know the VHDL code is quite complex here... 😅 So feel free to ask if you have further questions!
Sounds interesting! What kind of "faults" do you plan to inject (in what situations)? |
Beta Was this translation helpful? Give feedback.
-
Hi Stephan,
I have been experimenting and becoming familiar with the neorv32 core and really enjoying using it so far. I'm now ready to start using it for my PhD research project. I am trying to understand how the program counter works with this processor. I have been reading through the VHDL files under
neorv32/rtl/core
and can see the program counter (PC) seem to be driven from the moduleneorv32_cpu_control
. I know it is a complicated question, but can you explain how the PC works internally regarding how it is updated? I mean in terms of current, last and next instruction that are used in this module.I want to be able to inject faults into the program counter but not 100% sure how it operates yet.
Beta Was this translation helpful? Give feedback.
All reactions