annotate modules/bluespec/Pygar/core/AudioCoreRRR.cpp @ 70:bbd58fb592c9 pygar svn.71

[svn r71] better benchmarks
author rlm
date Wed, 12 May 2010 00:14:01 -0400
parents cf8bb3038cbd
children
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 using namespace std;
punk@13 13
punk@13 14 // ===== service instantiation =====
punk@13 15 AUDIOCORERRR_SERVER_CLASS AUDIOCORERRR_SERVER_CLASS::instance;
punk@13 16
punk@13 17 // constructor
punk@13 18 AUDIOCORERRR_SERVER_CLASS::AUDIOCORERRR_SERVER_CLASS() :
punk@15 19 serverStub(new AUDIOCORERRR_SERVER_STUB_CLASS(this))
punk@13 20 {
punk@13 21 // instantiate stub
rlm@23 22
punk@13 23 outputFile = NULL;
punk@13 24 memory = NULL;
punk@13 25 fflush(stdout);
punk@52 26 count = 0;
punk@65 27 printf("ReceiveSide Created\n");
punk@65 28
punk@13 29 }
punk@13 30
punk@13 31 // destructor
punk@13 32 AUDIOCORERRR_SERVER_CLASS::~AUDIOCORERRR_SERVER_CLASS()
punk@13 33 {
rlm@23 34 printf("rlm: AUDIOCORERRR_SERVER_CLASS::~AUDIOCORERRR_SERVER_CLASS()\n");
punk@13 35 Cleanup();
punk@13 36 }
punk@13 37
punk@13 38 // init
punk@13 39 void
punk@13 40 AUDIOCORERRR_SERVER_CLASS::Init(PLATFORMS_MODULE p)
punk@13 41 {
rlm@23 42 printf("rlm: AUDIOCORERRR_SERVER_CLASS::Init(PLATFORMS_MODULE p)\n");
rlm@23 43 parent = p;
punk@13 44 }
punk@13 45
punk@13 46 // uninit
punk@13 47 void
punk@13 48 AUDIOCORERRR_SERVER_CLASS::Uninit()
punk@13 49 {
rlm@23 50 printf("rlm: AUDIOCORERRR_SERVER_CLASS::Uninit()\n");
rlm@23 51 Cleanup();
punk@13 52 }
punk@13 53
punk@13 54 // cleanup
punk@13 55 void
punk@13 56 AUDIOCORERRR_SERVER_CLASS::Cleanup()
punk@13 57 {
rlm@23 58 printf("rlm: AUDIOCORERRR_SERVER_CLASS::Cleanup() \n\n");
rlm@23 59 delete serverStub;
punk@13 60 }
punk@13 61
punk@13 62
punk@13 63 //
punk@13 64 // RRR service methods
punk@13 65 //
punk@13 66
punk@33 67 /* Not used by scratchpad
punk@13 68 UINT32
punk@13 69 AUDIOCORERRR_SERVER_CLASS::MemoryRequestLoad (UINT32 address)
punk@13 70 {
punk@13 71 UINT32 returnVal;
rlm@23 72 printf("rlm: AUDIOCORERRR_SERVER_CLASS::MemoryRequestLoad (UINT32 address)\n");
punk@13 73 if(memory == NULL) {
punk@13 74 memory = new FUNCP_SIMULATED_MEMORY_CLASS();
punk@13 75 }
punk@13 76
punk@13 77
punk@13 78 memory->Read(0,(UINT64) address, sizeof(UINT32), &returnVal);
punk@13 79 return returnVal;
punk@13 80 }
punk@13 81
punk@13 82 void
punk@13 83 AUDIOCORERRR_SERVER_CLASS::MemoryRequestStore (UINT32 address, UINT32 data)
punk@13 84 {
rlm@23 85 printf("rlm: AUDIOCORERRR_SERVER_CLASS::MemoryRequestStore (UINT32 address, UINT32 data)\n");
punk@13 86 if(memory == NULL) {
punk@13 87 memory = new FUNCP_SIMULATED_MEMORY_CLASS();
punk@13 88 }
punk@13 89
punk@13 90 memory->Write(0,(UINT64) address, sizeof(UINT32), &data);
punk@22 91 }
punk@33 92 */
punk@13 93
punk@13 94 void
punk@52 95 AUDIOCORERRR_SERVER_CLASS::SendTerminate(UINT32 flag)
punk@52 96 {
punk@52 97 printf("lsp: Received Process Termination\n");
punk@52 98 CONNECTED_APPLICATION_CLASS::EndSimulation();
punk@52 99 }
punk@52 100
punk@52 101 void
punk@13 102
punk@13 103 AUDIOCORERRR_SERVER_CLASS::SendProcessedStream(UINT16 control, UINT16 data)
punk@13 104 {
punk@13 105
punk@25 106 // printf("rlm: SendProcessedStream called,\n");
punk@13 107 AudioProcessorControl audioProcessorControl = (AudioProcessorControl) control;
punk@13 108 switch(control) {
punk@13 109 case EndOfFile:
punk@13 110 if(outputFile != NULL) {
rlm@23 111 printf("rlm: FILE is NULL\n");
punk@13 112 fflush(outputFile);
punk@13 113 fclose(outputFile);
punk@13 114 outputFile = NULL;
punk@13 115 } else {
rlm@23 116 printf("rlm: Opening file for output.\n");
punk@13 117 outputFile = fopen("out_hw.pcm","w");
punk@13 118 assert(outputFile);
punk@13 119 fflush(outputFile);
punk@13 120 fclose(outputFile);
punk@13 121 }
punk@13 122
punk@13 123 // Long term this should be in the data portion. But until I have code running, keep it here.
punk@53 124 // count++;
punk@53 125 //if (count == 2)
punk@52 126 CONNECTED_APPLICATION_CLASS::EndSimulation();
punk@13 127 break;
punk@13 128
punk@13 129 case Data:
punk@13 130 if(outputFile == NULL) {
punk@13 131 outputFile = fopen("out_hw.pcm","w");
punk@13 132 assert(outputFile);
punk@13 133 }
punk@13 134
rlm@23 135 CONNECTED_APPLICATION_CLASS::UpdateSemaphore();
punk@65 136 printf("rlm: writing data to out_hw.pcm\n");
punk@13 137 fwrite(&data, 2,1 , outputFile);
punk@13 138 break;
punk@13 139 }
punk@13 140 }