software/driver: remove samplerate handling and simply pass it when writing dump if wanted

This commit is contained in:
Florent Kermarrec 2017-06-22 18:37:54 +02:00
parent 9e669dce7f
commit 49c524d866
3 changed files with 6 additions and 17 deletions

View File

@ -14,6 +14,7 @@ while not analyzer.done():
pass
analyzer.upload()
analyzer.save("dump.vcd")
analyzer.save("dump.sr")
# # #

View File

@ -9,18 +9,12 @@ import csv
class LiteScopeAnalyzerDriver:
def __init__(self, regs, name, config_csv=None, clk_freq=None, debug=False):
def __init__(self, regs, name, config_csv=None, debug=False):
self.regs = regs
self.name = name
self.config_csv = config_csv
if self.config_csv is None:
self.config_csv = name + ".csv"
if clk_freq is None:
self.clk_freq = None
self.samplerate = None
else:
self.clk_freq = clk_freq
self.samplerate = clk_freq
self.debug = debug
self.get_config()
self.get_layouts()
@ -78,10 +72,6 @@ class LiteScopeAnalyzerDriver:
def configure_subsampler(self, value):
self.frontend_subsampler_value.write(value-1)
if self.clk_freq is not None:
self.samplerate = self.clk_freq//n
else:
self.samplerate = None
def done(self):
return self.storage_idle.read()
@ -117,7 +107,7 @@ class LiteScopeAnalyzerDriver:
self.data = new_data
return self.data
def save(self, filename):
def save(self, filename, samplerate=None):
if self.debug:
print("[writing to " + filename + "]...")
name, ext = os.path.splitext(filename)
@ -128,9 +118,7 @@ class LiteScopeAnalyzerDriver:
elif ext == ".py":
dump = PythonDump()
elif ext == ".sr":
if self.samplerate is None:
raise ValueError("Unable to automatically retrieve clk_freq, clk_freq parameter required")
dump = SigrokDump(samplerate=self.samplerate)
dump = SigrokDump(samplerate=samplerate)
else:
raise NotImplementedError
dump.add_from_layout(self.layouts[self.group], self.data)

View File

@ -9,10 +9,10 @@ from litescope.software.dump.common import Dump, DumpVariable
class SigrokDump(Dump):
def __init__(self, dump=None, samplerate=50000000):
def __init__(self, dump=None, samplerate=None):
Dump.__init__(self)
self.variables = [] if dump is None else dump.variables
self.samplerate = samplerate
self.samplerate = 100e6 if samplerate is None else samplerate
def write_version(self):
f = open("version", "w")