view modules/bluespec/Pygar/core/AudioCoreRRR.cpp @ 65:cf8bb3038cbd pygar svn.66

[svn r66] sim passes
author punk
date Tue, 11 May 2010 09:05:22 -0400
parents bf08daea854e
children
line wrap: on
line source
1 #include <cstdio>
2 #include <cstdlib>
3 #include <iostream>
4 #include <iomanip>
5 #include <stdio.h>
6 #include <sys/stat.h>
8 #include "asim/rrr/service_ids.h"
10 #include "asim/provides/connected_application.h"
12 using namespace std;
14 // ===== service instantiation =====
15 AUDIOCORERRR_SERVER_CLASS AUDIOCORERRR_SERVER_CLASS::instance;
17 // constructor
18 AUDIOCORERRR_SERVER_CLASS::AUDIOCORERRR_SERVER_CLASS() :
19 serverStub(new AUDIOCORERRR_SERVER_STUB_CLASS(this))
20 {
21 // instantiate stub
23 outputFile = NULL;
24 memory = NULL;
25 fflush(stdout);
26 count = 0;
27 printf("ReceiveSide Created\n");
29 }
31 // destructor
32 AUDIOCORERRR_SERVER_CLASS::~AUDIOCORERRR_SERVER_CLASS()
33 {
34 printf("rlm: AUDIOCORERRR_SERVER_CLASS::~AUDIOCORERRR_SERVER_CLASS()\n");
35 Cleanup();
36 }
38 // init
39 void
40 AUDIOCORERRR_SERVER_CLASS::Init(PLATFORMS_MODULE p)
41 {
42 printf("rlm: AUDIOCORERRR_SERVER_CLASS::Init(PLATFORMS_MODULE p)\n");
43 parent = p;
44 }
46 // uninit
47 void
48 AUDIOCORERRR_SERVER_CLASS::Uninit()
49 {
50 printf("rlm: AUDIOCORERRR_SERVER_CLASS::Uninit()\n");
51 Cleanup();
52 }
54 // cleanup
55 void
56 AUDIOCORERRR_SERVER_CLASS::Cleanup()
57 {
58 printf("rlm: AUDIOCORERRR_SERVER_CLASS::Cleanup() \n\n");
59 delete serverStub;
60 }
63 //
64 // RRR service methods
65 //
67 /* Not used by scratchpad
68 UINT32
69 AUDIOCORERRR_SERVER_CLASS::MemoryRequestLoad (UINT32 address)
70 {
71 UINT32 returnVal;
72 printf("rlm: AUDIOCORERRR_SERVER_CLASS::MemoryRequestLoad (UINT32 address)\n");
73 if(memory == NULL) {
74 memory = new FUNCP_SIMULATED_MEMORY_CLASS();
75 }
78 memory->Read(0,(UINT64) address, sizeof(UINT32), &returnVal);
79 return returnVal;
80 }
82 void
83 AUDIOCORERRR_SERVER_CLASS::MemoryRequestStore (UINT32 address, UINT32 data)
84 {
85 printf("rlm: AUDIOCORERRR_SERVER_CLASS::MemoryRequestStore (UINT32 address, UINT32 data)\n");
86 if(memory == NULL) {
87 memory = new FUNCP_SIMULATED_MEMORY_CLASS();
88 }
90 memory->Write(0,(UINT64) address, sizeof(UINT32), &data);
91 }
92 */
94 void
95 AUDIOCORERRR_SERVER_CLASS::SendTerminate(UINT32 flag)
96 {
97 printf("lsp: Received Process Termination\n");
98 CONNECTED_APPLICATION_CLASS::EndSimulation();
99 }
101 void
103 AUDIOCORERRR_SERVER_CLASS::SendProcessedStream(UINT16 control, UINT16 data)
104 {
106 // printf("rlm: SendProcessedStream called,\n");
107 AudioProcessorControl audioProcessorControl = (AudioProcessorControl) control;
108 switch(control) {
109 case EndOfFile:
110 if(outputFile != NULL) {
111 printf("rlm: FILE is NULL\n");
112 fflush(outputFile);
113 fclose(outputFile);
114 outputFile = NULL;
115 } else {
116 printf("rlm: Opening file for output.\n");
117 outputFile = fopen("out_hw.pcm","w");
118 assert(outputFile);
119 fflush(outputFile);
120 fclose(outputFile);
121 }
123 // Long term this should be in the data portion. But until I have code running, keep it here.
124 // count++;
125 //if (count == 2)
126 CONNECTED_APPLICATION_CLASS::EndSimulation();
127 break;
129 case Data:
130 if(outputFile == NULL) {
131 outputFile = fopen("out_hw.pcm","w");
132 assert(outputFile);
133 }
135 CONNECTED_APPLICATION_CLASS::UpdateSemaphore();
136 printf("rlm: writing data to out_hw.pcm\n");
137 fwrite(&data, 2,1 , outputFile);
138 break;
139 }
140 }