From a269e67a101b82fc918c7310a86f27fa98100d1f Mon Sep 17 00:00:00 2001 From: Florent Kermarrec Date: Mon, 28 May 2018 19:42:46 +0200 Subject: [PATCH] software: add rising/falling edge support --- example_designs/test/test_analyzer.py | 2 +- litescope/software/driver/analyzer.py | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/example_designs/test/test_analyzer.py b/example_designs/test/test_analyzer.py index ab43005..c54929c 100644 --- a/example_designs/test/test_analyzer.py +++ b/example_designs/test/test_analyzer.py @@ -13,7 +13,7 @@ dumps = { for group, filename in dumps.items(): analyzer = LiteScopeAnalyzerDriver(wb.regs, "analyzer", debug=True) - analyzer.configure_trigger(cond={"zero": 1}) + analyzer.add_rising_edge_trigger("zero") analyzer.configure_subsampler(1) analyzer.configure_group(group) analyzer.run(offset=32, length=128) diff --git a/litescope/software/driver/analyzer.py b/litescope/software/driver/analyzer.py index d8951c3..ce2f767 100644 --- a/litescope/software/driver/analyzer.py +++ b/litescope/software/driver/analyzer.py @@ -65,8 +65,9 @@ class LiteScopeAnalyzerDriver: self.group = value self.mux_value.write(value) - def configure_trigger(self, value=0, mask=0, cond=None): - self.frontend_trigger_enable.write(0) + def add_trigger(self, value=0, mask=0, cond=None): + if self.frontend_trigger_mem_full.read(): + raise ValueError("Trigger memory full, too much conditions") if cond is not None: for k, v in cond.items(): value |= getattr(self, k + "_o")*v @@ -75,6 +76,17 @@ class LiteScopeAnalyzerDriver: self.frontend_trigger_mem_value.write(value) self.frontend_trigger_mem_write.write(1) + def add_rising_edge_trigger(self, name): + self.add_trigger(getattr(self, name + "_o")*0, getattr(self, name + "_m")) + self.add_trigger(getattr(self, name + "_o")*1, getattr(self, name + "_m")) + + def add_falling_edge_trigger(self, name): + self.add_trigger(getattr(self, name + "_o")*1, getattr(self, name + "_m")) + self.add_trigger(getattr(self, name + "_o")*0, getattr(self, name + "_m")) + + def configure_trigger(self, value=0, mask=0, cond=None): + self.add_trigger(value, mask, cond) + def configure_subsampler(self, value): self.frontend_subsampler_value.write(value-1)