view modules/bluespec/Pygar/core/AudioCoreRRR.cpp @ 38:05598d745f99 pygar svn.39

[svn r39] fixed audiocorepipe
author punk
date Tue, 04 May 2010 19:27:38 -0400
parents 2c8166d205d5
children 49049f97312c
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
23 printf("rlm: init called\n\n");
24 outputFile = NULL;
25 memory = NULL;
26 fflush(stdout);
27 }
29 // destructor
30 AUDIOCORERRR_SERVER_CLASS::~AUDIOCORERRR_SERVER_CLASS()
31 {
32 printf("rlm: AUDIOCORERRR_SERVER_CLASS::~AUDIOCORERRR_SERVER_CLASS()\n");
33 Cleanup();
34 }
36 // init
37 void
38 AUDIOCORERRR_SERVER_CLASS::Init(PLATFORMS_MODULE p)
39 {
40 printf("rlm: AUDIOCORERRR_SERVER_CLASS::Init(PLATFORMS_MODULE p)\n");
41 parent = p;
42 }
44 // uninit
45 void
46 AUDIOCORERRR_SERVER_CLASS::Uninit()
47 {
48 printf("rlm: AUDIOCORERRR_SERVER_CLASS::Uninit()\n");
49 Cleanup();
50 }
52 // cleanup
53 void
54 AUDIOCORERRR_SERVER_CLASS::Cleanup()
55 {
56 printf("rlm: AUDIOCORERRR_SERVER_CLASS::Cleanup() \n\n");
57 delete serverStub;
58 }
61 //
62 // RRR service methods
63 //
65 /* Not used by scratchpad
66 UINT32
67 AUDIOCORERRR_SERVER_CLASS::MemoryRequestLoad (UINT32 address)
68 {
69 UINT32 returnVal;
70 printf("rlm: AUDIOCORERRR_SERVER_CLASS::MemoryRequestLoad (UINT32 address)\n");
71 if(memory == NULL) {
72 memory = new FUNCP_SIMULATED_MEMORY_CLASS();
73 }
76 memory->Read(0,(UINT64) address, sizeof(UINT32), &returnVal);
77 return returnVal;
78 }
80 void
81 AUDIOCORERRR_SERVER_CLASS::MemoryRequestStore (UINT32 address, UINT32 data)
82 {
83 printf("rlm: AUDIOCORERRR_SERVER_CLASS::MemoryRequestStore (UINT32 address, UINT32 data)\n");
84 if(memory == NULL) {
85 memory = new FUNCP_SIMULATED_MEMORY_CLASS();
86 }
88 memory->Write(0,(UINT64) address, sizeof(UINT32), &data);
89 }
90 */
92 void
94 AUDIOCORERRR_SERVER_CLASS::SendProcessedStream(UINT16 control, UINT16 data)
95 {
97 // printf("rlm: SendProcessedStream called,\n");
98 AudioProcessorControl audioProcessorControl = (AudioProcessorControl) control;
99 switch(control) {
100 case EndOfFile:
101 if(outputFile != NULL) {
102 printf("rlm: FILE is NULL\n");
103 fflush(outputFile);
104 fclose(outputFile);
105 outputFile = NULL;
106 } else {
107 printf("rlm: Opening file for output.\n");
108 outputFile = fopen("out_hw.pcm","w");
109 assert(outputFile);
110 fflush(outputFile);
111 fclose(outputFile);
112 }
114 // Long term this should be in the data portion. But until I have code running, keep it here.
115 CONNECTED_APPLICATION_CLASS::EndSimulation();
116 break;
118 case Data:
119 if(outputFile == NULL) {
120 outputFile = fopen("out_hw.pcm","w");
121 assert(outputFile);
122 }
124 CONNECTED_APPLICATION_CLASS::UpdateSemaphore();
125 // printf("rlm: writing data to out_hw.pcm\n");
126 fwrite(&data, 2,1 , outputFile);
127 break;
128 }
129 }