Add address range checks

This commit is contained in:
Alex Forencich
2021-11-10 23:48:47 -08:00
parent da24857dd2
commit 6329187ced
2 changed files with 12 additions and 0 deletions

View File

@@ -279,6 +279,9 @@ class AxiMasterWrite(Reset):
if not isinstance(event, Event): if not isinstance(event, Event):
raise ValueError("Expected event object") raise ValueError("Expected event object")
if address < 0 or address >= 2**self.address_width:
raise ValueError("Address out of range")
if awid is None or awid < 0: if awid is None or awid < 0:
awid = None awid = None
elif awid > self.id_count: elif awid > self.id_count:
@@ -665,6 +668,9 @@ class AxiMasterRead(Reset):
if not isinstance(event, Event): if not isinstance(event, Event):
raise ValueError("Expected event object") raise ValueError("Expected event object")
if address < 0 or address >= 2**self.address_width:
raise ValueError("Address out of range")
if length < 0: if length < 0:
raise ValueError("Read length must be positive") raise ValueError("Read length must be positive")

View File

@@ -147,6 +147,9 @@ class AxiLiteMasterWrite(Reset):
if not isinstance(event, Event): if not isinstance(event, Event):
raise ValueError("Expected event object") raise ValueError("Expected event object")
if address < 0 or address >= 2**self.address_width:
raise ValueError("Address out of range")
if not self.awprot_present and prot != AxiProt.NONSECURE: if not self.awprot_present and prot != AxiProt.NONSECURE:
raise ValueError("awprot sideband signal value specified, but signal is not connected") raise ValueError("awprot sideband signal value specified, but signal is not connected")
@@ -385,6 +388,9 @@ class AxiLiteMasterRead(Reset):
if not isinstance(event, Event): if not isinstance(event, Event):
raise ValueError("Expected event object") raise ValueError("Expected event object")
if address < 0 or address >= 2**self.address_width:
raise ValueError("Address out of range")
if not self.arprot_present and prot != AxiProt.NONSECURE: if not self.arprot_present and prot != AxiProt.NONSECURE:
raise ValueError("arprot sideband signal value specified, but signal is not connected") raise ValueError("arprot sideband signal value specified, but signal is not connected")