From 6329187cedb573caa5f76633541dbf90e4830c5b Mon Sep 17 00:00:00 2001 From: Alex Forencich Date: Wed, 10 Nov 2021 23:48:47 -0800 Subject: [PATCH] Add address range checks --- cocotbext/axi/axi_master.py | 6 ++++++ cocotbext/axi/axil_master.py | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/cocotbext/axi/axi_master.py b/cocotbext/axi/axi_master.py index a6394d8..c298035 100644 --- a/cocotbext/axi/axi_master.py +++ b/cocotbext/axi/axi_master.py @@ -279,6 +279,9 @@ class AxiMasterWrite(Reset): if not isinstance(event, Event): 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: awid = None elif awid > self.id_count: @@ -665,6 +668,9 @@ class AxiMasterRead(Reset): if not isinstance(event, Event): raise ValueError("Expected event object") + if address < 0 or address >= 2**self.address_width: + raise ValueError("Address out of range") + if length < 0: raise ValueError("Read length must be positive") diff --git a/cocotbext/axi/axil_master.py b/cocotbext/axi/axil_master.py index b8082ff..b001963 100644 --- a/cocotbext/axi/axil_master.py +++ b/cocotbext/axi/axil_master.py @@ -147,6 +147,9 @@ class AxiLiteMasterWrite(Reset): if not isinstance(event, Event): 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: raise ValueError("awprot sideband signal value specified, but signal is not connected") @@ -385,6 +388,9 @@ class AxiLiteMasterRead(Reset): if not isinstance(event, Event): 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: raise ValueError("arprot sideband signal value specified, but signal is not connected")