What is meant by the FENCE instruction in the RISC-V instruction set?

前端 未结 2 1253
孤街浪徒
孤街浪徒 2021-02-02 16:56

While going through the RISC-V ISA, I have seen an instruction in the memory model section (FENCE instruction). What does it mean exactly?

2条回答
  •  暖寄归人
    2021-02-02 18:02

    I've found one case when using FENCE instruction is just necessary. Example:

    1. Some module in a SoC generates interrupt by writting value into CSR 0x783 (MIPI) via HostIO bus.
    2. Firmware jumps to the interrupt handler.
    3. Handler tries to reset 'pending' bit in a user implemented device by writting 1 into register.
    4. Such operation was compiled as a 'store' instruction with immediate value =1.
    5. As result, if I don't implement FENCE at the beginning of the handler I have some garbage value instead of proper immediate argument of the instruction.

提交回复
热议问题