comparison modules/bluespec/Pygar/core/AudioCoreSystem.cpp @ 52:49049f97312c pygar svn.53

[svn r53] sends to two cores (but has issues)
author punk
date Thu, 06 May 2010 08:57:53 -0400
parents 2b18894f75e2
children 2991344775f8
comparison
equal deleted inserted replaced
51:9fe5ed4af92d 52:49049f97312c
62 void 62 void
63 CONNECTED_APPLICATION_CLASS::Main() 63 CONNECTED_APPLICATION_CLASS::Main()
64 { 64 {
65 //rlm: two files 65 //rlm: two files
66 FILE *inputFile; 66 FILE *inputFile;
67 // FILE *inputFile1; 67 FILE *inputFile1;
68 UINT16 sample; 68 UINT16 sample;
69 //UINT16 sample1; 69 UINT16 sample1;
70 70
71 //rlm: not sure if normal ints are ok here; using UINT16 because I know it works 71 //rlm: not sure if normal ints are ok here; using UINT16 because I know it works
72 UINT16 channel0 = 5; 72 UINT16 channel0 = 0;
73 //UINT16 channel1 = 1; 73 UINT16 channel1 = 1;
74 74
75 //init processor 75 //init processor
76 int sleepCount = 0; 76 int sleepCount = 0;
77 int result = 0; 77 int result = 0;
78 78
84 84
85 85
86 //rlm: for now we are going to going to just have 2 files with "common names" 86 //rlm: for now we are going to going to just have 2 files with "common names"
87 87
88 generate_pcm("input.wav","input.pcm"); 88 generate_pcm("input.wav","input.pcm");
89 //generate_pcm("input1.wav", "input1.pcm"); 89 generate_pcm("input1.wav", "input1.pcm");
90 90
91 91
92 //Send data to the machine here. 92 //Send data to the machine here.
93 //rlm: two files 93 //rlm: two files
94 inputFile = fopen("input.pcm","r"); 94 inputFile = fopen("input.pcm","r");
95 // inputFile = fopen("input1.pcm", "r"); 95 inputFile = fopen("input1.pcm", "r");
96 96
97 //assert(inputFile1); 97 assert(inputFile1);
98 assert(inputFile); 98 assert(inputFile);
99 99
100 int count = 0; 100 int count = 0;
101 101
102 printf("main:PROCESSOR about to enter loop %d\n", count); 102 printf("main:PROCESSOR about to enter loop %d\n", count);
103 103
104 //rlm: here we read both files. later refactor into a function. 104 //rlm: here we read both files. later refactor into a function.
105 // also, this will terminate when the FIRST file reaches its end. 105 // also, this will terminate when the FIRST file reaches its end.
106 while( fread(&sample, 2, 1, inputFile)) //&& (fread(&sample1, 2 , 1, inputFile1))) 106 while( (fread(&sample, 2, 1, inputFile)) || (fread(&sample1, 2 , 1, inputFile1)))
107 { /* 107 { /*
108 printf("hi\n"); 108 printf("hi\n");
109 if (!coreFin && (result = clientStub->ReadCPUToHost(0)) != 1) 109 if (!coreFin && (result = clientStub->ReadCPUToHost(0)) != 1)
110 { 110 {
111 sleepCount++; 111 sleepCount++;
112 if(sleepCount == 200) {
113 printf("Failed to get response from hardware, bailing\n\n");
114 printf("This means that either your hardware is hanging\n");
115 printf("or that the software hasn't given it enough time\n");
116 printf("to complete. If you think it needs more time, then\n");
117 printf("edit CONNECTED_APPLICATION_CLASS::Main() in ProcessorSystem.cpp\n");
118 printf("(connected_application)\n");
119 }
120 } 112 }
121 else if (!coreFin && result == 1) 113 else if (!coreFin && result == 1)
122 { 114 {
123 printf("\n***SOFT_CORE PASSED***\n"); 115 printf("\n***SOFT_CORE PASSED***\n");
124 coreFin = true; 116 coreFin = true;
130 count++; 122 count++;
131 sem_wait(&throttle); 123 sem_wait(&throttle);
132 124
133 //rlm: two files. 125 //rlm: two files.
134 // clientStub->SendUnprocessedStream( Data,(UINT32)sample); 126 // clientStub->SendUnprocessedStream( Data,(UINT32)sample);
135 clientStub->SendUnprocessedStream((UINT32)channel0 , Data,(UINT32)sample); 127 clientStub->SendUnprocessedStream((UINT32)channel0 , Data,(UINT32)sample);
136 //clientStub->SendUnprocessedStream(channel1 , Data,(UINT32)sample1); 128 clientStub->SendUnprocessedStream((UINT32)channel1 , Data,(UINT32)sample1);
137
138 } 129 }
139 130
140 printf("main: out of loop\n"); 131 printf("main: out of loop\n");
141 132
142 // Need to put lock here to prevent potential race condition 133 // Need to put lock here to prevent potential race condition
144 135
145 //rlm: have to send end-files to both voices. 136 //rlm: have to send end-files to both voices.
146 // all of these operations wil eventually be moved into functions. 137 // all of these operations wil eventually be moved into functions.
147 //clientStub->SendUnprocessedStream(EndOfFile,0); 138 //clientStub->SendUnprocessedStream(EndOfFile,0);
148 clientStub->SendUnprocessedStream((UINT32)channel0, EndOfFile,0); 139 clientStub->SendUnprocessedStream((UINT32)channel0, EndOfFile,0);
149 // clientStub->SendUnprocessedStream(channel1, EndOfFile,0); 140 clientStub->SendUnprocessedStream((UINT32)channel1, EndOfFile,0);
150 141
151 printf("main: wait for end of file\n"); 142 printf("main: wait for end of file\n");
152 143
153 pthread_cond_wait(&cond, &lock); 144 pthread_cond_wait(&cond, &lock);
154 pthread_mutex_unlock(&lock); 145 pthread_mutex_unlock(&lock);