Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove legacy rawWrite/rawRead and remove MemoryDevice #1093

Merged
merged 6 commits into from
Jul 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions python/surf/devices/microchip/_Axi24LC64FT.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,13 @@ def __init__(self,
# Variables
##############################
if (instantiate):
pr.MemoryDevice(
self.add(pr.RemoteVariable(
name = "Mem",
description = "Memory Array",
size = (4*nelms),
# nelms = nelms,
)
numValues = nelms,
valueBits = 32,
valueStride = 32,
bitSize = 32 * nelms,
# mode = "RO",
))
243 changes: 94 additions & 149 deletions python/surf/devices/micron/_AxiMicronMt28ew.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import time
import datetime
import math
import rogue

class AxiMicronMt28ew(pr.Device):
def __init__(self,
Expand All @@ -28,16 +27,8 @@ def __init__(self,
hidden = True,
**kwargs):

self._useVars = rogue.Version.greaterThanEqual('5.4.0')

if self._useVars:
size = 0
else:
size = (0x1 << 12)

super().__init__(
description = description,
size = size,
hidden = hidden,
**kwargs)

Expand All @@ -48,76 +39,74 @@ def __init__(self,
##############################
# Setup variables
##############################
if self._useVars:

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=32,
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.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=32,
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):
Expand Down Expand Up @@ -203,16 +192,10 @@ def writeProm(self):
# Reset the PROM
self._resetCmd()
# Create a burst data array
if self._useVars:
dataArray = self.BurstData.get(read=False)
else:
dataArray = [0] * 256
dataArray = self.BurstData.get(read=False)

# Set the block transfer size
if self._useVars:
self.TranSize.set(0xFF)
else:
self._rawWrite(0x80,0xFF,tryCount=self._tryCount) # Deprecated
self.TranSize.set(0xFF)

# Setup the status bar
with click.progressbar(
Expand All @@ -238,35 +221,21 @@ def writeProm(self):
# Check for the last byte
if ( cnt == 256 ):

if self._useVars:
# Write burst data
self.BurstData.set(dataArray)
# Start a burst transfer
self.BurstTran.set(0x7FFFFFFF&addr)

else:
# Write burst data
self._rawWrite(offset=0x400, data=dataArray,tryCount=self._tryCount) # Deprecated
# Start a burst transfer
self._rawWrite(offset=0x84, data=0x7FFFFFFF&addr,tryCount=self._tryCount) # Deprecated
# Write burst data
self.BurstData.set(dataArray)
# Start a burst transfer
self.BurstTran.set(0x7FFFFFFF&addr)

# Check for leftover data
if (cnt != 256):
# Fill the rest of the data array with ones
for i in range(cnt, 256):
dataArray[i] = 0xFFFF

if self._useVars:
# Write burst data
self.BurstData.set(dataArray)
# Start a burst transfer
self.BurstTran.set(0x7FFFFFFF&addr)

else:
# Write burst data
self._rawWrite(offset=0x400, data=dataArray,tryCount=self._tryCount) # Deprecated
# Start a burst transfer
self._rawWrite(offset=0x84, data=0x7FFFFFFF&addr,tryCount=self._tryCount) # Deprecated
# Write burst data
self.BurstData.set(dataArray)
# Start a burst transfer
self.BurstTran.set(0x7FFFFFFF&addr)

# Close the status bar
bar.update(self._mcs.size)
Expand All @@ -275,16 +244,10 @@ def verifyProm(self):
# Reset the PROM
self._resetCmd()

if self._useVars:
# Set the data bus
self.DataWrBus.set(0xFFFFFFFF)
# Set the block transfer size
self.TranSize.set(0xFF)
else:
# Set the data bus
self._rawWrite(offset=0x0, data=0xFFFFFFFF,tryCount=self._tryCount) # Deprecated
# Set the block transfer size
self._rawWrite(offset=0x80, data=0xFF,tryCount=self._tryCount) # Deprecated
# Set the data bus
self.DataWrBus.set(0xFFFFFFFF)
# Set the block transfer size
self.TranSize.set(0xFF)

# Setup the status bar
with click.progressbar(
Expand All @@ -301,18 +264,12 @@ def verifyProm(self):
# Throttle down printf rate
bar.update(0x1FF)

if self._useVars:
# Start a burst transfer
self.BurstTran.set(0x80000000|addr)
# Start a burst transfer
self.BurstTran.set(0x80000000|addr)

# Get the data
dataArray = self.BurstData.get()
# Get the data
dataArray = self.BurstData.get()

else:
# Start a burst transfer
self._rawWrite(offset=0x84, data=0x80000000|addr,tryCount=self._tryCount) # Deprecated
# Get the data
dataArray = self._rawRead(offset=0x400,numWords=256,tryCount=self._tryCount) # Deprecated
else:
# Get the data for MCS file
data |= (int(self._mcs.entry[i][1]) << 8)
Expand All @@ -327,26 +284,14 @@ def verifyProm(self):

# Generic FLASH write Command
def _writeToFlash(self, addr, data):
if self._useVars:
# Set the data bus
self.DataWrBus.set(data)
# Set the address bus and initiate the transfer
self.AddrBus.set(addr&0x7FFFFFFF)
else:
# Set the data bus
self._rawWrite(offset=0x0, data=data,tryCount=self._tryCount) # Deprecated
# Set the address bus and initiate the transfer
self._rawWrite(offset=0x4,data=addr&0x7FFFFFFF,tryCount=self._tryCount) # Deprecated
# Set the data bus
self.DataWrBus.set(data)
# Set the address bus and initiate the transfer
self.AddrBus.set(addr&0x7FFFFFFF)

# Generic FLASH read Command
def _readFromFlash(self, addr):
if self._useVars:
# Set the address
self.AddrBus.set(addr|0x80000000)
# Get the read data
return self.DataRdBus.get()&0xFFFF
else:
# Set the address
self._rawWrite(offset=0x4, data=addr|0x80000000,tryCount=self._tryCount) # Deprecated
# Get the read data
return (self._rawRead(offset=0x8,tryCount=self._tryCount)&0xFFFF) # Deprecated
# Set the address
self.AddrBus.set(addr|0x80000000)
# Get the read data
return self.DataRdBus.get()&0xFFFF
Loading