From 5c94ed2ccaeaa8ab92e494afda01f19ff5cd4c56 Mon Sep 17 00:00:00 2001 From: Alex Forencich Date: Sun, 29 Nov 2020 14:02:48 -0800 Subject: [PATCH] Improve parameter validation --- cocotbext/axi/axi_master.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/cocotbext/axi/axi_master.py b/cocotbext/axi/axi_master.py index 3803b87..d1f9f18 100644 --- a/cocotbext/axi/axi_master.py +++ b/cocotbext/axi/axi_master.py @@ -111,11 +111,15 @@ class AxiMasterWrite(object): raise Exception("Token is not unique") self.active_tokens.add(token) + burst = AxiBurstType(burst) + if size is None or size < 0: size = self.max_burst_size - else: - if size > self.max_burst_size: - raise ValueError("Requested burst size exceeds maximum burst size allowed for bus width") + elif size > self.max_burst_size: + raise ValueError("Requested burst size exceeds maximum burst size allowed for bus width") + + lock = AxiLockType(lock) + prot = AxiProt(prot) self.in_flight_operations += 1 @@ -409,11 +413,15 @@ class AxiMasterRead(object): raise Exception("Token is not unique") self.active_tokens.add(token) + burst = AxiBurstType(burst) + if size is None or size < 0: size = self.max_burst_size - else: - if size > self.max_burst_size: - raise ValueError("Requested burst size exceeds maximum burst size allowed for bus width") + elif size > self.max_burst_size: + raise ValueError("Requested burst size exceeds maximum burst size allowed for bus width") + + lock = AxiLockType(lock) + prot = AxiProt(prot) self.in_flight_operations += 1