Use getattr with default value when accessing optional signals

This commit is contained in:
Alex Forencich
2021-11-09 00:46:37 -08:00
parent 558ba51c91
commit 43de2ea9b0
4 changed files with 26 additions and 22 deletions

View File

@@ -100,12 +100,12 @@ class AxiLiteRamWrite(Memory, Reset):
aw = await self.aw_channel.recv()
addr = (int(aw.awaddr) // self.byte_lanes) * self.byte_lanes
prot = AxiProt(aw.awprot)
prot = AxiProt(getattr(aw, 'awprot', AxiProt.NONSECURE))
w = await self.w_channel.recv()
data = int(w.wdata)
strb = int(w.wstrb)
strb = int(getattr(w, 'wstrb', self.strb_mask))
# todo latency
@@ -190,7 +190,7 @@ class AxiLiteRamRead(Memory, Reset):
ar = await self.ar_channel.recv()
addr = (int(ar.araddr) // self.byte_lanes) * self.byte_lanes
prot = AxiProt(ar.arprot)
prot = AxiProt(getattr(ar, 'arprot', AxiProt.NONSECURE))
# todo latency