comparison modules/bluespec/Pygar/core/AudioCoreRRR.cpp @ 13:6d461680c6d9 pygar svn.14

[svn r14] more stuff
author punk
date Tue, 27 Apr 2010 09:03:28 -0400
parents
children a1833d9f6e3d
comparison
equal deleted inserted replaced
12:394aa40fd812 13:6d461680c6d9
1 #include <cstdio>
2 #include <cstdlib>
3 #include <iostream>
4 #include <iomanip>
5 #include <stdio.h>
6 #include <sys/stat.h>
7
8 #include "asim/rrr/service_ids.h"
9
10 #include "asim/provides/connected_application.h"
11
12
13
14 using namespace std;
15
16 // ===== service instantiation =====
17 AUDIOCORERRR_SERVER_CLASS AUDIOCORERRR_SERVER_CLASS::instance;
18
19 // constructor
20 AUDIOCORERRR_SERVER_CLASS::AUDIOCORERRR_SERVER_CLASS() :
21 serverStub(new AUDICORERRR_SERVER_STUB_CLASS(this))
22 {
23 // instantiate stub
24 printf("AUDIOCORERRR init called\n");
25 outputFile = NULL;
26 memory = NULL;
27 fflush(stdout);
28 }
29
30 // destructor
31 AUDIOCORERRR_SERVER_CLASS::~AUDIOCORERRR_SERVER_CLASS()
32 {
33 Cleanup();
34 }
35
36 // init
37 void
38 AUDIOCORERRR_SERVER_CLASS::Init(PLATFORMS_MODULE p)
39 {
40 parent = p;
41 }
42
43 // uninit
44 void
45 AUDIOCORERRR_SERVER_CLASS::Uninit()
46 {
47 Cleanup();
48 }
49
50 // cleanup
51 void
52 AUDIOCORERRR_SERVER_CLASS::Cleanup()
53 {
54 delete serverStub;
55 }
56
57
58 //
59 // RRR service methods
60 //
61
62 UINT32
63 AUDIOCORERRR_SERVER_CLASS::MemoryRequestLoad (UINT32 address)
64 {
65 UINT32 returnVal;
66
67 if(memory == NULL) {
68 memory = new FUNCP_SIMULATED_MEMORY_CLASS();
69 }
70
71
72 memory->Read(0,(UINT64) address, sizeof(UINT32), &returnVal);
73 return returnVal;
74 }
75
76 void
77 AUDIOCORERRR_SERVER_CLASS::MemoryRequestStore (UINT32 address, UINT32 data)
78 {
79 if(memory == NULL) {
80 memory = new FUNCP_SIMULATED_MEMORY_CLASS();
81 }
82
83 memory->Write(0,(UINT64) address, sizeof(UINT32), &data);
84
85 void
86
87 AUDIOCORERRR_SERVER_CLASS::SendProcessedStream(UINT16 control, UINT16 data)
88 {
89
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 }
103
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;
107
108 case Data:
109 if(outputFile == NULL) {
110 outputFile = fopen("out_hw.pcm","w");
111 assert(outputFile);
112 }
113
114 CONNECTED_APPLICATION_CLASS::UpdateSemaphore();
115 fwrite(&data, 2,1 , outputFile);
116 break;
117 }
118 }