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 pass
analyzer.upload() analyzer.upload()
analyzer.save("dump.vcd") analyzer.save("dump.vcd")
analyzer.save("dump.sr")
# # # # # #

View File

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