mirror of
https://github.com/enjoy-digital/litex.git
synced 2025-01-04 09:52:26 -05:00
driver/la: add samplerate computation (required by sigrok export)
This commit is contained in:
parent
8e0553670a
commit
e495e2f537
1 changed files with 18 additions and 3 deletions
|
@ -5,12 +5,21 @@ from litescope.host.dump import *
|
||||||
from litescope.host.driver.truthtable import *
|
from litescope.host.driver.truthtable import *
|
||||||
|
|
||||||
class LiteScopeLADriver():
|
class LiteScopeLADriver():
|
||||||
def __init__(self, regs, name, config_csv=None, debug=False):
|
def __init__(self, regs, name, config_csv=None, clk_freq=None, debug=False):
|
||||||
self.regs = regs
|
self.regs = regs
|
||||||
self.name = name
|
self.name = name
|
||||||
self.debug = debug
|
|
||||||
if config_csv is None:
|
if config_csv is None:
|
||||||
self.config_csv = name + ".csv"
|
self.config_csv = name + ".csv"
|
||||||
|
if clk_freq is None:
|
||||||
|
try:
|
||||||
|
self.clk_freq = regs.identifier_frequency.read()
|
||||||
|
except:
|
||||||
|
self.clk_freq = None
|
||||||
|
self.samplerate = self.clk_freq
|
||||||
|
else:
|
||||||
|
self.clk_freq = clk_freq
|
||||||
|
self.samplerate = clk_freq
|
||||||
|
self.debug = debug
|
||||||
self.get_config()
|
self.get_config()
|
||||||
self.get_layout()
|
self.get_layout()
|
||||||
self.build()
|
self.build()
|
||||||
|
@ -78,6 +87,10 @@ class LiteScopeLADriver():
|
||||||
|
|
||||||
def configure_subsampler(self, n):
|
def configure_subsampler(self, n):
|
||||||
self.subsampler_value.write(n-1)
|
self.subsampler_value.write(n-1)
|
||||||
|
if self.clk_freq is not None:
|
||||||
|
self.samplerate = self.clk_freq//n
|
||||||
|
else:
|
||||||
|
self.samplerate = None
|
||||||
|
|
||||||
def configure_qualifier(self, v):
|
def configure_qualifier(self, v):
|
||||||
self.recorder_qualifier.write(v)
|
self.recorder_qualifier.write(v)
|
||||||
|
@ -121,7 +134,9 @@ class LiteScopeLADriver():
|
||||||
dump = PythonDump()
|
dump = PythonDump()
|
||||||
elif ext == ".sr":
|
elif ext == ".sr":
|
||||||
from litescope.host.dump.sigrok import SigrokDump
|
from litescope.host.dump.sigrok import SigrokDump
|
||||||
dump = SigrokDump()
|
if self.samplerate is None:
|
||||||
|
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.layout, self.data)
|
dump.add_from_layout(self.layout, self.data)
|
||||||
|
|
Loading…
Reference in a new issue