Mercurial > pygar
view modules/bluespec/Pygar/core/AudioCoreRRR.cpp @ 31:f41eef1bebfc pygar svn.32
[svn r32] Attempting to run soft core and audio
author | punk |
---|---|
date | Sat, 01 May 2010 11:50:20 -0400 |
parents | 220c14f5963c |
children | 2c8166d205d5 |
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 stub23 printf("rlm: init called\n\n");24 outputFile = NULL;25 memory = NULL;26 fflush(stdout);27 }29 // destructor30 AUDIOCORERRR_SERVER_CLASS::~AUDIOCORERRR_SERVER_CLASS()31 {32 printf("rlm: AUDIOCORERRR_SERVER_CLASS::~AUDIOCORERRR_SERVER_CLASS()\n");33 Cleanup();34 }36 // init37 void38 AUDIOCORERRR_SERVER_CLASS::Init(PLATFORMS_MODULE p)39 {40 printf("rlm: AUDIOCORERRR_SERVER_CLASS::Init(PLATFORMS_MODULE p)\n");41 parent = p;42 }44 // uninit45 void46 AUDIOCORERRR_SERVER_CLASS::Uninit()47 {48 printf("rlm: AUDIOCORERRR_SERVER_CLASS::Uninit()\n");49 Cleanup();50 }52 // cleanup53 void54 AUDIOCORERRR_SERVER_CLASS::Cleanup()55 {56 printf("rlm: AUDIOCORERRR_SERVER_CLASS::Cleanup() \n\n");57 delete serverStub;58 }61 //62 // RRR service methods63 //65 UINT3266 AUDIOCORERRR_SERVER_CLASS::MemoryRequestLoad (UINT32 address)67 {68 UINT32 returnVal;69 printf("rlm: AUDIOCORERRR_SERVER_CLASS::MemoryRequestLoad (UINT32 address)\n");70 if(memory == NULL) {71 memory = new FUNCP_SIMULATED_MEMORY_CLASS();72 }75 memory->Read(0,(UINT64) address, sizeof(UINT32), &returnVal);76 return returnVal;77 }79 void80 AUDIOCORERRR_SERVER_CLASS::MemoryRequestStore (UINT32 address, UINT32 data)81 {82 printf("rlm: AUDIOCORERRR_SERVER_CLASS::MemoryRequestStore (UINT32 address, UINT32 data)\n");83 if(memory == NULL) {84 memory = new FUNCP_SIMULATED_MEMORY_CLASS();85 }87 memory->Write(0,(UINT64) address, sizeof(UINT32), &data);88 }90 void92 AUDIOCORERRR_SERVER_CLASS::SendProcessedStream(UINT16 control, UINT16 data)93 {95 // printf("rlm: SendProcessedStream called,\n");96 AudioProcessorControl audioProcessorControl = (AudioProcessorControl) control;97 switch(control) {98 case EndOfFile:99 if(outputFile != NULL) {100 printf("rlm: FILE is NULL\n");101 fflush(outputFile);102 fclose(outputFile);103 outputFile = NULL;104 } else {105 printf("rlm: Opening file for output.\n");106 outputFile = fopen("out_hw.pcm","w");107 assert(outputFile);108 fflush(outputFile);109 fclose(outputFile);110 }112 // Long term this should be in the data portion. But until I have code running, keep it here.113 CONNECTED_APPLICATION_CLASS::EndSimulation();114 break;116 case Data:117 if(outputFile == NULL) {118 outputFile = fopen("out_hw.pcm","w");119 assert(outputFile);120 }122 CONNECTED_APPLICATION_CLASS::UpdateSemaphore();123 // printf("rlm: writing data to out_hw.pcm\n");124 fwrite(&data, 2,1 , outputFile);125 break;126 }127 }