macro Size = 4;

module SortArray(event int ?x_in,!y_out) {
    [Size]int u,v;
    {
        EndCell(u[0],v[0]);
    || 
        for(i=0..Size-2) do ||
            SortCell(u[i+1],v[i],u[i],v[i+1]);
    || 
        SortCell(x_in,v[Size-1],u[Size-1],y_out);
    }
}
drivenby {
    x_in = 4;
    pause;
    x_in = -1;  // dummy value
    pause;
    x_in = 3;
    pause;
    x_in = -1;  // dummy value
    pause;
    x_in = 1;
    pause;
    x_in = -1;  // dummy value
    pause;
    x_in = 2;
    pause;
    x_in = -1;  // dummy value
    pause;
    for(i=0..6) {
        x_in = 10;
        pause;
    }
}