view modules/bluespec/Pygar/core/AudioCoreRRR.cpp @ 22:0cfbb1e2de22 pygar svn.23

[svn r23] whoohoo! it Compiles (note with commented out stuff)
author punk
date Wed, 28 Apr 2010 00:40:15 -0400
parents a1833d9f6e3d
children 90197e3375e2
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
22 printf("AUDIOCORERRR init called\n");
23 outputFile = NULL;
24 memory = NULL;
25 fflush(stdout);
26 }
28 // destructor
29 AUDIOCORERRR_SERVER_CLASS::~AUDIOCORERRR_SERVER_CLASS()
30 {
31 Cleanup();
32 }
34 // init
35 void
36 AUDIOCORERRR_SERVER_CLASS::Init(PLATFORMS_MODULE p)
37 {
38 parent = p;
39 }
41 // uninit
42 void
43 AUDIOCORERRR_SERVER_CLASS::Uninit()
44 {
45 Cleanup();
46 }
48 // cleanup
49 void
50 AUDIOCORERRR_SERVER_CLASS::Cleanup()
51 {
52 delete serverStub;
53 }
56 //
57 // RRR service methods
58 //
60 UINT32
61 AUDIOCORERRR_SERVER_CLASS::MemoryRequestLoad (UINT32 address)
62 {
63 UINT32 returnVal;
65 if(memory == NULL) {
66 memory = new FUNCP_SIMULATED_MEMORY_CLASS();
67 }
70 memory->Read(0,(UINT64) address, sizeof(UINT32), &returnVal);
71 return returnVal;
72 }
74 void
75 AUDIOCORERRR_SERVER_CLASS::MemoryRequestStore (UINT32 address, UINT32 data)
76 {
77 if(memory == NULL) {
78 memory = new FUNCP_SIMULATED_MEMORY_CLASS();
79 }
81 memory->Write(0,(UINT64) address, sizeof(UINT32), &data);
82 }
84 void
86 AUDIOCORERRR_SERVER_CLASS::SendProcessedStream(UINT16 control, UINT16 data)
87 {
89 AudioProcessorControl audioProcessorControl = (AudioProcessorControl) control;
90 switch(control) {
91 case EndOfFile:
92 if(outputFile != NULL) {
93 fflush(outputFile);
94 fclose(outputFile);
95 outputFile = NULL;
96 } else {
97 outputFile = fopen("out_hw.pcm","w");
98 assert(outputFile);
99 fflush(outputFile);
100 fclose(outputFile);
101 }
103 // Long term this should be in the data portion. But until I have code running, keep it here.
104 CONNECTED_APPLICATION_CLASS::EndSimulation();
105 break;
107 case Data:
108 if(outputFile == NULL) {
109 outputFile = fopen("out_hw.pcm","w");
110 assert(outputFile);
111 }
113 CONNECTED_APPLICATION_CLASS::UpdateSemaphore();
114 fwrite(&data, 2,1 , outputFile);
115 break;
116 }
117 }