annotate modules/bluespec/Pygar/core/#AudioCoreRRR.cpp# @ 52:49049f97312c pygar svn.53

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