Skip to content

Make number of physical address bits configurable #1367

@Timmmm

Description

@Timmmm

Currently all bits are always implemented (64 bits on RV64, 34 bits on RV32... although I'm not 100% sure that all 34 bits actually work).

We should add a config setting for physical address bits, where higher bits are effectively read-only zero. The config validation function should check it isn't more than 34 on RV32.

This affects:

  • PPN bits in satp.
  • pmpaddrN

Actually I think that's it, so it should be very easy. Something like:

let pa_bits = config ...

...

function pmpWriteAddr(locked: bool, tor_locked: bool, reg: xlenbits, v: xlenbits) -> xlenbits =
  if (locked | tor_locked) then reg
  else {
    // Address bits higher then PA_BITS-1 are read-only zero, but
    // pmpaddr does not contain the lowest 2 bits of the addresses
    // so we actually use PA_BITS-3.
    assert(pa_bits <= xlen + 2);
    zero_extend(v[pa_bits - 3 .. 0])
  }

...

function legalize_satp(
...

  let s = [
    s with
    // If full 16-bit ASID is not supported then the high bits will be read only zero.
    Asid = zero_extend(s[Asid][asid_bits - 1 .. 0]),
    // Bits above the physically addressable memory are read only zero.
    PPN = zero_extend(s[PPN][pa_bits - pagesize_bits - 1 .. 0]),
  ];

(We need asid_bits configuration too!)

Metadata

Metadata

Assignees

No one assigned

    Labels

    configurationAdditional configuration settings needed for the model

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions