decr method

Conditional decr(
  1. {Logic s(
    1. Logic
    )?,
  2. dynamic val = 1}
)

Shorthand for a Conditional which decrements this by val.

By default for a Logic variable, if no val is provided then the result is --variable else result is var-=val.

If using Combinational, you will need to provide s as a remapping function since otherwise this will cause a "write after read" violation.


Sequential(clk, [
  pOut.decr(val: b),
]);

Combinational.ssa((s) => [
      s(pOut) < a,
      pOut.decr(val: b, s: s),
    ]);

Implementation

Conditional decr({Logic Function(Logic)? s, dynamic val = 1}) =>
    s == null ? (this < this - val) : (s(this) < s(this) - val);