[Libre-soc-dev] daily kan-ban update 25nov2020

Luke Kenneth Casson Leighton lkcl at lkcl.net
Wed Nov 25 22:11:45 GMT 2020


---
crowd-funded eco-conscious hardware: https://www.crowdsupply.com/eoma68

On Wed, Nov 25, 2020 at 8:03 PM Tobias Platen
<libre-soc at platen-software.de> wrote:
>
> today: looking into microwatt's loadstore1.vhdl
> and trying to understand how exceptions are reported

dar and disr get updated, stored in internal registers local to loadstore1.vhdl
https://github.com/antonblanchard/microwatt/blob/e40e752b9ab602f5ce1eb79be1fe96932558830d/loadstore1.vhdl#L747

e_out.exception is simply a flag that's output, which is picked up by
the *caller* of loadstore1.vhdl, which in this case is execute1.vhdl.

therefore, back in execute1.vhdl:
https://github.com/antonblanchard/microwatt/blob/e40e752b9ab602f5ce1eb79be1fe96932558830d/execute1.vhdl#L1234

the fact that e_out.exception == l_in.exception is noticed (as opposed
to, "an actual load or store took place") and, rather than let the PC
continue on to the next instruction (at PC+4), a "trap" is generated
that redirects the PC to a totally different address.  0x600 (line
1236), 0x300 (line 1239), etc. etc. etc. etc. etc.

execution of instructions therefore continues from that trap address,
*not* from "PC+4".   that is all that an exception is: a recording of
some state (SRR0, SRR1) containing copies of PC and MSR respectively
at the time of the exception, and the redirection of the PC to a
suitable "handler".

finally, back in loadstore1.vhdl:
https://github.com/antonblanchard/microwatt/blob/e40e752b9ab602f5ce1eb79be1fe96932558830d/loadstore1.vhdl#L641

a MFMSR command, which, obviously, is executed as one of the
instructions by the loadstore trap handler, reads dsisr or dar.

it's pretty simple.

l.



More information about the Libre-soc-dev mailing list