Skip to content

Commit

Permalink
general code clean up for AxiMicronP30.py
Browse files Browse the repository at this point in the history
  • Loading branch information
ruck314 committed Feb 20, 2024
1 parent 485663e commit 9ce4d2a
Showing 1 changed file with 129 additions and 111 deletions.
240 changes: 129 additions & 111 deletions python/surf/devices/micron/_AxiMicronP30.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,117 +39,135 @@ def __init__(self,
##############################
# Setup variables
##############################
self.add(pr.RemoteVariable(name='DataWrBus',
offset=0x0,
base=pr.UInt,
bitSize=32,
bitOffset=0,
retryCount=tryCount,
updateNotify=False,
bulkOpEn=False,
hidden=True,
verify=False))

self.add(pr.RemoteVariable(name='AddrBus',
offset=0x4,
base=pr.UInt,
bitSize=32,
bitOffset=0,
retryCount=tryCount,
updateNotify=False,
bulkOpEn=False,
hidden=True,
verify=False))

self.add(pr.RemoteVariable(name='DataRdBus',
offset=0x8,
base=pr.UInt,
bitSize=32,
bitOffset=0,
retryCount=tryCount,
updateNotify=False,
bulkOpEn=False,
hidden=True,
verify=False))

self.add(pr.RemoteVariable(name='TranSize',
offset=0x80,
base=pr.UInt,
bitSize=8,
bitOffset=0,
retryCount=tryCount,
updateNotify=False,
bulkOpEn=False,
hidden=True,
verify=False))

self.add(pr.RemoteVariable(name='BurstTran',
offset=0x84,
base=pr.UInt,
bitSize=32,
bitOffset=0,
retryCount=tryCount,
updateNotify=False,
bulkOpEn=False,
hidden=True,
verify=False))

self.add(pr.RemoteVariable(name='BurstData',
offset=0x400,
base=pr.UInt,
bitSize=32*256,
bitOffset=0,
numValues=256,
valueBits=32,
valueStride=32,
retryCount=tryCount,
updateNotify=False,
bulkOpEn=False,
hidden=True,
verify=False))

@self.command(value='',description="Load the .MCS into PROM",)
def LoadMcsFile(arg):

click.secho(('%s.LoadMcsFile: %s' % (self.path,arg) ), fg='green')
self._progDone = False

# Start time measurement for profiling
start = time.time()

# Configuration: Force default configurations
self._writeToFlash(0xFD4F,0x60,0x03)

# Open the MCS file
self._mcs.open(arg)

# Erase the PROM
self.eraseProm()

# Write to the PROM
self.writeProm()

# Verify the PROM
self.verifyProm()

# End time measurement for profiling
end = time.time()
elapsed = end - start
click.secho('LoadMcsFile() took %s to program the PROM' % datetime.timedelta(seconds=int(elapsed)), fg='green')

# Add a power cycle reminder
self._progDone = True
click.secho(
"\n\n\
***************************************************\n\
***************************************************\n\
The MCS data has been written into the PROM. \n\
To reprogram the FPGA with the new PROM data, \n\
a IPROG CMD or power cycle is be required.\n\
***************************************************\n\
***************************************************\n\n"
, bg='green',
)
self.add(pr.RemoteVariable(
name = 'DataWrBus',
offset = 0x0,
base = pr.UInt,
bitSize = 32,
bitOffset = 0,
retryCount = tryCount,
updateNotify = False,
bulkOpEn = False,
hidden = True,
verify = False,
))

self.add(pr.RemoteVariable(
name = 'AddrBus',
offset = 0x4,
base = pr.UInt,
bitSize = 32,
bitOffset = 0,
retryCount = tryCount,
updateNotify = False,
bulkOpEn = False,
hidden = True,
verify = False,
))

self.add(pr.RemoteVariable(
name = 'DataRdBus',
offset = 0x8,
base = pr.UInt,
bitSize = 32,
bitOffset = 0,
retryCount = tryCount,
updateNotify = False,
bulkOpEn = False,
hidden = True,
verify = False,
))

self.add(pr.RemoteVariable(
name = 'TranSize',
offset = 0x80,
base = pr.UInt,
bitSize = 8,
bitOffset = 0,
retryCount = tryCount,
updateNotify = False,
bulkOpEn = False,
hidden = True,
verify = False,
))

self.add(pr.RemoteVariable(
name = 'BurstTran',
offset = 0x84,
base = pr.UInt,
bitSize = 32,
bitOffset = 0,
retryCount = tryCount,
updateNotify = False,
bulkOpEn = False,
hidden = True,
verify = False,
))

self.add(pr.RemoteVariable(
name = 'BurstData',
offset = 0x400,
base = pr.UInt,
bitSize = 32*256,
bitOffset = 0,
numValues = 256,
valueBits = 32,
valueStride = 32,
retryCount = tryCount,
updateNotify = False,
bulkOpEn = False,
hidden = True,
verify = False,
))

self.add(pr.LocalCommand(
name = 'LoadMcsFile',
function = self._LoadMcsFile,
description = 'Load the .MCS into PROM',
value = '',
))

def _LoadMcsFile(self,arg):

click.secho(('%s.LoadMcsFile: %s' % (self.path,arg) ), fg='green')
self._progDone = False

# Start time measurement for profiling
start = time.time()

# Configuration: Force default configurations
self._writeToFlash(0xFD4F,0x60,0x03)

# Open the MCS file
self._mcs.open(arg)

# Erase the PROM
self.eraseProm()

# Write to the PROM
self.writeProm()

# Verify the PROM
self.verifyProm()

# End time measurement for profiling
end = time.time()
elapsed = end - start
click.secho('LoadMcsFile() took %s to program the PROM' % datetime.timedelta(seconds=int(elapsed)), fg='green')

# Add a power cycle reminder
self._progDone = True
click.secho(
"\n\n\
***************************************************\n\
***************************************************\n\
The MCS data has been written into the PROM. \n\
To reprogram the FPGA with the new PROM data, \n\
a IPROG CMD or power cycle is be required.\n\
***************************************************\n\
***************************************************\n\n"
, bg='green',
)

def eraseProm(self):
# Set the starting address index
Expand Down

0 comments on commit 9ce4d2a

Please sign in to comment.