1 from nmigen
import Signal
2 from nmigen
.cli
import main
4 class PermissionValidator():
5 """ The purpose of this Module is to check the Permissions of a given PTE
6 against the requested access permissions.
8 This module will either validate (by setting the valid bit HIGH)
9 the request or find a permission fault and invalidate (by setting
10 the valid bit LOW) the request
13 def __init__(self
, data_size
):
15 * data_size: (bit count) The size of the data words being processed
18 1. Data is valid -> valid is HIGH
19 2. Data is not valid -> valid is LOW
22 self
.data
= Signal(data_size
);
23 self
.xwr
= Signal(3) # Execute, Write, Read
24 self
.super = Signal(1) # Supervisor Mode
25 self
.super_access
= Signal(1) # Supervisor Access
26 self
.asid
= Signal(15) # Address Space IDentifier (ASID)
29 self
.valid
= Signal(1) # Denotes if the permissions are correct
31 def elaborate(self
, platform
):
34 # Check if ASID matches OR entry is global
35 If(data
[64:78] == self
.asid
or data
[5] == 1,
36 # Check Execute, Write, Read (XWR) Permissions
37 If(data
[3] == self
.xwr
[2] and data
[2] == self
.xwr
[1] \
38 and data
[1] == self
.xwr
[0],
41 # Check if entry is in user mode
42 # Check if supervisor has access
45 ).Elif(self
.super_access
== 1,
51 # Check if entry is in user mode