software/driver/analyzer/add_trigger: add support for binary/hexa expressions with x support.

ex: litescope_cli -v sig1 0b111x0
ex: litescope_cli -v sig2 0x1234567x
This commit is contained in:
Florent Kermarrec 2020-09-03 13:16:32 +02:00
parent 69de7c4930
commit dc9109030a
2 changed files with 21 additions and 4 deletions

View File

@ -8,7 +8,7 @@
import os
import sys
import re
from migen import *
@ -82,8 +82,26 @@ class LiteScopeAnalyzerDriver:
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
mask |= getattr(self, k + "_m")
# Check for binary/hexa expressions
mb = re.match("0b([01x]+)", v)
mx = re.match("0x([0-fx]+)", v)
m = mb or mx
if m is not None:
b = m.group(1)
v = 0
m = 0
for c in b:
v <<= 4 if mx is not None else 1
m <<= 4 if mx is not None else 1
if c != "x":
v |= int(c)
m |= 0xf if mx is not None else 0b1
value |= getattr(self, k + "_o")*v
mask |= getattr(self, k + "_m") & (getattr(self, k + "_o")*m)
# Else convert to int
else:
value |= getattr(self, k + "_o")*int(v, 0)
mask |= getattr(self, k + "_m")
self.trigger_mem_mask.write(mask)
self.trigger_mem_value.write(value)
self.trigger_mem_write.write(1)

View File

@ -85,7 +85,6 @@ def add_triggers(args, analyzer, signals):
cond = {}
for signal, value in args.value_trigger or []:
name = finder[signal]
value = int(value, 0)
cond[finder[signal]] = value
print(f"Condition: {name} == {value}")
if cond: