mirror of https://github.com/YosysHQ/yosys.git
Add support for $increment
This commit is contained in:
parent
88d9e213cb
commit
2125357e76
|
@ -3487,7 +3487,7 @@ skip_dynamic_range_lvalue_expansion:;
|
|||
goto apply_newNode;
|
||||
}
|
||||
|
||||
if (str == "\\$size" || str == "\\$bits" || str == "\\$high" || str == "\\$low" || str == "\\$left" || str == "\\$right")
|
||||
if (str == "\\$increment" || str == "\\$size" || str == "\\$bits" || str == "\\$high" || str == "\\$low" || str == "\\$left" || str == "\\$right")
|
||||
{
|
||||
int dim = 1;
|
||||
if (str == "\\$bits") {
|
||||
|
@ -3556,6 +3556,8 @@ skip_dynamic_range_lvalue_expansion:;
|
|||
result = left;
|
||||
else if (str == "\\$right")
|
||||
result = right;
|
||||
else if (str == "\\$increment")
|
||||
result = left >= right ? 1 : -1;
|
||||
else if (str == "\\$size")
|
||||
result = width;
|
||||
else { // str == "\\$bits"
|
||||
|
|
|
@ -90,4 +90,17 @@ assert property ($right(z, 3) == 0);
|
|||
assert property ($right(z[3]) == 9);
|
||||
assert property ($right(z[3][3]) == 0);
|
||||
assert property ($right(z[3], 2) == 0);
|
||||
|
||||
assert property ($increment(x) == 1);
|
||||
assert property ($increment(y) == -1);
|
||||
assert property ($increment(y, 1) == -1);
|
||||
assert property ($increment(y, (1+1)) == 1);
|
||||
|
||||
assert property ($increment(z) == 1);
|
||||
assert property ($increment(z, 1) == 1);
|
||||
assert property ($increment(z, 2) == -1);
|
||||
assert property ($increment(z, 3) == 1);
|
||||
assert property ($increment(z[3]) == -1);
|
||||
assert property ($increment(z[3][3]) == 1);
|
||||
assert property ($increment(z[3], 2) == 1);
|
||||
endmodule
|
||||
|
|
|
@ -107,6 +107,19 @@ always_comb begin
|
|||
assert ($right(s.sz.z[3]) == 9);
|
||||
assert ($right(s.sz.z[3][3]) == 4);
|
||||
assert ($right(s.sz.z[3], 2) == 4);
|
||||
|
||||
assert ($increment(s.x) == 1);
|
||||
assert ($increment(s.sy.y) == -1);
|
||||
assert ($increment(s.sy.y, 1) == -1);
|
||||
assert ($increment(s.sy.y, (1+1)) == 1);
|
||||
|
||||
assert ($increment(s.sz.z) == 1);
|
||||
assert ($increment(s.sz.z, 1) == 1);
|
||||
assert ($increment(s.sz.z, 2) == -1);
|
||||
assert ($increment(s.sz.z, 3) == -1);
|
||||
assert ($increment(s.sz.z[3]) == -1);
|
||||
assert ($increment(s.sz.z[3][3]) == -1);
|
||||
assert ($increment(s.sz.z[3], 2) == -1);
|
||||
end
|
||||
|
||||
endmodule
|
||||
|
|
Loading…
Reference in New Issue