From: Daniel Benusovich Date: Tue, 12 Mar 2019 02:53:12 +0000 (-0700) Subject: Update PermissionValidator to actually function. Needs tests X-Git-Tag: div_pipeline~2310 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=a52932bd2f1128543e572c168cb8c3cab6604051;p=soc.git Update PermissionValidator to actually function. Needs tests --- diff --git a/TLB/src/PermissionValidator.py b/TLB/src/PermissionValidator.py index dc7ae88f..6e8bee89 100644 --- a/TLB/src/PermissionValidator.py +++ b/TLB/src/PermissionValidator.py @@ -15,8 +15,7 @@ class PermissionValidator(): * data_size: (bit count) The size of the data words being processed Return: - 1. Data is valid -> valid is HIGH - 2. Data is not valid -> valid is LOW + * valid HIGH when permissions are correct """ # Input self.data = Signal(data_size); @@ -30,35 +29,23 @@ class PermissionValidator(): def elaborate(self, platform): m = Module() - m.d.comb += [ - # Check if ASID matches OR entry is global - If(data[64:78] == self.asid or data[5] == 1, - # Check Execute, Write, Read (XWR) Permissions - If(data[3] == self.xwr[2] and data[2] == self.xwr[1] \ - and data[1] == self.xwr[0], - # Check if supervisor - If(self.super == 1, - # Check if entry is in user mode - # Check if supervisor has access - If(data[4] == 0, - self.valid.eq(1) - ).Elif(self.super_access == 1, - self.valid.eq(1) - ).Else( - self.valid.eq(0) - ) - ).Else( - # Check if entry is in user mode - If(data[4] == 1, - self.valid.eq(1) - ).Else( - self.valid.eq(0) - ) - ) - ).Else( - self.valid.eq(0) - ) - ).Else( - self.valid.eq(0) - ) - ] + # ASID match or Global Permission + with m.If(data[64:78] == self.asid | data[5]): + # Check Execute, Write, Read (XWR) Permissions + with m.If(data[3] == self.xwr[2] \ + & data[2] == self.xwr[1] \ + & data[1] == self.xwr[0]): + # Supervisor Logic + with m.If(self.super): + # Valid if entry is not in user mode or supervisor + # has Supervisor User Memory (SUM) access via the + # SUM bit in the sstatus register + m.comb += self.valid.eq(~data[4] | self.super_access) + # User logic + with m.Else(): + # Valid if the entry is in user mode only + m.comb += self.valid.eq(data[4]) + with m.Else(): + m.comb += self.valid.eq(0) + with m.Else(): + m.comb += self.valid.eq(0) \ No newline at end of file