Skip to content

Commit

Permalink
software/driver/analyzer/add_trigger: add support for binary/hexa exp…
Browse files Browse the repository at this point in the history
…ressions with x support.

ex: litescope_cli -v sig1 0b111x0
ex: litescope_cli -v sig2 0x1234567x
  • Loading branch information
enjoy-digital committed Sep 3, 2020
1 parent 69de7c4 commit dc91090
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
24 changes: 21 additions & 3 deletions litescope/software/driver/analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import os
import sys

import re

from migen import *

Expand Down Expand Up @@ -82,8 +82,26 @@ def add_trigger(self, value=0, mask=0, cond=None):
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)
Expand Down
1 change: 0 additions & 1 deletion litescope/software/litescope_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit dc91090

Please sign in to comment.