On Mon, 2026-06-08 at 10:57 +0200, Nam Cao wrote:
> +    def __parse_invariant(self, inv):
> +        # by default assume the timer has ns expiration
> +        clock_type = "ns"
> +        if inv.unit == "j":
> +            clock_type = "jiffy"
> +
> +        env = inv.env + self.enum_suffix
> +        val = inv.val.replace("()", "(ha_mon)")
> +
> +        match inv.unit:
> +            case "us":
> +                val *= 10**3
> +            case "ms":
> +                val *= 10**6
> +            case "s":
> +                val *= 10**9
> +

I need to add a test case for this.. You can check by using something like 5 us
in stall.dot in place of threshold_jiffies.

val is a string, doing val * 1000 repeats the string 1000 times in python!
We need to convert it like we do in __adjust_value(). Something like:

diff --git a/tools/verification/rvgen/rvgen/dot2k.py 
b/tools/verification/rvgen/rvgen/dot2k.py
index a080b92334..4d39f229c9 100644
--- a/tools/verification/rvgen/rvgen/dot2k.py
+++ b/tools/verification/rvgen/rvgen/dot2k.py
@@ -244,7 +244,11 @@ class ha2k(dot2k):
             clock_type = "jiffy"
 
         env = inv.env + self.enum_suffix
-        val = inv.val.replace("()", "(ha_mon)")
+        try:
+            val = int(inv.val)
+        except ValueError:
+            # it's a constant, a parameter or a function
+            val = inv.val.replace("()", "(ha_mon)")
 
         match inv.unit:
             case "us":

Thanks,
Gabriele


Reply via email to