1. May 16, 2024
    • Bill McSpadden's avatar
      Merge branch 'master' into master · 8ab3ca84
      Bill McSpadden authored
      8ab3ca84
    • Tim Hutt's avatar
      Add some missing explicit var declarations · be1e04c0
      Tim Hutt authored
      Implicit `var` declarations will eventually be an error. This makes some implicit `var` declarations explicit.
      be1e04c0
    • Tim Hutt's avatar
      Handle 34-bit PMP address overflow · a71fee30
      Tim Hutt authored
      The existing PMP code could not handle physical addresses above 32 bits on RV32, which are possible since Sv32 has 34-bit physical addresses, and the PMP registers are in units of 4 bytes, so they can encode 34-bit addresses.
      
      This fixes that by delaying the *4 until the comparison where it can be done using `nat` instead of `xlenbits` which it would overflow.
      a71fee30
  2. May 13, 2024
    • Alasdair's avatar
      Refactor MUL instruction · e1242d85
      Alasdair authored
      This instruction had a bit of a case of 'boolean blindness' code smell,
      where the mul operation was represented as a triple of booleans. This
      commit refactors the implemention to use a struct with named fields for
      high, signed_rs1, and signed_rs2.
      
      The C_MUL instruction in Zcb also needs to be changed appropriately
      
      The mul_op struct was added in riscv_types
      
      While there do some housekeeping w.r.t the comment about a workaround for
      Sail < 0.15.1, as this is no longer needed.
      e1242d85
  3. May 11, 2024
  4. May 10, 2024
  5. May 08, 2024
    • Tim Hutt's avatar
      Add missing decoder guards for crypto extensions · f65c4b2c
      Tim Hutt authored
      These guards were missing from one side of each clause.
      f65c4b2c
    • Martin Berger's avatar
      Add Svinval extension. · 5c55b5bb
      Martin Berger authored
      
      
      These changes add the "Svinval" Standard Extension for Fine-Grained
      Address-Translation Cache Invalidation, Version 1.0 to the sail-riscv
      model.
      
      This extension defines five new instructions: SINVAL.VMA,
      SFENCE.W.INVAL, SFENCE.INVAL.IR, HINVAL.VVMA, HINVAL.GVMA.
      
      HINVAL.VVMA & HINVAL.GVMA are omitted since they build on the
      Hypervisor Extension which is yet to be included in the model.
      
      SFENCE.W.INVAL & SFENCE.INVAL.IR are treated as nops pending
      integration of the coherency model (rmem) with sail.
      
      The specification says that SINVAL.VMA behaves just as SFENCE.VMA,
      except there are additional ordering constraints with respect to the
      new SFENCE.W.INVAL & SFENCE.INVAL.IR instructions. Since these are
      nops, we can treat SINVAL.VMA as if it were SFENCE.VMA.
      
      Co-authored-by: default avatarKristin Barber <kristinbarber@google.com>
      5c55b5bb
    • Martin Berger's avatar
      418cf128
    • Martin Berger's avatar
      fixup! fixup! Add Svinval extension. · 0f2f54cb
      Martin Berger authored
      0f2f54cb
    • Martin Berger's avatar
      fixup! Add Svinval extension. · 66095cac
      Martin Berger authored
      66095cac
    • Martin Berger's avatar
      Add Svinval extension. · 34e43b27
      Martin Berger authored
          These changes add the "Svinval" Standard Extension for Fine-Grained
          Address-Translation Cache Invalidation, Version 1.0 to the sail-riscv model.
      
          This extension defines five new instructions: SINVAL.VMA, SFENCE.W.INVAL,
          SFENCE.INVAL.IR, HINVAL.VVMA, HINVAL.GVMA.
      
          HINVAL.VVMA & HINVAL.GVMA are omitted since they build on the
          Hypervisor Extension which is yet to be included in the model.
      
          SFENCE.W.INVAL & SFENCE.INVAL.IR are treated as nops pending integration
          of the coherency model (rmem) with sail.
      
          The specification says that SINVAL.VMA behaves just as SFENCE.VMA,
          except there are additional ordering constraints with respect to the new
          SFENCE.W.INVAL & SFENCE.INVAL.IR instructions. Since these are nops, we
          can treat SINVAL.VMA as if it were SFENCE.VMA.
      34e43b27
  6. Apr 30, 2024
  7. Apr 27, 2024
  8. Apr 24, 2024
  9. Apr 17, 2024
  10. Apr 16, 2024
  11. Apr 15, 2024
  12. Apr 12, 2024
    • Tim Hutt's avatar
      Remove & rename duplicate word_width <-> bytes mappings · e187e022
      Tim Hutt authored
      * Remove the duplicate mapping functions.
      * Rename to `size_bytes` for consistency with the other two functions.
      * Rename `size_bits` to `size_enc`, otherwise it's quite confusing that `size_bits` is not just `8 * size_bytes`.
      
      Fixes #423
      e187e022
  13. Apr 09, 2024
    • Tim Hutt's avatar
      Clean up memory checking functions slightly · 5c7d1f2a
      Tim Hutt authored
      * Move `write_knd_of_flags` into its own function.
      * Wrap really long lines
      * Move PMP check into `phys_access_check` function. This is needed for two reasons:
        - The CBO extension needs to do explicit access checks.
        - In future it will also check PMAs so the name needs changing.
      5c7d1f2a
  14. Apr 03, 2024
    • Tim Hutt's avatar
      Fix flen=32 compilation · a2ffa851
      Tim Hutt authored
      This has been broken for at least 2 years. This fixes the compilation.
      
      Fixes #351
      a2ffa851
  15. Apr 01, 2024
    • Rishiyur S. Nikhil's avatar
      Unify VM code · f601c866
      Rishiyur S. Nikhil authored
      Old vmem code had much 'cut-and-paste' replication for RV32 (Sv32) and (#408)
      
      RV64 (Sv39, Sv48), and was scattered over several files.
      
      New code unifies them into single set of parameterized functions
      that works for RV32/RV64 and Sv32/Sv39/Sv48 (and is ready for Sv57).
      
      Deleted old files:
          riscv_vmem_rv32.sail    riscv_vmem_rv64.sail
          riscv_vmem_sv32.sail    riscv_vmem_sv39.sail    riscv_vmem_sv48.sail
          riscv_pte.sail
          riscv_ptw.sail
      
      Current files: all named riscv_vmem_*
          riscv_vmem.sail    (root file for vmem)
          riscv_vmem_common.sail
          riscv_vmem_pte.sail
          riscv_vmem_ptw.sail
          riscv_vmem_tlb.sail
          riscv_vmem_types.sail
      
      Modified top-level Makefile accordingly.
      
      Added documentation on new vmem code: doc/notes_Virtual_Memory.adoc
      f601c866
  16. Mar 25, 2024
  17. Feb 27, 2024
  18. Feb 09, 2024
    • Tim Hutt's avatar
      Add m/senvcfg to CSR name map · 9602e3a5
      Tim Hutt authored
      These were missed when those CSRs were implemented.
      9602e3a5
    • Tim Hutt's avatar
      Shorten copyright notice at the top of each file · 2eb3e3d2
      Tim Hutt authored
      This script was used to do the modification:
      
      ```
      from pathlib import Path
      import re
      
      RE_LINE = r"/\*={50,150}\*/\n"
      RE_MIDDLE = r"/\*.*\*/\n"
      
      NEW_TEXT = """/*=======================================================================================*/
      /*  This Sail RISC-V architecture model, comprising all files and                        */
      /*  directories except where otherwise noted is subject the BSD                          */
      /*  two-clause license in the LICENSE file.                                              */
      /*                                                                                       */
      /*  SPDX-License-Identifier: BSD-2-Clause                                                */
      /*=======================================================================================*/
      """
      
      REPLACEMENT = re.compile(rf"^{RE_LINE}(?:{RE_MIDDLE}){{10,100}}{RE_LINE}")
      
      def main():
          for file in Path("model").glob("**/*.sail"):
              text = file.read_text(encoding="utf-8")
              text = REPLACEMENT.sub(NEW_TEXT, text, 1)
              file.write_text(text, encoding="utf-8")
      
      if __name__ == "__main__":
          main()
      ```
      2eb3e3d2
  19. Feb 06, 2024
    • Tim Hutt's avatar
      Improve PMP support · 4de2bff1
      Tim Hutt authored
      
      
      This implements a lot of missing functionality for PMPs.
      
      * Support 64 PMPs as well as 0 and 16.
      * Support setting PMP grain
      * Return correct address bits on read (some read as 0 or 1 depending on the grain and match type)
      * Unlock PMPs on reset
      * Implement pmpcfg WARL legalisation
      
      Co-authored-by: default avatarBen Fletcher <benjamin.fletcher@codasip.com>
      4de2bff1