comparison modules/bluespec/Pygar/core/AudioCoreSystem.cpp @ 31:f41eef1bebfc pygar svn.32

[svn r32] Attempting to run soft core and audio
author punk
date Sat, 01 May 2010 11:50:20 -0400
parents 220c14f5963c
children 0c775e733b81
comparison
equal deleted inserted replaced
30:2adf0fb45061 31:f41eef1bebfc
62 void 62 void
63 CONNECTED_APPLICATION_CLASS::Main() 63 CONNECTED_APPLICATION_CLASS::Main()
64 { 64 {
65 FILE *inputFile; 65 FILE *inputFile;
66 UINT16 sample; 66 UINT16 sample;
67 67
68 //init processor
69 int sleepCount = 0;
70 int result = 0;
71
72 bool coreFin = false;
73
74 fflush(stdout);
75
68 // Convert input wav to pcm 76 // Convert input wav to pcm
69 generate_pcm("input.wav","input.pcm"); 77 generate_pcm("input.wav","input.pcm");
70 78
71 //Send data to the machine here. 79 //Send data to the machine here.
72 inputFile = fopen("input.pcm","r"); 80 inputFile = fopen("input.pcm","r");
73 assert(inputFile); 81 assert(inputFile);
74 82
75
76 int count = 0; 83 int count = 0;
77 84
78 printf("main:PROCESSOR about to enter loop %d\n", count); 85 printf("main:PROCESSOR about to enter loop %d\n", count);
79 86
80 while(fread(&sample, 2, 1, inputFile)) { 87 while(fread(&sample, 2, 1, inputFile)) {
88 if (!coreFin && (result = clientStub->ReadCPUToHost(0)) != 1)
89 {
90 sleepCount++;
91 if(sleepCount == 200) {
92 printf("Failed to get response from hardware, bailing\n\n");
93 printf("This means that either your hardware is hanging\n");
94 printf("or that the software hasn't given it enough time\n");
95 printf("to complete. If you think it needs more time, then\n");
96 printf("edit CONNECTED_APPLICATION_CLASS::Main() in ProcessorSystem.cpp\n");
97 printf("(connected_application)\n");
98 }
99 }
100 else if (!coreFin && result == 1)
101 {
102 printf("\n***SOFT_CORE PASSED***\n");
103 coreFin = true;
104 }
105
81 if(count%1000 == 0) 106 if(count%1000 == 0)
82 printf("main: %d\n", count); 107 printf("main: %d\n", count);
83 count++; 108 count++;
84 sem_wait(&throttle); 109 sem_wait(&throttle);
85 // printf("rlm:sending data to processor (%d)\n", count); 110 // printf("rlm:sending data to processor (%d)\n", count);
86 clientStub->SendUnprocessedStream(Data,(UINT32)sample); 111 clientStub->SendUnprocessedStream(Data,(UINT32)sample);
112
87 } 113 }
88 114
89 printf("main: out of loop\n"); 115 printf("main: out of loop\n");
90 116
91 // Need to put lock here to prevent potential race condition 117 // Need to put lock here to prevent potential race condition
102 // Convert input wav to pcm 128 // Convert input wav to pcm
103 generate_wav("out_hw.pcm","input.wav","out_hw.wav"); 129 generate_wav("out_hw.pcm","input.wav","out_hw.wav");
104 130
105 printf("generate wav done\n"); 131 printf("generate wav done\n");
106 132
107 fflush(stdout); 133 printf("If you missed it, core ", coreFin ? "PASSED\n" : "FAILED\n");
108 exit(0);
109 }
110
111 /* THIS IS THE CODE HANDLING FROM THE REGULAR SOFT-CORE
112 TO BE INCORPORATED
113 // main
114 void
115 CONNECTED_APPLICATION_CLASS::Main()
116 {
117 int sleepCount = 0;
118 int result = 0;
119
120 fflush(stdout);
121
122 while ((result = clientStub->ReadCPUToHost(0)) != 1) {
123 sleep(1);
124 //printf("System controller sleeps with result: %d\n", result);
125 sleepCount++;
126 if(sleepCount == 100) {
127 printf("Failed to get response from hardware, bailing\n\n");
128 printf("This means that either your hardware is hanging\n");
129 printf("or that the software hasn't given it enough time\n");
130 printf("to complete. If you think it needs more time, then\n");
131 printf("edit CONNECTED_APPLICATION_CLASS::Main() in ProcessorSystem.cpp\n");
132 printf("(connected_application)\n");
133 exit(0);
134 }
135 }
136
137 if(result == 1) {
138 printf("\n***PASSED***\n");
139 }
140
141 // Dump the stats file 134 // Dump the stats file
142 135
143 STATS_DEVICE_SERVER_CLASS::GetInstance()->DumpStats(); 136 STATS_DEVICE_SERVER_CLASS::GetInstance()->DumpStats();
144 STATS_DEVICE_SERVER_CLASS::GetInstance()->EmitFile(); 137 STATS_DEVICE_SERVER_CLASS::GetInstance()->EmitFile();
145 138
146 fflush(stdout); 139 fflush(stdout);
147 exit(0); 140 exit(0);
148 }*/ 141 }