Skip to content

Commit

Permalink
Merge
Browse files Browse the repository at this point in the history
  • Loading branch information
benreynwar committed Jan 13, 2021
2 parents ccddb21 + 6e63d9d commit d1a64a3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
10 changes: 8 additions & 2 deletions axilent/cocotb_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,13 +180,19 @@ async def send(self, command):
for offset, d in enumerate(ac.data):
address = ac.start_address
if not ac.constant_address:
address += offset
if ac.address_by_word:
address += offset
else:
address += offset * 4
write_events.append(self.submit_write(address, d))
else:
for index in range(ac.length):
address = ac.start_address
if not ac.constant_address:
address += index
if ac.address_by_word:
address += index
else:
address += index * 4
read_events.append(self.submit_read(address))

for index, event in enumerate(write_events):
Expand Down
14 changes: 11 additions & 3 deletions axilent/comms.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,16 @@ def process_responses(self, read_responses, write_responses, resolve_future=True
return e, r


WORD_SIZE = 4


class AxiCommand(Command):
'''
Defines a series AXI4Lite master-to-slave commands.
'''

def __init__(self, start_address, length, readorwrite, data=None,
constant_address=False, description=None):
constant_address=False, description=None, address_by_word=True):
'''
`start_address`: The address on which the first AXI command operates.
`constant_address`: If this is `True` we keep operating on the same
Expand All @@ -106,6 +109,7 @@ def __init__(self, start_address, length, readorwrite, data=None,
self.length = length
self.readorwrite = readorwrite
self.constant_address = constant_address
self.address_by_word = address_by_word
assert readorwrite in (READ_TYPE, WRITE_TYPE)
self.data = data
if readorwrite == READ_TYPE:
Expand All @@ -114,7 +118,10 @@ def __init__(self, start_address, length, readorwrite, data=None,
assert len(self.data) == length
assert start_address <= max_address
if not constant_address:
assert start_address + length-1 <= max_address
if address_by_word:
assert start_address + length-1 <= max_address
else:
assert start_address + (length-1) * WORD_SIZE <= max_address
assert description
super().__init__(description)

Expand Down Expand Up @@ -169,7 +176,7 @@ def process_responses(self, read_responses, write_responses,
class SetUnsignedsCommand(AxiCommand):

def __init__(self, values, address, description=None,
constant_address=False):
constant_address=False, address_by_word=True):
for value in values:
assert value < pow(2, 32)
super().__init__(
Expand All @@ -178,6 +185,7 @@ def __init__(self, values, address, description=None,
readorwrite=WRITE_TYPE,
data=values,
constant_address=constant_address,
address_by_word=address_by_word,
description=description,
)

Expand Down

0 comments on commit d1a64a3

Please sign in to comment.