Page History
Table of Contents |
---|
Vectors
You can assign a whole vector at once to an array.
Code Block | ||||
---|---|---|---|---|
| ||||
scchart vectorstuples { output int arr[5] = ({1, 2, 3, 4, 5)} initial state init { entry do arr = ({6, 7, 8, 9, 10)} } } |
To assign only certain values of an array, you can also use the ignore value placeholder. Consult the expression manual for further information.
Code Block | ||||
---|---|---|---|---|
| ||||
scchart Ctuples { const int A = 1 output int arr[3][2] = (({{A,0)}, ({2,0)}, ({3,0))}} initial state init --> init do arr = (({{arr[0] + 1, _)}, _, ({arr[2] + 1, _))}} } |
This would, for example, result in c code assignments as displayed on the right.
Code Block | ||||
---|---|---|---|---|
| ||||
void logic(TickData* d) {
d->_g0 = d->_GO;
if (d->_g0) {
d->arr[0][0] = 1;
d->arr[0][1] = 0;
d->arr[1][0] = 2;
d->arr[1][1] = 0;
d->arr[2][0] = 3;
d->arr[2][1] = 0;
}
d->_g2 = d->_pg1;
if (d->_g2) {
d->arr[0][0] = d->arr[0] + 1;
d->arr[2][0] = d->arr[2] + 1;
}
d->_g1 = d->_g0 || d->_g2;
} |
Overview
Content Tools