Mercurial > pygar
comparison modules/bluespec/Pygar/core/#AudioCoreRRR.cpp# @ 26:f5dfbe28fa59 pygar svn.27
[svn r27] Fixed Instruction trace issue.
author | punk |
---|---|
date | Fri, 30 Apr 2010 09:03:10 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
25:220c14f5963c | 26:f5dfbe28fa59 |
---|---|
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 using namespace std; | |
13 | |
14 // ===== service instantiation ===== | |
15 AUDIOCORERRR_SERVER_CLASS AUDIOCORERRR_SERVER_CLASS::instance; | |
16 | |
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 } | |
27 | |
28 // destructor | |
29 AUDIOCORERRR_SERVER_CLASS::~AUDIOCORERRR_SERVER_CLASS() | |
30 { | |
31 Cleanup(); | |
32 } | |
33 | |
34 // init | |
35 void | |
36 AUDIOCORERRR_SERVER_CLASS::Init(PLATFORMS_MODULE p) | |
37 { | |
38 parent = p; | |
39 } | |
40 | |
41 // uninit | |
42 void | |
43 AUDIOCORERRR_SERVER_CLASS::Uninit() | |
44 { | |
45 Cleanup(); | |
46 } | |
47 | |
48 // cleanup | |
49 void | |
50 AUDIOCORERRR_SERVER_CLASS::Cleanup() | |
51 { | |
52 delete serverStub; | |
53 } | |
54 | |
55 | |
56 // | |
57 // RRR service methods | |
58 // | |
59 | |
60 UINT32 | |
61 AUDIOCORERRR_SERVER_CLASS::MemoryRequestLoad (UINT32 address) | |
62 { | |
63 UINT32 returnVal; | |
64 | |
65 if(memory == NULL) { | |
66 memory = new FUNCP_SIMULATED_MEMORY_CLASS(); | |
67 } | |
68 | |
69 | |
70 memory->Read(0,(UINT64) address, sizeof(UINT32), &returnVal); | |
71 return returnVal; | |
72 } | |
73 | |
74 void | |
75 AUDIOCORERRR_SERVER_CLASS::MemoryRequestStore (UINT32 address, UINT32 data) | |
76 { | |
77 if(memory == NULL) { | |
78 memory = new FUNCP_SIMULATED_MEMORY_CLASS(); | |
79 } | |
80 | |
81 memory->Write(0,(UINT64) address, sizeof(UINT32), &data); | |
82 } | |
83 | |
84 void | |
85 AUDIOCORERRR_SERVER_CLASS::SendProcessedStream(UINT16 control, UINT16 data) | |
86 { | |
87 | |
88 AudioProcessorControl audioProcessorControl = (AudioProcessorControl) control; | |
89 switch(control) { | |
90 case EndOfFile: | |
91 if(outputFile != NULL) { | |
92 fflush(outputFile); | |
93 fclose(outputFile); | |
94 outputFile = NULL; | |
95 } else { | |
96 outputFile = fopen("out_hw.pcm","w"); | |
97 assert(outputFile); | |
98 fflush(outputFile); | |
99 fclose(outputFile); | |
100 } | |
101 | |
102 // Long term this should be in the data portion. But until I have code running, keep it here. | |
103 CONNECTED_APPLICATION_CLASS::EndSimulation(); | |
104 break; | |
105 | |
106 case Data: | |
107 if(outputFile == NULL) { | |
108 outputFile = fopen("out_hw.pcm","w"); | |
109 assert(outputFile); | |
110 } | |
111 | |
112 CONNECTED_APPLICATION_CLASS::UpdateSemaphore(); | |
113 fwrite(&data, 2,1 , outputFile); | |
114 break; | |
115 } | |
116 } |