diff modules/bluespec/Pygar/core/#AudioCoreRRR.cpp# @ 26:f5dfbe28fa59 pygar svn.27

[svn r27] Fixed Instruction trace issue.
author punk
date Fri, 30 Apr 2010 09:03:10 -0400
parents
children
line wrap: on
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/modules/bluespec/Pygar/core/#AudioCoreRRR.cpp#	Fri Apr 30 09:03:10 2010 -0400
     1.3 @@ -0,0 +1,116 @@
     1.4 +#include <cstdio>
     1.5 +#include <cstdlib>
     1.6 +#include <iostream>
     1.7 +#include <iomanip>
     1.8 +#include <stdio.h>
     1.9 +#include <sys/stat.h>
    1.10 +
    1.11 +#include "asim/rrr/service_ids.h"
    1.12 +
    1.13 +#include "asim/provides/connected_application.h"
    1.14 +
    1.15 +using namespace std;
    1.16 +
    1.17 +// ===== service instantiation =====
    1.18 +AUDIOCORERRR_SERVER_CLASS AUDIOCORERRR_SERVER_CLASS::instance;
    1.19 +
    1.20 +// constructor
    1.21 +AUDIOCORERRR_SERVER_CLASS::AUDIOCORERRR_SERVER_CLASS() :
    1.22 +  serverStub(new AUDIOCORERRR_SERVER_STUB_CLASS(this))
    1.23 +{
    1.24 +    // instantiate stub
    1.25 +    printf("AUDIOCORERRR init called\n");
    1.26 +    outputFile = NULL;
    1.27 +    memory = NULL;
    1.28 +    fflush(stdout);
    1.29 +}
    1.30 +
    1.31 +// destructor
    1.32 +AUDIOCORERRR_SERVER_CLASS::~AUDIOCORERRR_SERVER_CLASS()
    1.33 +{
    1.34 +    Cleanup();
    1.35 +}
    1.36 +
    1.37 +// init
    1.38 +void
    1.39 +AUDIOCORERRR_SERVER_CLASS::Init(PLATFORMS_MODULE p)
    1.40 +{
    1.41 +    parent = p;
    1.42 +}
    1.43 +
    1.44 +// uninit
    1.45 +void
    1.46 +AUDIOCORERRR_SERVER_CLASS::Uninit()
    1.47 +{
    1.48 +    Cleanup();
    1.49 +}
    1.50 +
    1.51 +// cleanup
    1.52 +void
    1.53 +AUDIOCORERRR_SERVER_CLASS::Cleanup()
    1.54 +{
    1.55 +    delete serverStub;
    1.56 +}
    1.57 +
    1.58 +
    1.59 +//
    1.60 +// RRR service methods
    1.61 +//
    1.62 +
    1.63 +UINT32
    1.64 +AUDIOCORERRR_SERVER_CLASS::MemoryRequestLoad (UINT32 address)
    1.65 +{
    1.66 +  UINT32 returnVal;
    1.67 +  
    1.68 +  if(memory == NULL) {
    1.69 +    memory = new FUNCP_SIMULATED_MEMORY_CLASS();
    1.70 +  }
    1.71 +
    1.72 + 
    1.73 +  memory->Read(0,(UINT64) address, sizeof(UINT32), &returnVal); 
    1.74 +  return returnVal;
    1.75 +}
    1.76 +
    1.77 +void
    1.78 +AUDIOCORERRR_SERVER_CLASS::MemoryRequestStore (UINT32 address, UINT32 data)
    1.79 +{
    1.80 +  if(memory == NULL) {
    1.81 +    memory = new FUNCP_SIMULATED_MEMORY_CLASS();
    1.82 +  }
    1.83 +
    1.84 +  memory->Write(0,(UINT64) address, sizeof(UINT32), &data); 
    1.85 +}
    1.86 +
    1.87 +void
    1.88 +AUDIOCORERRR_SERVER_CLASS::SendProcessedStream(UINT16 control, UINT16 data)
    1.89 +{
    1.90 +
    1.91 +  AudioProcessorControl audioProcessorControl = (AudioProcessorControl) control;
    1.92 +  switch(control) {
    1.93 +    case EndOfFile:
    1.94 +      if(outputFile != NULL) {
    1.95 +        fflush(outputFile);
    1.96 +        fclose(outputFile);
    1.97 +        outputFile = NULL;
    1.98 +      } else {
    1.99 +        outputFile = fopen("out_hw.pcm","w");
   1.100 +        assert(outputFile);
   1.101 +        fflush(outputFile);
   1.102 +        fclose(outputFile);
   1.103 +      }
   1.104 +
   1.105 +      // Long term this should be in the data portion.  But until I have code running, keep it here.
   1.106 +      CONNECTED_APPLICATION_CLASS::EndSimulation(); 
   1.107 +    break;
   1.108 +
   1.109 +    case Data:
   1.110 +      if(outputFile == NULL) {
   1.111 +        outputFile = fopen("out_hw.pcm","w");
   1.112 +        assert(outputFile);
   1.113 +      }
   1.114 +
   1.115 +      CONNECTED_APPLICATION_CLASS::UpdateSemaphore();  
   1.116 +      fwrite(&data, 2,1 , outputFile);
   1.117 +    break;
   1.118 +  }
   1.119 +}