Mercurial > pygar
diff 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 |
line wrap: on
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/modules/bluespec/Pygar/core/AudioCoreRRR.cpp~ Tue Apr 27 09:03:28 2010 -0400 1.3 @@ -0,0 +1,118 @@ 1.4 +#include <cstdio> 1.5 +#include <cstdlib> 1.6 +#include <iostream> 1.7 +#include <iomanip> 1.8 +#include <stdio.h> 1.9 +#include <sys/stat.h> 1.10 + 1.11 +#include "asim/rrr/service_ids.h" 1.12 + 1.13 +#include "asim/provides/connected_application.h" 1.14 + 1.15 + 1.16 + 1.17 +using namespace std; 1.18 + 1.19 +// ===== service instantiation ===== 1.20 +AUDIOCORERRR_SERVER_CLASS AUDIOCORERRR_SERVER_CLASS::instance; 1.21 + 1.22 +// constructor 1.23 +AUDIOCORERRR_SERVER_CLASS::AUDIOCORERRR_SERVER_CLASS() : 1.24 + serverStub(new AUDICORERRR_SERVER_STUB_CLASS(this)) 1.25 +{ 1.26 + // instantiate stub 1.27 + printf("AUDIOCORERRR init called\n"); 1.28 + outputFile = NULL; 1.29 + memory = NULL; 1.30 + fflush(stdout); 1.31 +} 1.32 + 1.33 +// destructor 1.34 +AUDIOCORERRR_SERVER_CLASS::~PROCESSORSYSTEMRRR_SERVER_CLASS() 1.35 +{ 1.36 + Cleanup(); 1.37 +} 1.38 + 1.39 +// init 1.40 +void 1.41 +AUDIOCORERRR_SERVER_CLASS::Init(PLATFORMS_MODULE p) 1.42 +{ 1.43 + parent = p; 1.44 +} 1.45 + 1.46 +// uninit 1.47 +void 1.48 +AUDIOCORERRR_SERVER_CLASS::Uninit() 1.49 +{ 1.50 + Cleanup(); 1.51 +} 1.52 + 1.53 +// cleanup 1.54 +void 1.55 +AUDIOCORERRR_SERVER_CLASS::Cleanup() 1.56 +{ 1.57 + delete serverStub; 1.58 +} 1.59 + 1.60 + 1.61 +// 1.62 +// RRR service methods 1.63 +// 1.64 + 1.65 +UINT32 1.66 +AUDIOCORERRR_SERVER_CLASS::MemoryRequestLoad (UINT32 address) 1.67 +{ 1.68 + UINT32 returnVal; 1.69 + 1.70 + if(memory == NULL) { 1.71 + memory = new FUNCP_SIMULATED_MEMORY_CLASS(); 1.72 + } 1.73 + 1.74 + 1.75 + memory->Read(0,(UINT64) address, sizeof(UINT32), &returnVal); 1.76 + return returnVal; 1.77 +} 1.78 + 1.79 +void 1.80 +AUDIOCORERRR_SERVER_CLASS::MemoryRequestStore (UINT32 address, UINT32 data) 1.81 +{ 1.82 + if(memory == NULL) { 1.83 + memory = new FUNCP_SIMULATED_MEMORY_CLASS(); 1.84 + } 1.85 + 1.86 + memory->Write(0,(UINT64) address, sizeof(UINT32), &data); 1.87 + 1.88 +void 1.89 + 1.90 +AUDIOCORERRR_SERVER_CLASS::SendProcessedStream(UINT16 control, UINT16 data) 1.91 +{ 1.92 + 1.93 + AudioProcessorControl audioProcessorControl = (AudioProcessorControl) control; 1.94 + switch(control) { 1.95 + case EndOfFile: 1.96 + if(outputFile != NULL) { 1.97 + fflush(outputFile); 1.98 + fclose(outputFile); 1.99 + outputFile = NULL; 1.100 + } else { 1.101 + outputFile = fopen("out_hw.pcm","w"); 1.102 + assert(outputFile); 1.103 + fflush(outputFile); 1.104 + fclose(outputFile); 1.105 + } 1.106 + 1.107 + // Long term this should be in the data portion. But until I have code running, keep it here. 1.108 + CONNECTED_APPLICATION_CLASS::EndSimulation(); 1.109 + break; 1.110 + 1.111 + case Data: 1.112 + if(outputFile == NULL) { 1.113 + outputFile = fopen("out_hw.pcm","w"); 1.114 + assert(outputFile); 1.115 + } 1.116 + 1.117 + CONNECTED_APPLICATION_CLASS::UpdateSemaphore(); 1.118 + fwrite(&data, 2,1 , outputFile); 1.119 + break; 1.120 + } 1.121 +}