From 873bb1a03435113662e1313f60ef599707eb9137 Mon Sep 17 00:00:00 2001 From: Alex Forencich Date: Fri, 7 Jan 2022 12:52:41 -0800 Subject: [PATCH] Explicit cast to integer before converting to enum or flag type --- cocotbext/axi/axi_master.py | 4 ++-- cocotbext/axi/axi_slave.py | 8 ++++---- cocotbext/axi/axil_master.py | 4 ++-- cocotbext/axi/axil_slave.py | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/cocotbext/axi/axi_master.py b/cocotbext/axi/axi_master.py index 3f08ce4..d08e741 100644 --- a/cocotbext/axi/axi_master.py +++ b/cocotbext/axi/axi_master.py @@ -591,7 +591,7 @@ class AxiMasterWrite(Region, Reset): for burst_length in cmd.burst_list: b = await context.get_resp() - burst_resp = AxiResp(getattr(b, 'bresp', AxiResp.OKAY)) + burst_resp = AxiResp(int(getattr(b, 'bresp', AxiResp.OKAY))) burst_user = int(getattr(b, 'buser', 0)) if burst_resp != AxiResp.OKAY: @@ -973,7 +973,7 @@ class AxiMasterRead(Region, Reset): for r in burst: cycle_data = int(r.rdata) - cycle_resp = AxiResp(getattr(r, "rresp", AxiResp.OKAY)) + cycle_resp = AxiResp(int(getattr(r, "rresp", AxiResp.OKAY))) cycle_user = int(getattr(r, "ruser", 0)) if cycle_resp != AxiResp.OKAY: diff --git a/cocotbext/axi/axi_slave.py b/cocotbext/axi/axi_slave.py index 30b1b89..3b8105c 100644 --- a/cocotbext/axi/axi_slave.py +++ b/cocotbext/axi/axi_slave.py @@ -115,8 +115,8 @@ class AxiSlaveWrite(Reset): addr = int(aw.awaddr) length = int(getattr(aw, 'awlen', 0)) size = int(getattr(aw, 'awsize', self.max_burst_size)) - burst = AxiBurstType(getattr(aw, 'awburst', AxiBurstType.INCR)) - prot = AxiProt(getattr(aw, 'awprot', AxiProt.NONSECURE)) + burst = AxiBurstType(int(getattr(aw, 'awburst', AxiBurstType.INCR))) + prot = AxiProt(int(getattr(aw, 'awprot', AxiProt.NONSECURE))) self.log.info("Write burst awid: 0x%x awaddr: 0x%08x awlen: %d awsize: %d awprot: %s", awid, addr, length, size, prot) @@ -275,8 +275,8 @@ class AxiSlaveRead(Reset): addr = int(ar.araddr) length = int(getattr(ar, 'arlen', 0)) size = int(getattr(ar, 'arsize', self.max_burst_size)) - burst = AxiBurstType(getattr(ar, 'arburst', AxiBurstType.INCR)) - prot = AxiProt(getattr(ar, 'arprot', AxiProt.NONSECURE)) + burst = AxiBurstType(int(getattr(ar, 'arburst', AxiBurstType.INCR))) + prot = AxiProt(int(getattr(ar, 'arprot', AxiProt.NONSECURE))) self.log.info("Read burst arid: 0x%x araddr: 0x%08x arlen: %d arsize: %d arprot: %s", arid, addr, length, size, prot) diff --git a/cocotbext/axi/axil_master.py b/cocotbext/axi/axil_master.py index 3721fa3..2c02b88 100644 --- a/cocotbext/axi/axil_master.py +++ b/cocotbext/axi/axil_master.py @@ -311,7 +311,7 @@ class AxiLiteMasterWrite(Region, Reset): for k in range(cmd.cycles): b = await self.b_channel.recv() - cycle_resp = AxiResp(getattr(b, 'bresp', AxiResp.OKAY)) + cycle_resp = AxiResp(int(getattr(b, 'bresp', AxiResp.OKAY))) if cycle_resp != AxiResp.OKAY: resp = cycle_resp @@ -517,7 +517,7 @@ class AxiLiteMasterRead(Region, Reset): r = await self.r_channel.recv() cycle_data = int(r.rdata) - cycle_resp = AxiResp(getattr(r, 'rresp', AxiResp.OKAY)) + cycle_resp = AxiResp(int(getattr(r, 'rresp', AxiResp.OKAY))) if cycle_resp != AxiResp.OKAY: resp = cycle_resp diff --git a/cocotbext/axi/axil_slave.py b/cocotbext/axi/axil_slave.py index bc347d0..4ad0a23 100644 --- a/cocotbext/axi/axil_slave.py +++ b/cocotbext/axi/axil_slave.py @@ -106,7 +106,7 @@ class AxiLiteSlaveWrite(Reset): aw = await self.aw_channel.recv() addr = (int(aw.awaddr) // self.byte_lanes) * self.byte_lanes - prot = AxiProt(getattr(aw, 'awprot', AxiProt.NONSECURE)) + prot = AxiProt(int(getattr(aw, 'awprot', AxiProt.NONSECURE))) w = await self.w_channel.recv() @@ -221,7 +221,7 @@ class AxiLiteSlaveRead(Reset): ar = await self.ar_channel.recv() addr = (int(ar.araddr) // self.byte_lanes) * self.byte_lanes - prot = AxiProt(getattr(ar, 'arprot', AxiProt.NONSECURE)) + prot = AxiProt(int(getattr(ar, 'arprot', AxiProt.NONSECURE))) r = self.r_channel._transaction_obj() r.rresp = AxiResp.OKAY