-
Notifications
You must be signed in to change notification settings - Fork 202
/
Copy pathprelude_mem_addrtype.sail
27 lines (19 loc) · 1.34 KB
/
prelude_mem_addrtype.sail
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/*=======================================================================================*/
/* 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 */
/*=======================================================================================*/
/* Note: virtaddr includes physical addresses when address translation is disabled.
* It is used where the address would be virtual if address translation is active.
*/
type physaddrbits = bits(physaddrbits_len)
let physaddrbits_len = sizeof(physaddrbits_len)
newtype physaddr = Physaddr : physaddrbits
newtype virtaddr = Virtaddr : xlenbits
function bits_of_physaddr(Physaddr(paddr) : physaddr) -> physaddrbits = paddr
function bits_of_virtaddr(Virtaddr(vaddr) : virtaddr) -> xlenbits = vaddr
function sub_virtaddr_xlenbits(Virtaddr(addr) : virtaddr, offset : xlenbits) -> virtaddr = Virtaddr(addr - offset)
overload operator - = { sub_virtaddr_xlenbits }
overload bits_of = { bits_of_physaddr, bits_of_virtaddr }