changeset 16:7e1510b47336 pygar svn.17

[svn r17] added rest of items for core
author punk
date Tue, 27 Apr 2010 22:54:50 -0400
parents a1833d9f6e3d
children 9d1f38722f5b
files #AudioProcessor.cpp# #AudioProcessorRRR.rrr# #AudioProcessorTypes.bsv# AudioPipelineDefault.bsv AudioProcessor.bsv AudioProcessor.cpp AudioProcessor.h AudioProcessorRRR.cpp AudioProcessorRRR.h AudioProcessorRRR.rrr AudioProcessorTypes.bsv DFT.cpp SndfileWavUtil.cpp SndfileWavUtil.h audio_pipeline_default.awb audio_processor_hardware_system.awb audio_processor_software_system.awb audio_processor_types.awb common/PathTypes.bsv common/RoutingTable.bsv config/pm/Pygar/fullSystem/audio_core_exe.apm modules/bluespec/Pygar/core/audioPipeTypes.bsv modules/bluespec/Pygar/lab4/processor_library.awr
diffstat 22 files changed, 1131 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/#AudioProcessor.cpp#	Tue Apr 27 22:54:50 2010 -0400
     1.3 @@ -0,0 +1,104 @@
     1.4 +#include <stdio.h>
     1.5 +#include <pthread.h>
     1.6 +#include <semaphore.h>
     1.7 +
     1.8 +#include "asim/provides/connected_application.h"
     1.9 +//#include "asim/provides/SndfileWavUtil.h"
    1.10 +
    1.11 +#include "asim/rrr/client_stub_AUDIOPROCESSORRRR.h"
    1.12 +
    1.13 +using namespace std;
    1.14 +
    1.15 +pthread_mutex_t CONNECTED_APPLICATION_CLASS::lock;
    1.16 +pthread_cond_t  CONNECTED_APPLICATION_CLASS::cond;
    1.17 +sem_t CONNECTED_APPLICATION_CLASS::throttle;
    1.18 +
    1.19 +// constructor
    1.20 +CONNECTED_APPLICATION_CLASS::CONNECTED_APPLICATION_CLASS(VIRTUAL_PLATFORM vp) :
    1.21 +    clientStub(new AUDIOPROCESSORRRR_CLIENT_STUB_CLASS(this))
    1.22 +{
    1.23 +œôøº}
    1.24 +œôøºœôøºœôøº
    1.25 +// destructor
    1.26 +CONNECTED_APPLICATION_CLASS::~CONNECTED_APPLICATION_CLASS()
    1.27 +{
    1.28 +}
    1.29 +
    1.30 +// init
    1.31 +void
    1.32 +CONNECTED_APPLICATION_CLASS::Init()
    1.33 +{
    1.34 +
    1.35 +  pthread_mutex_init(&lock, NULL);
    1.36 +  pthread_cond_init(&cond, NULL);
    1.37 +  sem_init(&throttle, 0, 64);
    1.38 +
    1.39 +}
    1.40 +
    1.41 +void
    1.42 +CONNECTED_APPLICATION_CLASS::UpdateSemaphore()
    1.43 +{
    1.44 +  sem_post(&throttle);
    1.45 +}
    1.46 +
    1.47 +void
    1.48 +CONNECTED_APPLICATION_CLASS::EndSimulation()
    1.49 +{
    1.50 +  printf("EndSimulation Called\n");
    1.51 +  fflush(stdout);
    1.52 +  pthread_mutex_lock(&lock);
    1.53 +  // Do something about the race occuring here
    1.54 +  pthread_cond_signal(&cond); 
    1.55 +  pthread_mutex_unlock(&lock);
    1.56 +  printf("EndSimulation done\n");
    1.57 +  fflush(stdout);  
    1.58 +}
    1.59 +
    1.60 +// main
    1.61 +void
    1.62 +CONNECTED_APPLICATION_CLASS::Main()
    1.63 +{
    1.64 +  FILE *inputFile;
    1.65 +  UINT16 sample;
    1.66 +  
    1.67 +  // Convert input wav to pcm
    1.68 +  generate_pcm("input.wav","input.pcm");
    1.69 +
    1.70 +  //Send data to the machine here.
    1.71 +  inputFile = fopen("input.pcm","r");
    1.72 +  assert(inputFile);
    1.73 +
    1.74 +
    1.75 +  int count = 0;
    1.76 +
    1.77 +  printf("main: about to enter loop %d\n", count);  
    1.78 +
    1.79 +  while(fread(&sample, 2, 1, inputFile)) {
    1.80 +    if(count%1000 == 0)
    1.81 +      printf("main: %d\n", count);
    1.82 +    count++;
    1.83 +    sem_wait(&throttle);
    1.84 +    clientStub->SendUnprocessedStream(Data,(UINT32)sample);
    1.85 +  } 
    1.86 +
    1.87 +  printf("main: out of loop\n");
    1.88 +
    1.89 +  // Need to put lock here to prevent potential race condition
    1.90 +  pthread_mutex_lock(&lock);
    1.91 +  clientStub->SendUnprocessedStream(EndOfFile,0);
    1.92 +
    1.93 +  printf("main: wait for end of file\n");
    1.94 +
    1.95 +  pthread_cond_wait(&cond, &lock);
    1.96 +  pthread_mutex_unlock(&lock);
    1.97 +
    1.98 +  printf("main: lastt data out\n");
    1.99 +
   1.100 +  // Convert input wav to pcm
   1.101 +  generate_wav("out_hw.pcm","input.wav","out_hw.wav");
   1.102 +
   1.103 +  printf("generate wav done\n");
   1.104 +
   1.105 +  fflush(stdout);
   1.106 +  exit(0);
   1.107 +}
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/#AudioProcessorRRR.rrr#	Tue Apr 27 22:54:50 2010 -0400
     2.3 @@ -0,0 +1,14 @@
     2.4 +service AUDIOPROCESSORRRR
     2.5 +{
     2.6 +    server sw (cpp, method) <- hw (bsv, connection) 
     2.7 +    {
     2.8 +       method SendProcessedStream (in UINT32[32] ctrl, in UINT32[32] sample);
     2.9 +    };
    2.10 +
    2.11 +    server hw (bsv, connection) <- sw (cpp, method)
    2.12 +    {
    2.13 +        method SendUnprocessedStream (in UINT32[32] ctrl, in UINT32[32] sample);
    2.14 +    };
    2.15 +
    2.16 +
    2.17 + };
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/#AudioProcessorTypes.bsv#	Tue Apr 27 22:54:50 2010 -0400
     3.3 @@ -0,0 +1,52 @@
     3.4 +
     3.5 +// The MIT License
     3.6 +
     3.7 +// Copyright (c) 2009 Massachusetts Institute of Technology
     3.8 +
     3.9 +// Permission is hereby granted, free of charge, to any person obtaining a copy
    3.10 +// of this software and associated documentation files (the "Software"), to deal
    3.11 +// in the Software without restriction, including without limitation the rights
    3.12 +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    3.13 +// copies of the Software, and to permit persons to whom the Software is
    3.14 +// furnished to do so, subject to the following conditions:
    3.15 +
    3.16 +// The above copyright notice and this permission notice shall be included in
    3.17 +// all copies or substantial portions of the Software.
    3.18 +
    3.19 +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    3.20 +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    3.21 +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    3.22 +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    3.23 +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    3.24 +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    3.25 +// THE SOFTWARE.
    3.26 +
    3.27 +// Author: Kermin Fleming kfleming@mit.edu
    3.28 +
    3.29 +import Connectable::*;
    3.30 +import GetPut::*;
    3.31 +import ClientServer::*;
    3.32 +
    3.33 +typedef Int#(16) Sample;
    3.34 +
    3.35 +typedef enum {
    3.36 +  EndOfFile = 0,
    3.37 +  Data = 1
    3.38 +} AudioProcessorControl deriving (Bits,Eq);
    3.39 +
    3.40 +
    3.41 +typedef struct { 
    3.42 +  Sample left;
    3.43 +  Sample right;
    3.44 +} StereoSample deriving (Bits,Eq);
    3.45 +
    3.46 +typedef union tagged{
    3.47 + Sample Sample;
    3.48 + void EndOfFile;
    3.49 +} AudioProcessorUnit deriving (Bits,Eq);
    3.50 +
    3.51 +interface AudioPipeline;
    3.52 +  interface Put#(AudioProcessorUnit) sampleInput;
    3.53 +  interface Get#(AudioProcessorUnit) sampleOutput;
    3.54 +endinterface
    3.55 +
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/AudioPipelineDefault.bsv	Tue Apr 27 22:54:50 2010 -0400
     4.3 @@ -0,0 +1,38 @@
     4.4 +// The MIT License
     4.5 +
     4.6 +// Copyright (c) 2009 Massachusetts Institute of Technology
     4.7 +
     4.8 +// Permission is hereby granted, free of charge, to any person obtaining a copy
     4.9 +// of this software and associated documentation files (the "Software"), to deal
    4.10 +// in the Software without restriction, including without limitation the rights
    4.11 +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    4.12 +// copies of the Software, and to permit persons to whom the Software is
    4.13 +// furnished to do so, subject to the following conditions:
    4.14 +
    4.15 +// The above copyright notice and this permission notice shall be included in
    4.16 +// all copies or substantial portions of the Software.
    4.17 +
    4.18 +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    4.19 +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    4.20 +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    4.21 +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    4.22 +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    4.23 +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    4.24 +// THE SOFTWARE.
    4.25 +
    4.26 +// Author: Kermin Fleming kfleming@mit.edu
    4.27 +
    4.28 +import Connectable::*;
    4.29 +import GetPut::*;
    4.30 +import ClientServer::*;
    4.31 +import FIFO::*;
    4.32 +
    4.33 +`include "asim/provides/audio_processor_types.bsh"
    4.34 +
    4.35 +module mkAudioPipeline (AudioPipeline);
    4.36 +  FIFO#(AudioProcessorUnit) fifo <- mkFIFO;
    4.37 +  
    4.38 +  interface sampleInput = fifoToPut(fifo);
    4.39 +  interface sampleOutput = fifoToGet(fifo);
    4.40 +
    4.41 +endmodule
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/AudioProcessor.bsv	Tue Apr 27 22:54:50 2010 -0400
     5.3 @@ -0,0 +1,77 @@
     5.4 +// The MIT License
     5.5 +
     5.6 +// Copyright (c) 2009 Massachusetts Institute of Technology
     5.7 +
     5.8 +// Permission is hereby granted, free of charge, to any person obtaining a copy
     5.9 +// of this software and associated documentation files (the "Software"), to deal
    5.10 +// in the Software without restriction, including without limitation the rights
    5.11 +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    5.12 +// copies of the Software, and to permit persons to whom the Software is
    5.13 +// furnished to do so, subject to the following conditions:
    5.14 +
    5.15 +// The above copyright notice and this permission notice shall be included in
    5.16 +// all copies or substantial portions of the Software.
    5.17 +
    5.18 +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    5.19 +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    5.20 +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    5.21 +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    5.22 +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    5.23 +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    5.24 +// THE SOFTWARE.
    5.25 +
    5.26 +import Connectable::*;
    5.27 +import GetPut::*;
    5.28 +import ClientServer::*;
    5.29 +
    5.30 +//AWB includes
    5.31 +`include "asim/provides/low_level_platform_interface.bsh"
    5.32 +`include "asim/provides/soft_connections.bsh"
    5.33 +`include "asim/provides/common_services.bsh"
    5.34 +
    5.35 +// Local includes
    5.36 +`include "asim/provides/audio_processor_types.bsh"
    5.37 +`include "asim/provides/audio_pipeline.bsh"
    5.38 +
    5.39 +`include "asim/rrr/remote_client_stub_AUDIOPROCESSORRRR.bsh"
    5.40 +`include "asim/rrr/remote_server_stub_AUDIOPROCESSORRRR.bsh"
    5.41 +
    5.42 +
    5.43 +module [CONNECTED_MODULE] mkConnectedApplication ();
    5.44 +
    5.45 +   // Instantiate the rrr stubs
    5.46 +   ClientStub_AUDIOPROCESSORRRR client_stub <- mkClientStub_AUDIOPROCESSORRRR();
    5.47 +   ServerStub_AUDIOPROCESSORRRR server_stub <- mkServerStub_AUDIOPROCESSORRRR();
    5.48 +
    5.49 +   // Instantiate the audio pipeline
    5.50 +   AudioPipeline pipeline <- mkAudioPipeline();
    5.51 +
    5.52 +   rule feedInput;
    5.53 +     let command <- server_stub.acceptRequest_SendUnprocessedStream();
    5.54 +     AudioProcessorControl ctrl = unpack(truncate(command.ctrl));
    5.55 +
    5.56 +     if(ctrl == EndOfFile)
    5.57 +       begin
    5.58 +         pipeline.sampleInput.put(tagged EndOfFile);
    5.59 +       end
    5.60 +     else 
    5.61 +       begin
    5.62 +         pipeline.sampleInput.put(tagged Sample unpack(truncate(command.sample)));
    5.63 +       end
    5.64 +   endrule
    5.65 +
    5.66 +   rule feedOutput;
    5.67 +     let pipelineData <- pipeline.sampleOutput.get();
    5.68 +     AudioProcessorControl endOfFileTag = EndOfFile;
    5.69 +     AudioProcessorControl sampleTag = Data;
    5.70 +
    5.71 +     case (pipelineData) matches
    5.72 +       tagged EndOfFile: client_stub.makeRequest_SendProcessedStream(zeroExtend(pack(endOfFileTag)),?);
    5.73 +       tagged Sample .sample:client_stub.makeRequest_SendProcessedStream(zeroExtend(pack(sampleTag)),
    5.74 +                                                                         zeroExtend(pack(sample)));
    5.75 +     endcase
    5.76 +   endrule
    5.77 +
    5.78 +endmodule
    5.79 +
    5.80 +
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/AudioProcessor.cpp	Tue Apr 27 22:54:50 2010 -0400
     6.3 @@ -0,0 +1,104 @@
     6.4 +#include <stdio.h>
     6.5 +#include <pthread.h>
     6.6 +#include <semaphore.h>
     6.7 +
     6.8 +#include "asim/provides/connected_application.h"
     6.9 +//#include "asim/provides/SndfileWavUtil.h"
    6.10 +
    6.11 +#include "asim/rrr/client_stub_AUDIOPROCESSORRRR.h"
    6.12 +
    6.13 +using namespace std;
    6.14 +
    6.15 +pthread_mutex_t CONNECTED_APPLICATION_CLASS::lock;
    6.16 +pthread_cond_t  CONNECTED_APPLICATION_CLASS::cond;
    6.17 +sem_t CONNECTED_APPLICATION_CLASS::throttle;
    6.18 +
    6.19 +// constructor
    6.20 +CONNECTED_APPLICATION_CLASS::CONNECTED_APPLICATION_CLASS(VIRTUAL_PLATFORM vp) :
    6.21 +    clientStub(new AUDIOPROCESSORRRR_CLIENT_STUB_CLASS(this))
    6.22 +{
    6.23 +}
    6.24 +
    6.25 +// destructor
    6.26 +CONNECTED_APPLICATION_CLASS::~CONNECTED_APPLICATION_CLASS()
    6.27 +{
    6.28 +}
    6.29 +
    6.30 +// init
    6.31 +void
    6.32 +CONNECTED_APPLICATION_CLASS::Init()
    6.33 +{
    6.34 +
    6.35 +  pthread_mutex_init(&lock, NULL);
    6.36 +  pthread_cond_init(&cond, NULL);
    6.37 +  sem_init(&throttle, 0, 64);
    6.38 +
    6.39 +}
    6.40 +
    6.41 +void
    6.42 +CONNECTED_APPLICATION_CLASS::UpdateSemaphore()
    6.43 +{
    6.44 +  sem_post(&throttle);
    6.45 +}
    6.46 +
    6.47 +void
    6.48 +CONNECTED_APPLICATION_CLASS::EndSimulation()
    6.49 +{
    6.50 +  printf("EndSimulation Called\n");
    6.51 +  fflush(stdout);
    6.52 +  pthread_mutex_lock(&lock);
    6.53 +  // Do something about the race occuring here
    6.54 +  pthread_cond_signal(&cond); 
    6.55 +  pthread_mutex_unlock(&lock);
    6.56 +  printf("EndSimulation done\n");
    6.57 +  fflush(stdout);  
    6.58 +}
    6.59 +
    6.60 +// main
    6.61 +void
    6.62 +CONNECTED_APPLICATION_CLASS::Main()
    6.63 +{
    6.64 +  FILE *inputFile;
    6.65 +  UINT16 sample;
    6.66 +  
    6.67 +  // Convert input wav to pcm
    6.68 +  generate_pcm("input.wav","input.pcm");
    6.69 +
    6.70 +  //Send data to the machine here.
    6.71 +  inputFile = fopen("input.pcm","r");
    6.72 +  assert(inputFile);
    6.73 +
    6.74 +
    6.75 +  int count = 0;
    6.76 +
    6.77 +  printf("main: about to enter loop %d\n", count);  
    6.78 +
    6.79 +  while(fread(&sample, 2, 1, inputFile)) {
    6.80 +    if(count%1000 == 0)
    6.81 +      printf("main: %d\n", count);
    6.82 +    count++;
    6.83 +    sem_wait(&throttle);
    6.84 +    clientStub->SendUnprocessedStream(Data,(UINT32)sample);
    6.85 +  } 
    6.86 +
    6.87 +  printf("main: out of loop\n");
    6.88 +
    6.89 +  // Need to put lock here to prevent potential race condition
    6.90 +  pthread_mutex_lock(&lock);
    6.91 +  clientStub->SendUnprocessedStream(EndOfFile,0);
    6.92 +
    6.93 +  printf("main: wait for end of file\n");
    6.94 +
    6.95 +  pthread_cond_wait(&cond, &lock);
    6.96 +  pthread_mutex_unlock(&lock);
    6.97 +
    6.98 +  printf("main: lastt data out\n");
    6.99 +
   6.100 +  // Convert input wav to pcm
   6.101 +  generate_wav("out_hw.pcm","input.wav","out_hw.wav");
   6.102 +
   6.103 +  printf("generate wav done\n");
   6.104 +
   6.105 +  fflush(stdout);
   6.106 +  exit(0);
   6.107 +}
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/AudioProcessor.h	Tue Apr 27 22:54:50 2010 -0400
     7.3 @@ -0,0 +1,56 @@
     7.4 +//
     7.5 +// INTEL CONFIDENTIAL
     7.6 +// Copyright (c) 2008 Intel Corp.  Recipient is granted a non-sublicensable 
     7.7 +// copyright license under Intel copyrights to copy and distribute this code 
     7.8 +// internally only. This code is provided "AS IS" with no support and with no 
     7.9 +// warranties of any kind, including warranties of MERCHANTABILITY,
    7.10 +// FITNESS FOR ANY PARTICULAR PURPOSE or INTELLECTUAL PROPERTY INFRINGEMENT. 
    7.11 +// By making any use of this code, Recipient agrees that no other licenses 
    7.12 +// to any Intel patents, trade secrets, copyrights or other intellectual 
    7.13 +// property rights are granted herein, and no other licenses shall arise by 
    7.14 +// estoppel, implication or by operation of law. Recipient accepts all risks 
    7.15 +// of use.
    7.16 +//
    7.17 +
    7.18 +// possibly use include paths to hide existing modules?
    7.19 +
    7.20 +#ifndef __AUDIO_PROCESSOR_CONNECTED_APPLICATION__
    7.21 +#define __AUDIO_PROCESSOR_CONNECTED_APPLICATION__
    7.22 +
    7.23 +#include <stdio.h>
    7.24 +#include <pthread.h>
    7.25 +#include <semaphore.h>
    7.26 +
    7.27 +#include "asim/provides/virtual_platform.h"
    7.28 +
    7.29 +#include "asim/rrr/client_stub_AUDIOPROCESSORRRR.h"
    7.30 +
    7.31 +typedef enum {
    7.32 +  EndOfFile = 0,
    7.33 +  Data = 1
    7.34 +} AudioProcessorControl; 
    7.35 +
    7.36 +
    7.37 +typedef class CONNECTED_APPLICATION_CLASS* CONNECTED_APPLICATION;
    7.38 +class CONNECTED_APPLICATION_CLASS : public PLATFORMS_MODULE_CLASS
    7.39 +{
    7.40 +  private:
    7.41 +    AUDIOPROCESSORRRR_CLIENT_STUB clientStub;
    7.42 +    static sem_t throttle;
    7.43 +    static pthread_mutex_t lock;
    7.44 +    static pthread_cond_t  cond;    
    7.45 +
    7.46 +  public:
    7.47 +    CONNECTED_APPLICATION_CLASS(VIRTUAL_PLATFORM vp);
    7.48 +    ~CONNECTED_APPLICATION_CLASS();
    7.49 +    static void EndSimulation();
    7.50 +    static void UpdateSemaphore();
    7.51 +
    7.52 +    // init
    7.53 +    void Init();
    7.54 +
    7.55 +    // main
    7.56 +    void Main();
    7.57 +};
    7.58 +
    7.59 +#endif
     8.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.2 +++ b/AudioProcessorRRR.cpp	Tue Apr 27 22:54:50 2010 -0400
     8.3 @@ -0,0 +1,93 @@
     8.4 +#include <cstdio>
     8.5 +#include <cstdlib>
     8.6 +#include <iostream>
     8.7 +#include <iomanip>
     8.8 +#include <stdio.h>
     8.9 +#include <sys/stat.h>
    8.10 +
    8.11 +#include "asim/rrr/service_ids.h"
    8.12 +
    8.13 +#include "asim/provides/connected_application.h"
    8.14 +
    8.15 +
    8.16 +
    8.17 +using namespace std;
    8.18 +
    8.19 +// ===== service instantiation =====
    8.20 +AUDIOPROCESSORRRR_SERVER_CLASS AUDIOPROCESSORRRR_SERVER_CLASS::instance;
    8.21 +
    8.22 +// constructor
    8.23 +AUDIOPROCESSORRRR_SERVER_CLASS::AUDIOPROCESSORRRR_SERVER_CLASS() :
    8.24 +    serverStub(new AUDIOPROCESSORRRR_SERVER_STUB_CLASS(this))
    8.25 +{
    8.26 +    // instantiate stub
    8.27 +    printf("AUDIOPROCESSORRR init called\n");
    8.28 +    outputFile = NULL;
    8.29 +}
    8.30 +
    8.31 +// destructor
    8.32 +AUDIOPROCESSORRRR_SERVER_CLASS::~AUDIOPROCESSORRRR_SERVER_CLASS()
    8.33 +{
    8.34 +    Cleanup();
    8.35 +}
    8.36 +
    8.37 +// init
    8.38 +void
    8.39 +AUDIOPROCESSORRRR_SERVER_CLASS::Init(PLATFORMS_MODULE p)
    8.40 +{
    8.41 +    parent = p;
    8.42 +}
    8.43 +
    8.44 +// uninit
    8.45 +void
    8.46 +AUDIOPROCESSORRRR_SERVER_CLASS::Uninit()
    8.47 +{
    8.48 +    Cleanup();
    8.49 +}
    8.50 +
    8.51 +// cleanup
    8.52 +void
    8.53 +AUDIOPROCESSORRRR_SERVER_CLASS::Cleanup()
    8.54 +{
    8.55 +    delete serverStub;
    8.56 +}
    8.57 +
    8.58 +
    8.59 +//
    8.60 +// RRR service methods
    8.61 +//
    8.62 +
    8.63 +void
    8.64 +AUDIOPROCESSORRRR_SERVER_CLASS::SendProcessedStream(UINT16 control, UINT16 data)
    8.65 +{
    8.66 +
    8.67 +  AudioProcessorControl audioProcessorControl = (AudioProcessorControl) control;
    8.68 +  switch(control) {
    8.69 +    case EndOfFile:
    8.70 +      if(outputFile != NULL) {
    8.71 +        fflush(outputFile);
    8.72 +        fclose(outputFile);
    8.73 +        outputFile = NULL;
    8.74 +      } else {
    8.75 +        outputFile = fopen("out_hw.pcm","w");
    8.76 +        assert(outputFile);
    8.77 +        fflush(outputFile);
    8.78 +        fclose(outputFile);
    8.79 +      }
    8.80 +
    8.81 +      CONNECTED_APPLICATION_CLASS::EndSimulation(); 
    8.82 +    break;
    8.83 +
    8.84 +    case Data:
    8.85 +      if(outputFile == NULL) {
    8.86 +        outputFile = fopen("out_hw.pcm","w");
    8.87 +        assert(outputFile);
    8.88 +      }
    8.89 +
    8.90 +      CONNECTED_APPLICATION_CLASS::UpdateSemaphore();  
    8.91 +      fwrite(&data, 2,1 , outputFile);
    8.92 +    break;
    8.93 +  }
    8.94 + 
    8.95 +}
    8.96 +
     9.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.2 +++ b/AudioProcessorRRR.h	Tue Apr 27 22:54:50 2010 -0400
     9.3 @@ -0,0 +1,50 @@
     9.4 +
     9.5 +#ifndef _AUDIOPROCESSORRRR_
     9.6 +#define _AUDIOPROCESSORRRR_
     9.7 +
     9.8 +#include <stdio.h>
     9.9 +#include <sys/time.h>
    9.10 +
    9.11 +#include "asim/provides/low_level_platform_interface.h"
    9.12 +
    9.13 +#include "asim/provides/rrr.h"
    9.14 +
    9.15 +
    9.16 +
    9.17 +typedef class AUDIOPROCESSORRRR_SERVER_CLASS* AUDIOPROCESSORRRR_SERVER;
    9.18 +class AUDIOPROCESSORRRR_SERVER_CLASS: public RRR_SERVER_CLASS, public PLATFORMS_MODULE_CLASS
    9.19 +{
    9.20 +  private:
    9.21 +    // self-instantiation
    9.22 +    static AUDIOPROCESSORRRR_SERVER_CLASS instance;
    9.23 +    FILE *outputFile;
    9.24 +
    9.25 +    // server stub
    9.26 +    RRR_SERVER_STUB serverStub;
    9.27 +
    9.28 +    int count;    
    9.29 +
    9.30 +  public:
    9.31 +    AUDIOPROCESSORRRR_SERVER_CLASS();
    9.32 +    ~AUDIOPROCESSORRRR_SERVER_CLASS();
    9.33 +
    9.34 +    // static methods
    9.35 +    static AUDIOPROCESSORRRR_SERVER GetInstance() { return &instance; }
    9.36 +
    9.37 +    // required RRR methods
    9.38 +    void Init(PLATFORMS_MODULE);
    9.39 +    void Uninit();
    9.40 +    void Cleanup();
    9.41 +
    9.42 +    //
    9.43 +    // RRR service methods
    9.44 +    //
    9.45 +    void SendProcessedStream(UINT16 control, UINT16 data0);
    9.46 +};
    9.47 +
    9.48 +
    9.49 +
    9.50 +// include server stub
    9.51 +#include "asim/rrr/server_stub_AUDIOPROCESSORRRR.h"
    9.52 +
    9.53 +#endif
    10.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.2 +++ b/AudioProcessorRRR.rrr	Tue Apr 27 22:54:50 2010 -0400
    10.3 @@ -0,0 +1,14 @@
    10.4 +service AUDIOPROCESSORRRR
    10.5 +{
    10.6 +    server sw (cpp, method) <- hw (bsv, connection) 
    10.7 +    {
    10.8 +       method SendProcessedStream (in UINT32[32] ctrl, in UINT32[32] sample);
    10.9 +    };
   10.10 +
   10.11 +    server hw (bsv, connection) <- sw (cpp, method)
   10.12 +    {
   10.13 +        method SendUnprocessedStream (in UINT32[32] ctrl, in UINT32[32] sample);
   10.14 +    };
   10.15 +
   10.16 +
   10.17 + };
    11.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.2 +++ b/AudioProcessorTypes.bsv	Tue Apr 27 22:54:50 2010 -0400
    11.3 @@ -0,0 +1,52 @@
    11.4 +
    11.5 +// The MIT License
    11.6 +
    11.7 +// Copyright (c) 2009 Massachusetts Institute of Technology
    11.8 +
    11.9 +// Permission is hereby granted, free of charge, to any person obtaining a copy
   11.10 +// of this software and associated documentation files (the "Software"), to deal
   11.11 +// in the Software without restriction, including without limitation the rights
   11.12 +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
   11.13 +// copies of the Software, and to permit persons to whom the Software is
   11.14 +// furnished to do so, subject to the following conditions:
   11.15 +
   11.16 +// The above copyright notice and this permission notice shall be included in
   11.17 +// all copies or substantial portions of the Software.
   11.18 +
   11.19 +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   11.20 +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   11.21 +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
   11.22 +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   11.23 +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
   11.24 +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
   11.25 +// THE SOFTWARE.
   11.26 +
   11.27 +// Author: Kermin Fleming kfleming@mit.edu
   11.28 +
   11.29 +import Connectable::*;
   11.30 +import GetPut::*;
   11.31 +import ClientServer::*;
   11.32 +
   11.33 +typedef Int#(16) Sample;
   11.34 +
   11.35 +typedef enum {
   11.36 +  EndOfFile = 0,
   11.37 +  Data = 1
   11.38 +} AudioProcessorControl deriving (Bits,Eq);
   11.39 +
   11.40 +
   11.41 +typedef struct { 
   11.42 +  Sample left;
   11.43 +  Sample right;
   11.44 +} StereoSample deriving (Bits,Eq);
   11.45 +
   11.46 +typedef union tagged{
   11.47 + Sample Sample;
   11.48 + void EndOfFile;
   11.49 +} AudioProcessorUnit deriving (Bits,Eq);
   11.50 +
   11.51 +interface AudioPipeline;
   11.52 +  interface Put#(AudioProcessorUnit) sampleInput;
   11.53 +  interface Get#(AudioProcessorUnit) sampleOutput;
   11.54 +endinterface
   11.55 +
    12.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.2 +++ b/DFT.cpp	Tue Apr 27 22:54:50 2010 -0400
    12.3 @@ -0,0 +1,46 @@
    12.4 +#include <stdio.h>
    12.5 +#include <stdlib.h>
    12.6 +#include <math.h>
    12.7 +
    12.8 +
    12.9 +int DFT(int dir,int m,double *x1,double *y1)
   12.10 +{
   12.11 +   long i,k;
   12.12 +   double arg;
   12.13 +   double cosarg,sinarg;
   12.14 +   double *x2=NULL,*y2=NULL;
   12.15 +
   12.16 +   x2 = (double *)(malloc(m*sizeof(double)));
   12.17 +   y2 = (double *)(malloc(m*sizeof(double)));
   12.18 +   if (x2 == NULL || y2 == NULL)
   12.19 +      return 0;
   12.20 +
   12.21 +   for (i=0;i<m;i++) {
   12.22 +      x2[i] = 0;
   12.23 +      y2[i] = 0;
   12.24 +      arg = - dir * 2.0 * 3.141592654 * (double)i / (double)m;
   12.25 +      for (k=0;k<m;k++) {
   12.26 +         cosarg = cos(k * arg);
   12.27 +         sinarg = sin(k * arg);
   12.28 +         x2[i] += (x1[k] * cosarg - y1[k] * sinarg);
   12.29 +         y2[i] += (x1[k] * sinarg + y1[k] * cosarg);
   12.30 +      }
   12.31 +   }
   12.32 +
   12.33 +   /* Copy the data back */
   12.34 +   if (dir == 1) {
   12.35 +      for (i=0;i<m;i++) {
   12.36 +         x1[i] = x2[i];
   12.37 +         y1[i] = y2[i];
   12.38 +      }
   12.39 +   } else {
   12.40 +      for (i=0;i<m;i++) {
   12.41 +         x1[i] = x2[i];
   12.42 +         y1[i] = y2[i];
   12.43 +      }
   12.44 +   }
   12.45 +
   12.46 +   free(x2);
   12.47 +   free(y2);
   12.48 +   return 1;
   12.49 +}
    13.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    13.2 +++ b/SndfileWavUtil.cpp	Tue Apr 27 22:54:50 2010 -0400
    13.3 @@ -0,0 +1,125 @@
    13.4 +#include <stdlib.h>
    13.5 +#include <string.h>
    13.6 +#include <errno.h>
    13.7 +#include <math.h>
    13.8 +#include <sndfile.h>
    13.9 +#include "SndfileWavUtil.h"
   13.10 +
   13.11 +void
   13.12 +generate_wav(const char * pcmfilename, const char * samplewavfilename, const char * outputwavfilename)
   13.13 +{
   13.14 +  char outfilename[2048];
   13.15 +  SNDFILE * outfile ;
   13.16 +  SNDFILE * wavfile ;
   13.17 +  SNDFILE * pcmfile ;
   13.18 +  SF_INFO wavinfo ;
   13.19 +  SF_INFO pcminfo ;
   13.20 +  int buff;
   13.21 +  SF_INSTRUMENT inst ;
   13.22 +  
   13.23 +  memset (&wavinfo, 0, sizeof (wavinfo)) ;
   13.24 +
   13.25 +  
   13.26 +  wavfile = sf_open(samplewavfilename, SFM_READ, &wavinfo);
   13.27 +
   13.28 +  if (wavfile == NULL){      
   13.29 +    printf ("\nERROR : Not able to open wav file named '%s' : %s/\n", samplewavfilename, sf_strerror (NULL)) ;
   13.30 +    exit (1) ;
   13.31 +  } ;
   13.32 +
   13.33 +  printf("WAV format: %x\n", wavinfo.format);
   13.34 +
   13.35 +  if (!((wavinfo.format & SF_FORMAT_PCM_16) && (wavinfo.channels == 1) && 
   13.36 +        (wavinfo.format & SF_FORMAT_WAV))){
   13.37 +    printf("\nERROR : .wav file must be SF_FORMAT_PCM_16 in mono\n");
   13.38 +  }
   13.39 +
   13.40 +  pcminfo.format = SF_FORMAT_RAW | SF_FORMAT_PCM_16;
   13.41 +  pcminfo.samplerate = wavinfo.samplerate;
   13.42 +  pcminfo.channels = wavinfo.channels;
   13.43 +
   13.44 +  pcmfile = sf_open(pcmfilename, SFM_READ, &pcminfo);
   13.45 +
   13.46 +  if (pcmfile == NULL){      
   13.47 +    printf ("\nERROR : Not able to open pcm file named '%s' : %s/\n", pcmfilename, sf_strerror (NULL)) ;
   13.48 +    exit (1) ;
   13.49 +  } ;
   13.50 +
   13.51 +
   13.52 +
   13.53 +  outfile = sf_open(outputwavfilename, SFM_WRITE, &wavinfo);
   13.54 +
   13.55 +  memset (&inst, 0, sizeof (inst)) ;
   13.56 +
   13.57 +  for(int i = SF_STR_FIRST; i <= SF_STR_LAST; i = i + 1) { 
   13.58 +    const char * str =  sf_get_string(wavfile,i);
   13.59 +    if(str != NULL) {
   13.60 +      sf_set_string(outfile,i,str);
   13.61 +    }
   13.62 +  }
   13.63 +  
   13.64 +  if (outfile == NULL){      
   13.65 +    printf ("\nERROR : Not able to create wav file named '%s' : %s/\n", outfilename, sf_strerror (NULL)) ;
   13.66 +    exit (1) ;
   13.67 +  } ;
   13.68 +
   13.69 +  while(sf_read_int(pcmfile, &buff, 1) == 1){
   13.70 +    if(sf_write_int(outfile, &buff, 1) != 1){
   13.71 +      printf("\nERROR : unable to write to '%s' : %s/\n", outfilename, sf_strerror(NULL));
   13.72 +    }
   13.73 +  }
   13.74 +  
   13.75 +  sf_close (wavfile) ;
   13.76 +  sf_close (outfile) ;
   13.77 +  sf_close (pcmfile) ;
   13.78 +  
   13.79 +}
   13.80 +
   13.81 +
   13.82 +void
   13.83 +generate_pcm (const char * wavfilename, const char * pcmfilename)
   13.84 +{
   13.85 +	SNDFILE * wavfile ;
   13.86 +	SNDFILE * pcmfile ;
   13.87 +	SF_INFO wavinfo ;
   13.88 +	SF_INFO pcminfo ;
   13.89 +	int buff;
   13.90 +
   13.91 +	memset (&wavinfo, 0, sizeof (wavinfo)) ;
   13.92 +	memset (&pcminfo, 0, sizeof (pcminfo)) ;
   13.93 +
   13.94 +	wavfile = sf_open (wavfilename, SFM_READ, &wavinfo) ;
   13.95 +
   13.96 +	if (wavfile == NULL){      
   13.97 +	  printf ("\nERROR : Not able to open wav file named '%s' : %s/\n", wavfilename, sf_strerror (NULL)) ;
   13.98 +	  exit (1) ;
   13.99 +	} ;
  13.100 +
  13.101 +	pcminfo.format = SF_FORMAT_RAW | SF_FORMAT_PCM_16;
  13.102 +	pcminfo.samplerate = wavinfo.samplerate;
  13.103 +	pcminfo.channels = wavinfo.channels;
  13.104 +
  13.105 +	if ((!wavinfo.format & SF_FORMAT_PCM_16) || (!wavinfo.channels == 1)){
  13.106 +	  printf("\nERROR : .wav file must be SF_FORMAT_PCM_16 and mono\n");
  13.107 +	}
  13.108 +
  13.109 +	pcmfile = sf_open (pcmfilename, SFM_WRITE, &pcminfo) ;
  13.110 +
  13.111 +	if (pcmfile == NULL){      
  13.112 +	  printf ("\nERROR : Not able to create pcm file named '%s' : %s/\n", pcmfilename, sf_strerror (NULL)) ;
  13.113 +	  exit (1) ;
  13.114 +	} ;
  13.115 +	
  13.116 +	while(sf_read_int(wavfile, &buff, 1) == 1){
  13.117 +	  if(sf_write_int(pcmfile, &buff, 1) != 1){
  13.118 +	    printf("\nERROR : unable to write to '%s' : %s/\n", pcmfilename, sf_strerror(NULL));
  13.119 +	  }
  13.120 +	}
  13.121 +
  13.122 +	sf_close (wavfile) ;
  13.123 +	sf_close (pcmfile) ;
  13.124 +} 
  13.125 +
  13.126 +
  13.127 +
  13.128 +
    14.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    14.2 +++ b/SndfileWavUtil.h	Tue Apr 27 22:54:50 2010 -0400
    14.3 @@ -0,0 +1,9 @@
    14.4 +#ifndef _SNDFILE_WAV_UTIL_
    14.5 +#define _SNDFILE_WAV_UTIL_
    14.6 +
    14.7 +int guess_direction (const char * filename1, const char * filename2) ;
    14.8 +int guess_major_format (const char * filename) ;
    14.9 +void generate_pcm(const char * wavfilename, const char * pcmfilename);
   14.10 +void generate_wav(const char * pcmfilename, const char * samplewavfilename, const char * outputwavfilename);
   14.11 +
   14.12 +#endif
    15.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    15.2 +++ b/audio_pipeline_default.awb	Tue Apr 27 22:54:50 2010 -0400
    15.3 @@ -0,0 +1,10 @@
    15.4 +%name Default Audio Pipeline
    15.5 +%desc A basic copy-though audio pipeline
    15.6 +
    15.7 +%provides audio_pipeline
    15.8 +
    15.9 +%attributes 6_375
   15.10 +
   15.11 +%public AudioPipelineDefault.bsv
   15.12 +
   15.13 +
    16.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    16.2 +++ b/audio_processor_hardware_system.awb	Tue Apr 27 22:54:50 2010 -0400
    16.3 @@ -0,0 +1,19 @@
    16.4 +%name Audio Processor Application
    16.5 +%desc Top level audio processor. This module wraps an Audio Pipeline, providing communications between host and audio processor
    16.6 +
    16.7 +%provides connected_application
    16.8 +
    16.9 +%requires audio_processor_types
   16.10 +%requires audio_pipeline
   16.11 +
   16.12 +%attributes 6_375
   16.13 +
   16.14 +%sources -t H    -v PUBLIC  AudioProcessor.h
   16.15 +%sources -t H    -v PUBLIC  AudioProcessorRRR.h
   16.16 +%sources -t H    -v PUBLIC  SndfileWavUtil.h
   16.17 +%sources -t BSV  -v PUBLIC  AudioProcessor.bsv
   16.18 +%sources -t CPP  -v PRIVATE AudioProcessor.cpp
   16.19 +%sources -t CPP  -v PRIVATE AudioProcessorRRR.cpp
   16.20 +%sources -t CPP  -v PRIVATE SndfileWavUtil.cpp
   16.21 +%sources -t RRR  -v PUBLIC  AudioProcessorRRR.rrr
   16.22 +%library /usr/lib/libsndfile.so
    17.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    17.2 +++ b/audio_processor_software_system.awb	Tue Apr 27 22:54:50 2010 -0400
    17.3 @@ -0,0 +1,16 @@
    17.4 +********************************************************************
    17.5 +* Awb module specification
    17.6 +********************************************************************
    17.7 +
    17.8 +%AWB_START
    17.9 +
   17.10 +%name Audio Processor Software
   17.11 +%desc Audio Processor Software 
   17.12 +%provides software_system
   17.13 +
   17.14 +%attributes 6_375
   17.15 +
   17.16 +%public AudioProcessor.cpp
   17.17 +%public AudioProcessor.h
   17.18 +
   17.19 +%AWB_END
    18.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    18.2 +++ b/audio_processor_types.awb	Tue Apr 27 22:54:50 2010 -0400
    18.3 @@ -0,0 +1,9 @@
    18.4 +%name Audio Processor Types
    18.5 +%desc Audio Processing Pipeline Types
    18.6 +
    18.7 +%provides audio_processor_types
    18.8 +
    18.9 +%attributes 6_375
   18.10 +
   18.11 +%public AudioProcessorTypes.bsv
   18.12 +
    19.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    19.2 +++ b/common/PathTypes.bsv	Tue Apr 27 22:54:50 2010 -0400
    19.3 @@ -0,0 +1,31 @@
    19.4 +import Trace::*;
    19.5 +import Vector::*;
    19.6 +
    19.7 +`define MAX_VOICES       4
    19.8 +`define MAX_CORES       16
    19.9 +`define MAX_PATH_IDS    18
   19.10 +`define MAX_PATH_LENGTH 8
   19.11 +
   19.12 +// The path is hardwired and so should never be stored in a register.  Therefore int type rather than Bit type
   19.13 +
   19.14 +typedef Bit#(32) MemAddr;
   19.15 +typedef Int#(TLog#(`MAX_PATH_IDS))  PathId;
   19.16 +typedef Int#(24) Sample;
   19.17 +typedef Int#(TLog#(`MAX_VOICES)) VoiceId;
   19.18 +
   19.19 +
   19.20 +//The mixer is identified as PathId 0, path end is max 
   19.21 +PathId mixerId = 0;
   19.22 +PathId endId = `MAX_CORES+1;
   19.23 +
   19.24 +// Path is array of path ids
   19.25 +typedef Vector#(`MAX_PATH_LENGTH,  PathId) CorePath;
   19.26 +CorePath emptyCore = replicate(endId);
   19.27 +
   19.28 +typedef struct
   19.29 +{
   19.30 +  VoiceId   voice;
   19.31 +  MemAddr   startAddr;
   19.32 +  CorePath  route;
   19.33 +} FullPath deriving (Bits, Eq);
   19.34 +
    20.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    20.2 +++ b/common/RoutingTable.bsv	Tue Apr 27 22:54:50 2010 -0400
    20.3 @@ -0,0 +1,52 @@
    20.4 +import Trace::*;
    20.5 +import Vector::*;
    20.6 +import PathTypes::*;
    20.7 +
    20.8 +function FullPath genEmptyPaths (Integer a) ;
    20.9 +   FullPath empt = FullPath {voice: fromInteger(a), startAddr: 0, route: emptyCore};
   20.10 +   return (empt);
   20.11 +endfunction
   20.12 +
   20.13 +interface RoutingTable;
   20.14 +   method FullPath getPath(Integer voiceNo);
   20.15 +endinterface
   20.16 +
   20.17 +module mkRoutingTable(RoutingTable);
   20.18 +   Vector#(`MAX_VOICES, FullPath) routeTable = genWith(genEmptyPaths);
   20.19 +
   20.20 +   function CorePath updateVoice0(Integer len, Vector#(len, PathId) cores, CorePath inPath);
   20.21 +      CorePath outPath = inPath;
   20.22 +      for(Integer i = 0; i < len; i = i+1)
   20.23 +	inPath[i] = cores[i];
   20.24 +      return outPath;
   20.25 +   endfunction
   20.26 +
   20.27 +   //demonstrate two ways of building the routeTable
   20.28 +   routeTable[0].startAddr = 0;  //where is this really going to come from?
   20.29 +   routeTable[0].route[0] = 3;
   20.30 +   routeTable[0].route[1] = mixerId;
   20.31 +   //rest are already initialized toinvalid
   20.32 +
   20.33 +   // or if you just want to update a straight list, this longer emplate works.
   20.34 +   function CorePath createVoice1Route();
   20.35 +      CorePath outPath = emptyCore;
   20.36 +      
   20.37 +      Integer len = 3;
   20.38 +      PathId route[len] = {1, 2, mixerId}; //route to update
   20.39 + 
   20.40 +      for(Integer i = 0; i < len; i = i+1)
   20.41 +	 outPath[i] = route[i];
   20.42 +      
   20.43 +      return outPath;
   20.44 +   endfunction
   20.45 +   routeTable[1].route = createVoice1Route;
   20.46 +   routeTable[1].startAddr = 0;
   20.47 +
   20.48 +   //remaining voices are all initialized to empty.
   20.49 +   
   20.50 +   method FullPath getPath(Integer a);
   20.51 +      return routeTable[a];
   20.52 +   endmethod
   20.53 +   
   20.54 +endmodule
   20.55 + 
    21.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    21.2 +++ b/config/pm/Pygar/fullSystem/audio_core_exe.apm	Tue Apr 27 22:54:50 2010 -0400
    21.3 @@ -0,0 +1,110 @@
    21.4 +
    21.5 +[Global]
    21.6 +SaveParameters=0
    21.7 +Description=
    21.8 +File=audio_core_exe
    21.9 +Version=2.1
   21.10 +Name=Audio Processor
   21.11 +DefaultBenchmark=config/bm/bluespec/demos.cfx/benchmarks/null.cfg
   21.12 +Type=HAsim
   21.13 +Class=Asim::Model
   21.14 +DefaultRunOpts=
   21.15 +
   21.16 +[Model]
   21.17 +DefaultAttributes=hybrid simulation
   21.18 +model=HW/SW Hybrid Project Foundation
   21.19 +
   21.20 +[FPGA Environment]
   21.21 +File=config/pm/hasim/submodels/fpgaenv/fpgaenv-hybrid-exe.apm
   21.22 +Packagehint=platforms
   21.23 +
   21.24 +[Soft Connections Hybrid Application Environment/Requires]
   21.25 +platform_services=Platform Services
   21.26 +soft_connections_lib=Soft Connections Library
   21.27 +connected_application=audio pipeline with soft core
   21.28 +
   21.29 +[Hybrid Project Common Utilities]
   21.30 +File=config/pm/hasim/submodels/common/project-common-default.apm
   21.31 +Packagehint=hasim
   21.32 +
   21.33 +[Soft Connections Library]
   21.34 +File=config/pm/hasim/submodels/common/soft-connections-lib.apm
   21.35 +Packagehint=hasim
   21.36 +
   21.37 +[Platform Services]
   21.38 +File=config/pm/hasim/submodels/platform-services/standard-platform-services.apm
   21.39 +Packagehint=hasim
   21.40 +
   21.41 +[HW/SW Hybrid Project Foundation]
   21.42 +File=modules/project/project-hybrid.awb
   21.43 +Packagehint=platforms
   21.44 +
   21.45 +[Soft Connections Hybrid Application Environment]
   21.46 +File=modules/application-env/hybrid/soft-connections/application-env-hybrid-soft-conn.awb
   21.47 +Packagehint=platforms
   21.48 +
   21.49 +[HW/SW Hybrid Project Foundation/Requires]
   21.50 +project_common=Hybrid Project Common Utilities
   21.51 +fpgaenv=FPGA Environment
   21.52 +application_env=Soft Connections Hybrid Application Environment
   21.53 +
   21.54 +[HW/SW Hybrid Project Foundation/Params]
   21.55 +WAIT_FOR_HARDWARE=0
   21.56 +
   21.57 +[VMH hybrid memory]
   21.58 +File=modules/hasim/functional-partition/memory-state/memory/hybrid/vmh/vmh-memory.awb
   21.59 +Packagehint=hasim
   21.60 +
   21.61 +[Functional Partition Base Types]
   21.62 +File=modules/hasim/functional-partition/base-types/funcp-base-types.awb
   21.63 +Packagehint=hasim
   21.64 +
   21.65 +[3-Stage Audio Processor]
   21.66 +File=modules/bluespec/mit-6.375/core/processor.awb
   21.67 +Packagehint=mit-6.375
   21.68 +
   21.69 +[Blocking Data Cache]
   21.70 +File=modules/bluespec/mit-6.375/lab4/data_cache.awb
   21.71 +Packagehint=mit-6.375
   21.72 +
   21.73 +[Blocking Instruction Cache]
   21.74 +File=modules/bluespec/mit-6.375/lab4/instruction_cache.awb
   21.75 +Packagehint=mit-6.375
   21.76 +
   21.77 +[Default HAsim Common Library]
   21.78 +File=config/pm/hasim/submodels/common/hasim_common.apm
   21.79 +Packagehint=hasim
   21.80 +
   21.81 +[Simple Audio Processor Core]
   21.82 +File=modules/bluespec/mit-6.375/core/audio_pipe_types.awb
   21.83 +Packagehint=mit-6.375
   21.84 +
   21.85 +[Round-robin memory arbiter]
   21.86 +File=modules/bluespec/mit-6.375/lab4/mem_arb.awb
   21.87 +Packagehint=mit-6.375
   21.88 +
   21.89 +[Processor Library]
   21.90 +File=modules/bluespec/mit-6.375/lab4/processor_library.awb
   21.91 +Packagehint=mit-6.375
   21.92 +
   21.93 +[audio pipeline with soft core]
   21.94 +File=modules/bluespec/mit-6.375/core/audio_core_pipe.awb
   21.95 +Packagehint=mit-6.375
   21.96 +
   21.97 +[Audio Processor Core]
   21.98 +File=modules/bluespec/mit-6.375/core/audio_core.awb
   21.99 +Packagehint=mit-6.375
  21.100 +
  21.101 +[audio pipeline with soft core/Requires]
  21.102 +hasim_common=Default HAsim Common Library
  21.103 +funcp_simulated_memory=VMH hybrid memory
  21.104 +core=Audio Processor Core
  21.105 +funcp_base_types=Functional Partition Base Types
  21.106 +audio_pipe_types=Simple Audio Processor Core
  21.107 +
  21.108 +[Audio Processor Core/Requires]
  21.109 +processor_library=Processor Library
  21.110 +processor=3-Stage Audio Processor
  21.111 +data_cache=Blocking Data Cache
  21.112 +instruction_cache=Blocking Instruction Cache
  21.113 +mem_arb=Round-robin memory arbiter
    22.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    22.2 +++ b/modules/bluespec/Pygar/core/audioPipeTypes.bsv	Tue Apr 27 22:54:50 2010 -0400
    22.3 @@ -0,0 +1,50 @@
    22.4 +
    22.5 +// The MIT License
    22.6 +
    22.7 +// Copyright (c) 2009 Massachusetts Institute of Technology
    22.8 +
    22.9 +// Permission is hereby granted, free of charge, to any person obtaining a copy
   22.10 +// of this software and associated documentation files (the "Software"), to deal
   22.11 +// in the Software without restriction, including without limitation the rights
   22.12 +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
   22.13 +// copies of the Software, and to permit persons to whom the Software is
   22.14 +// furnished to do so, subject to the following conditions:
   22.15 +
   22.16 +// The above copyright notice and this permission notice shall be included in
   22.17 +// all copies or substantial portions of the Software.
   22.18 +
   22.19 +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   22.20 +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   22.21 +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
   22.22 +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   22.23 +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
   22.24 +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
   22.25 +// THE SOFTWARE.
   22.26 +
   22.27 +// Author: Ker
   22.28 +// min Fleming kfleming@mit.edu
   22.29 +
   22.30 +import Connectable::*;
   22.31 +import GetPut::*;
   22.32 +import ClientServer::*;
   22.33 +
   22.34 +typedef Int#(16) Sample;
   22.35 +
   22.36 +typedef enum {
   22.37 +  EndOfFile = 0,
   22.38 +  Data = 1
   22.39 +} AudioProcessorControl deriving (Bits,Eq);
   22.40 +
   22.41 +
   22.42 +typedef struct { 
   22.43 +  Sample left;
   22.44 +  Sample right;
   22.45 +} StereoSample deriving (Bits,Eq);
   22.46 +
   22.47 +typedef union tagged{
   22.48 + Sample Sample;
   22.49 + void EndOfFile;
   22.50 +} AudioProcessorUnit deriving (Bits,Eq);
   22.51 +
   22.52 +
   22.53 +