incr method
Shorthand for a Conditional which increments this by val
.
By default for a Logic variable, if no val
is provided then the
result is ++variable else result is variable+=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.incr(val: b),
]);
Combinational.ssa((s) => [
s(pOut) < a,
pOut.incr(val: b, s: s),
]);
Implementation
Conditional incr({Logic Function(Logic)? s, dynamic val = 1}) =>
s == null ? (this < this + val) : (s(this) < s(this) + val);