main
|
Last change
on this file was ea777aa, checked in by Alex Wilton <awilton@…>, 3 years ago |
|
Moved examples, include, build_default.properties, common.xml, and README out from dev.civl.com into the root of the repo.
git-svn-id: svn://vsl.cis.udel.edu/civl/trunk@5704 fb995dde-84ed-4084-dfe6-e5aef3e2452c
|
-
Property mode
set to
100644
|
|
File size:
761 bytes
|
| Line | |
|---|
| 1 | /*Command line execution:
|
|---|
| 2 | * civl verify -por=new -inputN=3 adder2.cvl
|
|---|
| 3 | *
|
|---|
| 4 | * This example is to show that the new POR is working properly.
|
|---|
| 5 | *
|
|---|
| 6 | */
|
|---|
| 7 | #include<civlc.cvh>
|
|---|
| 8 |
|
|---|
| 9 | $input int N;
|
|---|
| 10 |
|
|---|
| 11 | void adder(int* result, int k){
|
|---|
| 12 | int local = 0;
|
|---|
| 13 |
|
|---|
| 14 | for(int i = 1; i <= k; i++)
|
|---|
| 15 | local += i;
|
|---|
| 16 | /*
|
|---|
| 17 | * result is a parameter of pointer type and the actual value here
|
|---|
| 18 | * refers to a shared variable in a higher scope.
|
|---|
| 19 | * A correct POR should detect this statement as dependent.
|
|---|
| 20 | * */
|
|---|
| 21 | result[k-1] = local;
|
|---|
| 22 | }
|
|---|
| 23 |
|
|---|
| 24 | void main(){
|
|---|
| 25 | int sum[N];
|
|---|
| 26 | $proc procs[N];
|
|---|
| 27 |
|
|---|
| 28 | for(int i = 0; i < N; i++) {
|
|---|
| 29 | procs[i] = $spawn adder(sum, i+1);
|
|---|
| 30 | }
|
|---|
| 31 | for(int i = 0; i < N; i++) {
|
|---|
| 32 | $wait(procs[i]);
|
|---|
| 33 | }
|
|---|
| 34 | for(int i = 0; i < N; i++) {
|
|---|
| 35 | $assert((sum[i] == ((i+1)*(i+2)/2)));
|
|---|
| 36 | }
|
|---|
| 37 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.