Mercurial > pygar
view modules/bluespec/Pygar/core/AudioCoreRRR.cpp @ 15:a1833d9f6e3d pygar svn.16
[svn r16] Recent
author | punk |
---|---|
date | Tue, 27 Apr 2010 13:11:45 -0400 |
parents | 6d461680c6d9 |
children | 0cfbb1e2de22 |
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"14 using namespace std;16 // ===== service instantiation =====17 AUDIOCORERRR_SERVER_CLASS AUDIOCORERRR_SERVER_CLASS::instance;19 // constructor20 AUDIOCORERRR_SERVER_CLASS::AUDIOCORERRR_SERVER_CLASS() :21 serverStub(new AUDIOCORERRR_SERVER_STUB_CLASS(this))22 {23 // instantiate stub24 printf("AUDIOCORERRR init called\n");25 outputFile = NULL;26 memory = NULL;27 fflush(stdout);28 }30 // destructor31 AUDIOCORERRR_SERVER_CLASS::~AUDIOCORERRR_SERVER_CLASS()32 {33 Cleanup();34 }36 // init37 void38 AUDIOCORERRR_SERVER_CLASS::Init(PLATFORMS_MODULE p)39 {40 parent = p;41 }43 // uninit44 void45 AUDIOCORERRR_SERVER_CLASS::Uninit()46 {47 Cleanup();48 }50 // cleanup51 void52 AUDIOCORERRR_SERVER_CLASS::Cleanup()53 {54 delete serverStub;55 }58 //59 // RRR service methods60 //62 UINT3263 AUDIOCORERRR_SERVER_CLASS::MemoryRequestLoad (UINT32 address)64 {65 UINT32 returnVal;67 if(memory == NULL) {68 memory = new FUNCP_SIMULATED_MEMORY_CLASS();69 }72 memory->Read(0,(UINT64) address, sizeof(UINT32), &returnVal);73 return returnVal;74 }76 void77 AUDIOCORERRR_SERVER_CLASS::MemoryRequestStore (UINT32 address, UINT32 data)78 {79 if(memory == NULL) {80 memory = new FUNCP_SIMULATED_MEMORY_CLASS();81 }83 memory->Write(0,(UINT64) address, sizeof(UINT32), &data);85 void87 AUDIOCORERRR_SERVER_CLASS::SendProcessedStream(UINT16 control, UINT16 data)88 {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 }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;108 case Data:109 if(outputFile == NULL) {110 outputFile = fopen("out_hw.pcm","w");111 assert(outputFile);112 }114 CONNECTED_APPLICATION_CLASS::UpdateSemaphore();115 fwrite(&data, 2,1 , outputFile);116 break;117 }118 }