view modules/bluespec/Pygar/core/AudioCoreRRR.cpp @ 21:cffe0829ce14 pygar svn.22

[svn r22] compiles with memclient commented out
author punk
date Wed, 28 Apr 2010 00:21:02 -0400
parents a1833d9f6e3d
children 0cfbb1e2de22
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"
14 using namespace std;
16 // ===== service instantiation =====
17 AUDIOCORERRR_SERVER_CLASS AUDIOCORERRR_SERVER_CLASS::instance;
19 // constructor
20 AUDIOCORERRR_SERVER_CLASS::AUDIOCORERRR_SERVER_CLASS() :
21 serverStub(new AUDIOCORERRR_SERVER_STUB_CLASS(this))
22 {
23 // instantiate stub
24 printf("AUDIOCORERRR init called\n");
25 outputFile = NULL;
26 memory = NULL;
27 fflush(stdout);
28 }
30 // destructor
31 AUDIOCORERRR_SERVER_CLASS::~AUDIOCORERRR_SERVER_CLASS()
32 {
33 Cleanup();
34 }
36 // init
37 void
38 AUDIOCORERRR_SERVER_CLASS::Init(PLATFORMS_MODULE p)
39 {
40 parent = p;
41 }
43 // uninit
44 void
45 AUDIOCORERRR_SERVER_CLASS::Uninit()
46 {
47 Cleanup();
48 }
50 // cleanup
51 void
52 AUDIOCORERRR_SERVER_CLASS::Cleanup()
53 {
54 delete serverStub;
55 }
58 //
59 // RRR service methods
60 //
62 UINT32
63 AUDIOCORERRR_SERVER_CLASS::MemoryRequestLoad (UINT32 address)
64 {
65 UINT32 returnVal;
67 if(memory == NULL) {
68 memory = new FUNCP_SIMULATED_MEMORY_CLASS();
69 }
72 memory->Read(0,(UINT64) address, sizeof(UINT32), &returnVal);
73 return returnVal;
74 }
76 void
77 AUDIOCORERRR_SERVER_CLASS::MemoryRequestStore (UINT32 address, UINT32 data)
78 {
79 if(memory == NULL) {
80 memory = new FUNCP_SIMULATED_MEMORY_CLASS();
81 }
83 memory->Write(0,(UINT64) address, sizeof(UINT32), &data);
85 void
87 AUDIOCORERRR_SERVER_CLASS::SendProcessedStream(UINT16 control, UINT16 data)
88 {
90 AudioProcessorControl audioProcessorControl = (AudioProcessorControl) control;
91 switch(control) {
92 case EndOfFile:
93 if(outputFile != NULL) {
94 fflush(outputFile);
95 fclose(outputFile);
96 outputFile = NULL;
97 } else {
98 outputFile = fopen("out_hw.pcm","w");
99 assert(outputFile);
100 fflush(outputFile);
101 fclose(outputFile);
102 }
104 // Long term this should be in the data portion. But until I have code running, keep it here.
105 CONNECTED_APPLICATION_CLASS::EndSimulation();
106 break;
108 case Data:
109 if(outputFile == NULL) {
110 outputFile = fopen("out_hw.pcm","w");
111 assert(outputFile);
112 }
114 CONNECTED_APPLICATION_CLASS::UpdateSemaphore();
115 fwrite(&data, 2,1 , outputFile);
116 break;
117 }
118 }