view modules/bluespec/Pygar/core/AudioCoreRRR.cpp @ 61:74d2fe78f36a pygar svn.62

[svn r62] synthesis boundaries
author punk
date Mon, 10 May 2010 20:31:25 -0400
parents 2991344775f8
children bf08daea854e
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 printf("rlm: init called\n\n");
24 outputFile = NULL;
25 memory = NULL;
26 fflush(stdout);
27 count = 0;
28 }
30 // destructor
31 AUDIOCORERRR_SERVER_CLASS::~AUDIOCORERRR_SERVER_CLASS()
32 {
33 printf("rlm: AUDIOCORERRR_SERVER_CLASS::~AUDIOCORERRR_SERVER_CLASS()\n");
34 Cleanup();
35 }
37 // init
38 void
39 AUDIOCORERRR_SERVER_CLASS::Init(PLATFORMS_MODULE p)
40 {
41 printf("rlm: AUDIOCORERRR_SERVER_CLASS::Init(PLATFORMS_MODULE p)\n");
42 parent = p;
43 }
45 // uninit
46 void
47 AUDIOCORERRR_SERVER_CLASS::Uninit()
48 {
49 printf("rlm: AUDIOCORERRR_SERVER_CLASS::Uninit()\n");
50 Cleanup();
51 }
53 // cleanup
54 void
55 AUDIOCORERRR_SERVER_CLASS::Cleanup()
56 {
57 printf("rlm: AUDIOCORERRR_SERVER_CLASS::Cleanup() \n\n");
58 delete serverStub;
59 }
62 //
63 // RRR service methods
64 //
66 /* Not used by scratchpad
67 UINT32
68 AUDIOCORERRR_SERVER_CLASS::MemoryRequestLoad (UINT32 address)
69 {
70 UINT32 returnVal;
71 printf("rlm: AUDIOCORERRR_SERVER_CLASS::MemoryRequestLoad (UINT32 address)\n");
72 if(memory == NULL) {
73 memory = new FUNCP_SIMULATED_MEMORY_CLASS();
74 }
77 memory->Read(0,(UINT64) address, sizeof(UINT32), &returnVal);
78 return returnVal;
79 }
81 void
82 AUDIOCORERRR_SERVER_CLASS::MemoryRequestStore (UINT32 address, UINT32 data)
83 {
84 printf("rlm: AUDIOCORERRR_SERVER_CLASS::MemoryRequestStore (UINT32 address, UINT32 data)\n");
85 if(memory == NULL) {
86 memory = new FUNCP_SIMULATED_MEMORY_CLASS();
87 }
89 memory->Write(0,(UINT64) address, sizeof(UINT32), &data);
90 }
91 */
93 void
94 AUDIOCORERRR_SERVER_CLASS::SendTerminate(UINT32 flag)
95 {
96 printf("lsp: Received Process Termination\n");
97 CONNECTED_APPLICATION_CLASS::EndSimulation();
98 }
100 void
102 AUDIOCORERRR_SERVER_CLASS::SendProcessedStream(UINT16 control, UINT16 data)
103 {
105 // printf("rlm: SendProcessedStream called,\n");
106 AudioProcessorControl audioProcessorControl = (AudioProcessorControl) control;
107 switch(control) {
108 case EndOfFile:
109 if(outputFile != NULL) {
110 printf("rlm: FILE is NULL\n");
111 fflush(outputFile);
112 fclose(outputFile);
113 outputFile = NULL;
114 } else {
115 printf("rlm: Opening file for output.\n");
116 outputFile = fopen("out_hw.pcm","w");
117 assert(outputFile);
118 fflush(outputFile);
119 fclose(outputFile);
120 }
122 // Long term this should be in the data portion. But until I have code running, keep it here.
123 // count++;
124 //if (count == 2)
125 CONNECTED_APPLICATION_CLASS::EndSimulation();
126 break;
128 case Data:
129 if(outputFile == NULL) {
130 outputFile = fopen("out_hw.pcm","w");
131 assert(outputFile);
132 }
134 CONNECTED_APPLICATION_CLASS::UpdateSemaphore();
135 // printf("rlm: writing data to out_hw.pcm\n");
136 fwrite(&data, 2,1 , outputFile);
137 break;
138 }
139 }