annotate modules/bluespec/Pygar/core/AudioCoreRRR.cpp @ 21:cffe0829ce14 pygar svn.22

[svn r22] compiles with memclient commented out
author punk
date Wed, 28 Apr 2010 00:21:02 -0400
parents a1833d9f6e3d
children 0cfbb1e2de22
rev   line source
punk@13 1 #include <cstdio>
punk@13 2 #include <cstdlib>
punk@13 3 #include <iostream>
punk@13 4 #include <iomanip>
punk@13 5 #include <stdio.h>
punk@13 6 #include <sys/stat.h>
punk@13 7
punk@13 8 #include "asim/rrr/service_ids.h"
punk@13 9
punk@13 10 #include "asim/provides/connected_application.h"
punk@13 11
punk@13 12
punk@13 13
punk@13 14 using namespace std;
punk@13 15
punk@13 16 // ===== service instantiation =====
punk@13 17 AUDIOCORERRR_SERVER_CLASS AUDIOCORERRR_SERVER_CLASS::instance;
punk@13 18
punk@13 19 // constructor
punk@13 20 AUDIOCORERRR_SERVER_CLASS::AUDIOCORERRR_SERVER_CLASS() :
punk@15 21 serverStub(new AUDIOCORERRR_SERVER_STUB_CLASS(this))
punk@13 22 {
punk@13 23 // instantiate stub
punk@13 24 printf("AUDIOCORERRR init called\n");
punk@13 25 outputFile = NULL;
punk@13 26 memory = NULL;
punk@13 27 fflush(stdout);
punk@13 28 }
punk@13 29
punk@13 30 // destructor
punk@13 31 AUDIOCORERRR_SERVER_CLASS::~AUDIOCORERRR_SERVER_CLASS()
punk@13 32 {
punk@13 33 Cleanup();
punk@13 34 }
punk@13 35
punk@13 36 // init
punk@13 37 void
punk@13 38 AUDIOCORERRR_SERVER_CLASS::Init(PLATFORMS_MODULE p)
punk@13 39 {
punk@13 40 parent = p;
punk@13 41 }
punk@13 42
punk@13 43 // uninit
punk@13 44 void
punk@13 45 AUDIOCORERRR_SERVER_CLASS::Uninit()
punk@13 46 {
punk@13 47 Cleanup();
punk@13 48 }
punk@13 49
punk@13 50 // cleanup
punk@13 51 void
punk@13 52 AUDIOCORERRR_SERVER_CLASS::Cleanup()
punk@13 53 {
punk@13 54 delete serverStub;
punk@13 55 }
punk@13 56
punk@13 57
punk@13 58 //
punk@13 59 // RRR service methods
punk@13 60 //
punk@13 61
punk@13 62 UINT32
punk@13 63 AUDIOCORERRR_SERVER_CLASS::MemoryRequestLoad (UINT32 address)
punk@13 64 {
punk@13 65 UINT32 returnVal;
punk@13 66
punk@13 67 if(memory == NULL) {
punk@13 68 memory = new FUNCP_SIMULATED_MEMORY_CLASS();
punk@13 69 }
punk@13 70
punk@13 71
punk@13 72 memory->Read(0,(UINT64) address, sizeof(UINT32), &returnVal);
punk@13 73 return returnVal;
punk@13 74 }
punk@13 75
punk@13 76 void
punk@13 77 AUDIOCORERRR_SERVER_CLASS::MemoryRequestStore (UINT32 address, UINT32 data)
punk@13 78 {
punk@13 79 if(memory == NULL) {
punk@13 80 memory = new FUNCP_SIMULATED_MEMORY_CLASS();
punk@13 81 }
punk@13 82
punk@13 83 memory->Write(0,(UINT64) address, sizeof(UINT32), &data);
punk@13 84
punk@13 85 void
punk@13 86
punk@13 87 AUDIOCORERRR_SERVER_CLASS::SendProcessedStream(UINT16 control, UINT16 data)
punk@13 88 {
punk@13 89
punk@13 90 AudioProcessorControl audioProcessorControl = (AudioProcessorControl) control;
punk@13 91 switch(control) {
punk@13 92 case EndOfFile:
punk@13 93 if(outputFile != NULL) {
punk@13 94 fflush(outputFile);
punk@13 95 fclose(outputFile);
punk@13 96 outputFile = NULL;
punk@13 97 } else {
punk@13 98 outputFile = fopen("out_hw.pcm","w");
punk@13 99 assert(outputFile);
punk@13 100 fflush(outputFile);
punk@13 101 fclose(outputFile);
punk@13 102 }
punk@13 103
punk@13 104 // Long term this should be in the data portion. But until I have code running, keep it here.
punk@13 105 CONNECTED_APPLICATION_CLASS::EndSimulation();
punk@13 106 break;
punk@13 107
punk@13 108 case Data:
punk@13 109 if(outputFile == NULL) {
punk@13 110 outputFile = fopen("out_hw.pcm","w");
punk@13 111 assert(outputFile);
punk@13 112 }
punk@13 113
punk@13 114 CONNECTED_APPLICATION_CLASS::UpdateSemaphore();
punk@13 115 fwrite(&data, 2,1 , outputFile);
punk@13 116 break;
punk@13 117 }
punk@13 118 }