view 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
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
85 AUDIOCORERRR_SERVER_CLASS::SendProcessedStream(UINT16 control, UINT16 data)
86 {
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 }
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;
106 case Data:
107 if(outputFile == NULL) {
108 outputFile = fopen("out_hw.pcm","w");
109 assert(outputFile);
110 }
112 CONNECTED_APPLICATION_CLASS::UpdateSemaphore();
113 fwrite(&data, 2,1 , outputFile);
114 break;
115 }
116 }