Skip to content

The definition of the function is_aligned_addr overlaps with the function is_aligned #609

Open
@KotorinMinami

Description

@KotorinMinami

In riscv_insts_base.sail:311-317 , we have:

function is_aligned(vaddr : xlenbits, width : word_width) -> bool =
  match width {
    BYTE   => true,
    HALF   => vaddr[0..0] == zeros(),
    WORD   => vaddr[1..0] == zeros(),
    DOUBLE => vaddr[2..0] == zeros(),
  }

but in riscv_mem.sail:42-43 , we have:

function is_aligned_addr forall 'n. (addr : xlenbits, width : int('n)) -> bool =
  unsigned(addr) % width == 0

Obviously the latter can implement the former, and there is code implementation redundancy between the two, of course we can implement is_aligned using is_aligned(vaddr, width) = is_aligned(vaddr, size_bytes(width)) to avoid somehow different definitions or duplicated definitions

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions