Add byteorder to word wrappers
This commit is contained in:
@@ -186,37 +186,42 @@ class AxiMasterWrite(object):
|
||||
await self.wait(token)
|
||||
return self.get_write_resp(token)
|
||||
|
||||
async def write_words(self, address, data, ws=2, awid=None, burst=AxiBurstType.INCR, size=None,
|
||||
async def write_words(self, address, data, byteorder='little', ws=2, awid=None, burst=AxiBurstType.INCR, size=None,
|
||||
lock=AxiLockType.NORMAL, cache=0b0011, prot=AxiProt.NONSECURE, qos=0, region=0, user=0, wuser=0):
|
||||
words = data
|
||||
data = bytearray()
|
||||
for w in words:
|
||||
data.extend(w.to_bytes(ws, 'little'))
|
||||
data.extend(w.to_bytes(ws, byteorder))
|
||||
await self.write(address, data, awid, burst, size, lock, cache, prot, qos, region, user, wuser)
|
||||
|
||||
async def write_dwords(self, address, data, awid=None, burst=AxiBurstType.INCR, size=None,
|
||||
async def write_dwords(self, address, data, byteorder='little', awid=None, burst=AxiBurstType.INCR, size=None,
|
||||
lock=AxiLockType.NORMAL, cache=0b0011, prot=AxiProt.NONSECURE, qos=0, region=0, user=0, wuser=0):
|
||||
await self.write_words(address, data, 4, awid, burst, size, lock, cache, prot, qos, region, user, wuser)
|
||||
await self.write_words(address, data, byteorder, 4, awid, burst, size,
|
||||
lock, cache, prot, qos, region, user, wuser)
|
||||
|
||||
async def write_qwords(self, address, data, awid=None, burst=AxiBurstType.INCR, size=None,
|
||||
async def write_qwords(self, address, data, byteorder='little', awid=None, burst=AxiBurstType.INCR, size=None,
|
||||
lock=AxiLockType.NORMAL, cache=0b0011, prot=AxiProt.NONSECURE, qos=0, region=0, user=0, wuser=0):
|
||||
await self.write_words(address, data, 8, awid, burst, size, lock, cache, prot, qos, region, user, wuser)
|
||||
await self.write_words(address, data, byteorder, 8, awid, burst, size,
|
||||
lock, cache, prot, qos, region, user, wuser)
|
||||
|
||||
async def write_byte(self, address, data, awid=None, burst=AxiBurstType.INCR, size=None,
|
||||
lock=AxiLockType.NORMAL, cache=0b0011, prot=AxiProt.NONSECURE, qos=0, region=0, user=0, wuser=0):
|
||||
await self.write(address, [data], awid, burst, size, lock, cache, prot, qos, region, user, wuser)
|
||||
|
||||
async def write_word(self, address, data, ws=2, awid=None, burst=AxiBurstType.INCR, size=None,
|
||||
async def write_word(self, address, data, byteorder='little', ws=2, awid=None, burst=AxiBurstType.INCR, size=None,
|
||||
lock=AxiLockType.NORMAL, cache=0b0011, prot=AxiProt.NONSECURE, qos=0, region=0, user=0, wuser=0):
|
||||
await self.write_words(address, [data], ws, awid, burst, size, lock, cache, prot, qos, region, user, wuser)
|
||||
await self.write_words(address, [data], byteorder, ws, awid, burst, size,
|
||||
lock, cache, prot, qos, region, user, wuser)
|
||||
|
||||
async def write_dword(self, address, data, awid=None, burst=AxiBurstType.INCR, size=None,
|
||||
async def write_dword(self, address, data, byteorder='little', awid=None, burst=AxiBurstType.INCR, size=None,
|
||||
lock=AxiLockType.NORMAL, cache=0b0011, prot=AxiProt.NONSECURE, qos=0, region=0, user=0, wuser=0):
|
||||
await self.write_dwords(address, [data], awid, burst, size, lock, cache, prot, qos, region, user, wuser)
|
||||
await self.write_dwords(address, [data], byteorder, awid, burst, size,
|
||||
lock, cache, prot, qos, region, user, wuser)
|
||||
|
||||
async def write_qword(self, address, data, awid=None, burst=AxiBurstType.INCR, size=None,
|
||||
async def write_qword(self, address, data, byteorder='little', awid=None, burst=AxiBurstType.INCR, size=None,
|
||||
lock=AxiLockType.NORMAL, cache=0b0011, prot=AxiProt.NONSECURE, qos=0, region=0, user=0, wuser=0):
|
||||
await self.write_qwords(address, [data], awid, burst, size, lock, cache, prot, qos, region, user, wuser)
|
||||
await self.write_qwords(address, [data], byteorder, awid, burst, size,
|
||||
lock, cache, prot, qos, region, user, wuser)
|
||||
|
||||
async def _process_write(self):
|
||||
while True:
|
||||
@@ -511,37 +516,42 @@ class AxiMasterRead(object):
|
||||
await self.wait(token)
|
||||
return self.get_read_data(token)
|
||||
|
||||
async def read_words(self, address, count, ws=2, arid=None, burst=AxiBurstType.INCR, size=None,
|
||||
async def read_words(self, address, count, byteorder='little', ws=2, arid=None, burst=AxiBurstType.INCR, size=None,
|
||||
lock=AxiLockType.NORMAL, cache=0b0011, prot=AxiProt.NONSECURE, qos=0, region=0, user=0):
|
||||
data = await self.read(address, count*ws, burst, size, lock, cache, prot, qos, region, user)
|
||||
data = await self.read(address, count*ws, arid, burst, size, lock, cache, prot, qos, region, user)
|
||||
words = []
|
||||
for k in range(count):
|
||||
words.append(int.from_bytes(data.data[ws*k:ws*(k+1)], 'little'))
|
||||
words.append(int.from_bytes(data.data[ws*k:ws*(k+1)], byteorder))
|
||||
return words
|
||||
|
||||
async def read_dwords(self, address, count, arid=None, burst=AxiBurstType.INCR, size=None,
|
||||
async def read_dwords(self, address, count, byteorder='little', arid=None, burst=AxiBurstType.INCR, size=None,
|
||||
lock=AxiLockType.NORMAL, cache=0b0011, prot=AxiProt.NONSECURE, qos=0, region=0, user=0):
|
||||
return await self.read_words(address, count, 4, arid, burst, size, lock, cache, prot, qos, region, user)
|
||||
return await self.read_words(address, count, byteorder, 4, arid, burst, size,
|
||||
lock, cache, prot, qos, region, user)
|
||||
|
||||
async def read_qwords(self, address, count, arid=None, burst=AxiBurstType.INCR, size=None,
|
||||
async def read_qwords(self, address, count, byteorder='little', arid=None, burst=AxiBurstType.INCR, size=None,
|
||||
lock=AxiLockType.NORMAL, cache=0b0011, prot=AxiProt.NONSECURE, qos=0, region=0, user=0):
|
||||
return await self.read_words(address, count, 8, arid, burst, size, lock, cache, prot, qos, region, user)
|
||||
return await self.read_words(address, count, byteorder, 8, arid, burst, size,
|
||||
lock, cache, prot, qos, region, user)
|
||||
|
||||
async def read_byte(self, address, arid=None, burst=AxiBurstType.INCR, size=None,
|
||||
lock=AxiLockType.NORMAL, cache=0b0011, prot=AxiProt.NONSECURE, qos=0, region=0, user=0):
|
||||
return (await self.read(address, 1, arid, burst, size, lock, cache, prot, qos, region, user)).data[0]
|
||||
|
||||
async def read_word(self, address, ws=2, arid=None, burst=AxiBurstType.INCR, size=None,
|
||||
async def read_word(self, address, byteorder='little', ws=2, arid=None, burst=AxiBurstType.INCR, size=None,
|
||||
lock=AxiLockType.NORMAL, cache=0b0011, prot=AxiProt.NONSECURE, qos=0, region=0, user=0):
|
||||
return (await self.read_words(address, 1, ws, arid, burst, size, lock, cache, prot, qos, region, user))[0]
|
||||
return (await self.read_words(address, 1, byteorder, ws, arid, burst, size,
|
||||
lock, cache, prot, qos, region, user))[0]
|
||||
|
||||
async def read_dword(self, address, arid=None, burst=AxiBurstType.INCR, size=None,
|
||||
async def read_dword(self, address, byteorder='little', arid=None, burst=AxiBurstType.INCR, size=None,
|
||||
lock=AxiLockType.NORMAL, cache=0b0011, prot=AxiProt.NONSECURE, qos=0, region=0, user=0):
|
||||
return (await self.read_dwords(address, 1, arid, burst, size, lock, cache, prot, qos, region, user))[0]
|
||||
return (await self.read_dwords(address, 1, byteorder, arid, burst, size,
|
||||
lock, cache, prot, qos, region, user))[0]
|
||||
|
||||
async def read_qword(self, address, arid=None, burst=AxiBurstType.INCR, size=None,
|
||||
async def read_qword(self, address, byteorder='little', arid=None, burst=AxiBurstType.INCR, size=None,
|
||||
lock=AxiLockType.NORMAL, cache=0b0011, prot=AxiProt.NONSECURE, qos=0, region=0, user=0):
|
||||
return (await self.read_qwords(address, 1, arid, burst, size, lock, cache, prot, qos, region, user))[0]
|
||||
return (await self.read_qwords(address, 1, byteorder, arid, burst, size,
|
||||
lock, cache, prot, qos, region, user))[0]
|
||||
|
||||
async def _process_read(self):
|
||||
while True:
|
||||
@@ -749,19 +759,19 @@ class AxiMaster(object):
|
||||
return await self.read_if.read(address, length, arid,
|
||||
burst, size, lock, cache, prot, qos, region, user)
|
||||
|
||||
async def read_words(self, address, count, ws=2, arid=None, burst=AxiBurstType.INCR, size=None,
|
||||
async def read_words(self, address, count, byteorder='little', ws=2, arid=None, burst=AxiBurstType.INCR, size=None,
|
||||
lock=AxiLockType.NORMAL, cache=0b0011, prot=AxiProt.NONSECURE, qos=0, region=0, user=0):
|
||||
return await self.read_if.read_words(address, count, ws, arid,
|
||||
return await self.read_if.read_words(address, count, byteorder, ws, arid,
|
||||
burst, size, lock, cache, prot, qos, region, user)
|
||||
|
||||
async def read_dwords(self, address, count, arid=None, burst=AxiBurstType.INCR, size=None,
|
||||
async def read_dwords(self, address, count, byteorder='little', arid=None, burst=AxiBurstType.INCR, size=None,
|
||||
lock=AxiLockType.NORMAL, cache=0b0011, prot=AxiProt.NONSECURE, qos=0, region=0, user=0):
|
||||
return await self.read_if.read_dwords(address, count, arid,
|
||||
return await self.read_if.read_dwords(address, count, byteorder, arid,
|
||||
burst, size, lock, cache, prot, qos, region, user)
|
||||
|
||||
async def read_qwords(self, address, count, arid=None, burst=AxiBurstType.INCR, size=None,
|
||||
async def read_qwords(self, address, count, byteorder='little', arid=None, burst=AxiBurstType.INCR, size=None,
|
||||
lock=AxiLockType.NORMAL, cache=0b0011, prot=AxiProt.NONSECURE, qos=0, region=0, user=0):
|
||||
return await self.read_if.read_qwords(address, count, arid,
|
||||
return await self.read_if.read_qwords(address, count, byteorder, arid,
|
||||
burst, size, lock, cache, prot, qos, region, user)
|
||||
|
||||
async def read_byte(self, address, arid=None, burst=AxiBurstType.INCR, size=None,
|
||||
@@ -769,19 +779,19 @@ class AxiMaster(object):
|
||||
return await self.read_if.read_byte(address, arid,
|
||||
burst, size, lock, cache, prot, qos, region, user)
|
||||
|
||||
async def read_word(self, address, ws=2, arid=None, burst=AxiBurstType.INCR, size=None,
|
||||
async def read_word(self, address, byteorder='little', ws=2, arid=None, burst=AxiBurstType.INCR, size=None,
|
||||
lock=AxiLockType.NORMAL, cache=0b0011, prot=AxiProt.NONSECURE, qos=0, region=0, user=0):
|
||||
return await self.read_if.read_word(address, ws, arid,
|
||||
return await self.read_if.read_word(address, byteorder, ws, arid,
|
||||
burst, size, lock, cache, prot, qos, region, user)
|
||||
|
||||
async def read_dword(self, address, arid=None, burst=AxiBurstType.INCR, size=None,
|
||||
async def read_dword(self, address, byteorder='little', arid=None, burst=AxiBurstType.INCR, size=None,
|
||||
lock=AxiLockType.NORMAL, cache=0b0011, prot=AxiProt.NONSECURE, qos=0, region=0, user=0):
|
||||
return await self.read_if.read_dword(address, arid,
|
||||
return await self.read_if.read_dword(address, byteorder, arid,
|
||||
burst, size, lock, cache, prot, qos, region, user)
|
||||
|
||||
async def read_qword(self, address, arid=None, burst=AxiBurstType.INCR, size=None,
|
||||
async def read_qword(self, address, byteorder='little', arid=None, burst=AxiBurstType.INCR, size=None,
|
||||
lock=AxiLockType.NORMAL, cache=0b0011, prot=AxiProt.NONSECURE, qos=0, region=0, user=0):
|
||||
return await self.read_if.read_qword(address, arid,
|
||||
return await self.read_if.read_qword(address, byteorder, arid,
|
||||
burst, size, lock, cache, prot, qos, region, user)
|
||||
|
||||
async def write(self, address, data, awid=None, burst=AxiBurstType.INCR, size=None,
|
||||
@@ -789,19 +799,19 @@ class AxiMaster(object):
|
||||
return await self.write_if.write(address, data, awid,
|
||||
burst, size, lock, cache, prot, qos, region, user, wuser)
|
||||
|
||||
async def write_words(self, address, data, ws=2, awid=None, burst=AxiBurstType.INCR, size=None,
|
||||
async def write_words(self, address, data, byteorder='little', ws=2, awid=None, burst=AxiBurstType.INCR, size=None,
|
||||
lock=AxiLockType.NORMAL, cache=0b0011, prot=AxiProt.NONSECURE, qos=0, region=0, user=0, wuser=0):
|
||||
return await self.write_if.write_words(address, data, ws, awid,
|
||||
return await self.write_if.write_words(address, data, byteorder, ws, awid,
|
||||
burst, size, lock, cache, prot, qos, region, user, wuser)
|
||||
|
||||
async def write_dwords(self, address, data, awid=None, burst=AxiBurstType.INCR, size=None,
|
||||
async def write_dwords(self, address, data, byteorder='little', awid=None, burst=AxiBurstType.INCR, size=None,
|
||||
lock=AxiLockType.NORMAL, cache=0b0011, prot=AxiProt.NONSECURE, qos=0, region=0, user=0, wuser=0):
|
||||
return await self.write_if.write_dwords(address, data, awid,
|
||||
return await self.write_if.write_dwords(address, data, byteorder, awid,
|
||||
burst, size, lock, cache, prot, qos, region, user, wuser)
|
||||
|
||||
async def write_qwords(self, address, data, awid=None, burst=AxiBurstType.INCR, size=None,
|
||||
async def write_qwords(self, address, data, byteorder='little', awid=None, burst=AxiBurstType.INCR, size=None,
|
||||
lock=AxiLockType.NORMAL, cache=0b0011, prot=AxiProt.NONSECURE, qos=0, region=0, user=0, wuser=0):
|
||||
return await self.write_if.write_qwords(address, data, awid,
|
||||
return await self.write_if.write_qwords(address, data, byteorder, awid,
|
||||
burst, size, lock, cache, prot, qos, region, user, wuser)
|
||||
|
||||
async def write_byte(self, address, data, awid=None, burst=AxiBurstType.INCR, size=None,
|
||||
@@ -809,17 +819,17 @@ class AxiMaster(object):
|
||||
return await self.write_if.write_byte(address, data, awid,
|
||||
burst, size, lock, cache, prot, qos, region, user, wuser)
|
||||
|
||||
async def write_word(self, address, data, ws=2, awid=None, burst=AxiBurstType.INCR, size=None,
|
||||
async def write_word(self, address, data, byteorder='little', ws=2, awid=None, burst=AxiBurstType.INCR, size=None,
|
||||
lock=AxiLockType.NORMAL, cache=0b0011, prot=AxiProt.NONSECURE, qos=0, region=0, user=0, wuser=0):
|
||||
return await self.write_if.write_word(address, data, ws, awid,
|
||||
return await self.write_if.write_word(address, data, byteorder, ws, awid,
|
||||
burst, size, lock, cache, prot, qos, region, user, wuser)
|
||||
|
||||
async def write_dword(self, address, data, awid=None, burst=AxiBurstType.INCR, size=None,
|
||||
async def write_dword(self, address, data, byteorder='little', awid=None, burst=AxiBurstType.INCR, size=None,
|
||||
lock=AxiLockType.NORMAL, cache=0b0011, prot=AxiProt.NONSECURE, qos=0, region=0, user=0, wuser=0):
|
||||
return await self.write_if.write_dword(address, data, awid,
|
||||
return await self.write_if.write_dword(address, data, byteorder, awid,
|
||||
burst, size, lock, cache, prot, qos, region, user, wuser)
|
||||
|
||||
async def write_qword(self, address, data, awid=None, burst=AxiBurstType.INCR, size=None,
|
||||
async def write_qword(self, address, data, byteorder='little', awid=None, burst=AxiBurstType.INCR, size=None,
|
||||
lock=AxiLockType.NORMAL, cache=0b0011, prot=AxiProt.NONSECURE, qos=0, region=0, user=0, wuser=0):
|
||||
return await self.write_if.write_qword(address, data, awid,
|
||||
return await self.write_if.write_qword(address, data, byteorder, awid,
|
||||
burst, size, lock, cache, prot, qos, region, user, wuser)
|
||||
|
||||
Reference in New Issue
Block a user