Mercurial > pygar
view modules/bluespec/Pygar/core/#AudioCoreRRR.cpp# @ 47:97d1959f7c5c pygar svn.48
[svn r48] changed sctipt to use our own programs, changed rlp.wav and rlp1.wav to be shorter
author | rlm |
---|---|
date | Wed, 05 May 2010 13:23:58 -0400 |
parents | f5dfbe28fa59 |
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 // constructor18 AUDIOCORERRR_SERVER_CLASS::AUDIOCORERRR_SERVER_CLASS() :19 serverStub(new AUDIOCORERRR_SERVER_STUB_CLASS(this))20 {21 // instantiate stub22 printf("AUDIOCORERRR init called\n");23 outputFile = NULL;24 memory = NULL;25 fflush(stdout);26 }28 // destructor29 AUDIOCORERRR_SERVER_CLASS::~AUDIOCORERRR_SERVER_CLASS()30 {31 Cleanup();32 }34 // init35 void36 AUDIOCORERRR_SERVER_CLASS::Init(PLATFORMS_MODULE p)37 {38 parent = p;39 }41 // uninit42 void43 AUDIOCORERRR_SERVER_CLASS::Uninit()44 {45 Cleanup();46 }48 // cleanup49 void50 AUDIOCORERRR_SERVER_CLASS::Cleanup()51 {52 delete serverStub;53 }56 //57 // RRR service methods58 //60 UINT3261 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 void75 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 void85 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 }