changeset 41:16ba43f0a7c3 pygar svn.42

[svn r42] got channels working
author rlm
date Tue, 04 May 2010 22:32:52 -0400
parents 7ac38b0f93fa
children ced2ebd41347
files modules/bluespec/Pygar/common/AudioProcessor.bsv modules/bluespec/Pygar/common/AudioProcessorRRR.cpp modules/bluespec/Pygar/common/AudioProcessorRRR.h modules/bluespec/Pygar/common/AudioProcessorRRR.rrr modules/bluespec/Pygar/core/AudioCoreRRR.rrr modules/bluespec/Pygar/core/AudioCoreSystem.cpp modules/bluespec/Pygar/core/audioCorePipeline.bsv
diffstat 7 files changed, 14 insertions(+), 247 deletions(-) [+]
line wrap: on
line diff
     1.1 --- a/modules/bluespec/Pygar/common/AudioProcessor.bsv	Tue May 04 19:53:09 2010 -0400
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,77 +0,0 @@
     1.4 -// The MIT License
     1.5 -
     1.6 -// Copyright (c) 2009 Massachusetts Institute of Technology
     1.7 -
     1.8 -// Permission is hereby granted, free of charge, to any person obtaining a copy
     1.9 -// of this software and associated documentation files (the "Software"), to deal
    1.10 -// in the Software without restriction, including without limitation the rights
    1.11 -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    1.12 -// copies of the Software, and to permit persons to whom the Software is
    1.13 -// furnished to do so, subject to the following conditions:
    1.14 -
    1.15 -// The above copyright notice and this permission notice shall be included in
    1.16 -// all copies or substantial portions of the Software.
    1.17 -
    1.18 -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    1.19 -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    1.20 -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    1.21 -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    1.22 -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    1.23 -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    1.24 -// THE SOFTWARE.
    1.25 -
    1.26 -import Connectable::*;
    1.27 -import GetPut::*;
    1.28 -import ClientServer::*;
    1.29 -
    1.30 -//AWB includes
    1.31 -`include "asim/provides/low_level_platform_interface.bsh"
    1.32 -`include "asim/provides/soft_connections.bsh"
    1.33 -`include "asim/provides/common_services.bsh"
    1.34 -
    1.35 -// Local includes
    1.36 -`include "asim/provides/audio_processor_types.bsh"
    1.37 -`include "asim/provides/audio_pipeline.bsh"
    1.38 -
    1.39 -`include "asim/rrr/remote_client_stub_AUDIOPROCESSORRRR.bsh"
    1.40 -`include "asim/rrr/remote_server_stub_AUDIOPROCESSORRRR.bsh"
    1.41 -
    1.42 -
    1.43 -module [CONNECTED_MODULE] mkConnectedApplication ();
    1.44 -
    1.45 -   // Instantiate the rrr stubs
    1.46 -   ClientStub_AUDIOPROCESSORRRR client_stub <- mkClientStub_AUDIOPROCESSORRRR();
    1.47 -   ServerStub_AUDIOPROCESSORRRR server_stub <- mkServerStub_AUDIOPROCESSORRRR();
    1.48 -
    1.49 -   // Instantiate the audio pipeline
    1.50 -   AudioPipeline pipeline <- mkAudioPipeline();
    1.51 -
    1.52 -   rule feedInput;
    1.53 -     let command <- server_stub.acceptRequest_SendUnprocessedStream();
    1.54 -     AudioProcessorControl ctrl = unpack(truncate(command.ctrl));
    1.55 -
    1.56 -     if(ctrl == EndOfFile)
    1.57 -       begin
    1.58 -         pipeline.sampleInput.put(tagged EndOfFile);
    1.59 -       end
    1.60 -     else 
    1.61 -       begin
    1.62 -         pipeline.sampleInput.put(tagged Sample unpack(truncate(command.sample)));
    1.63 -       end
    1.64 -   endrule
    1.65 -
    1.66 -   rule feedOutput;
    1.67 -     let pipelineData <- pipeline.sampleOutput.get();
    1.68 -     AudioProcessorControl endOfFileTag = EndOfFile;
    1.69 -     AudioProcessorControl sampleTag = Data;
    1.70 -
    1.71 -     case (pipelineData) matches
    1.72 -       tagged EndOfFile: client_stub.makeRequest_SendProcessedStream(zeroExtend(pack(endOfFileTag)),?);
    1.73 -       tagged Sample .sample:client_stub.makeRequest_SendProcessedStream(zeroExtend(pack(sampleTag)),
    1.74 -                                                                         zeroExtend(pack(sample)));
    1.75 -     endcase
    1.76 -   endrule
    1.77 -
    1.78 -endmodule
    1.79 -
    1.80 -
     2.1 --- a/modules/bluespec/Pygar/common/AudioProcessorRRR.cpp	Tue May 04 19:53:09 2010 -0400
     2.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.3 @@ -1,93 +0,0 @@
     2.4 -#include <cstdio>
     2.5 -#include <cstdlib>
     2.6 -#include <iostream>
     2.7 -#include <iomanip>
     2.8 -#include <stdio.h>
     2.9 -#include <sys/stat.h>
    2.10 -
    2.11 -#include "asim/rrr/service_ids.h"
    2.12 -
    2.13 -#include "asim/provides/connected_application.h"
    2.14 -
    2.15 -
    2.16 -
    2.17 -using namespace std;
    2.18 -
    2.19 -// ===== service instantiation =====
    2.20 -AUDIOPROCESSORRRR_SERVER_CLASS AUDIOPROCESSORRRR_SERVER_CLASS::instance;
    2.21 -
    2.22 -// constructor
    2.23 -AUDIOPROCESSORRRR_SERVER_CLASS::AUDIOPROCESSORRRR_SERVER_CLASS() :
    2.24 -    serverStub(new AUDIOPROCESSORRRR_SERVER_STUB_CLASS(this))
    2.25 -{
    2.26 -    // instantiate stub
    2.27 -    printf("AUDIOPROCESSORRR init called\n");
    2.28 -    outputFile = NULL;
    2.29 -}
    2.30 -
    2.31 -// destructor
    2.32 -AUDIOPROCESSORRRR_SERVER_CLASS::~AUDIOPROCESSORRRR_SERVER_CLASS()
    2.33 -{
    2.34 -    Cleanup();
    2.35 -}
    2.36 -
    2.37 -// init
    2.38 -void
    2.39 -AUDIOPROCESSORRRR_SERVER_CLASS::Init(PLATFORMS_MODULE p)
    2.40 -{
    2.41 -    parent = p;
    2.42 -}
    2.43 -
    2.44 -// uninit
    2.45 -void
    2.46 -AUDIOPROCESSORRRR_SERVER_CLASS::Uninit()
    2.47 -{
    2.48 -    Cleanup();
    2.49 -}
    2.50 -
    2.51 -// cleanup
    2.52 -void
    2.53 -AUDIOPROCESSORRRR_SERVER_CLASS::Cleanup()
    2.54 -{
    2.55 -    delete serverStub;
    2.56 -}
    2.57 -
    2.58 -
    2.59 -//
    2.60 -// RRR service methods
    2.61 -//
    2.62 -
    2.63 -void
    2.64 -AUDIOPROCESSORRRR_SERVER_CLASS::SendProcessedStream(UINT16 control, UINT16 data)
    2.65 -{
    2.66 -
    2.67 -  AudioProcessorControl audioProcessorControl = (AudioProcessorControl) control;
    2.68 -  switch(control) {
    2.69 -    case EndOfFile:
    2.70 -      if(outputFile != NULL) {
    2.71 -        fflush(outputFile);
    2.72 -        fclose(outputFile);
    2.73 -        outputFile = NULL;
    2.74 -      } else {
    2.75 -        outputFile = fopen("out_hw.pcm","w");
    2.76 -        assert(outputFile);
    2.77 -        fflush(outputFile);
    2.78 -        fclose(outputFile);
    2.79 -      }
    2.80 -
    2.81 -      CONNECTED_APPLICATION_CLASS::EndSimulation(); 
    2.82 -    break;
    2.83 -
    2.84 -    case Data:
    2.85 -      if(outputFile == NULL) {
    2.86 -        outputFile = fopen("out_hw.pcm","w");
    2.87 -        assert(outputFile);
    2.88 -      }
    2.89 -
    2.90 -      CONNECTED_APPLICATION_CLASS::UpdateSemaphore();  
    2.91 -      fwrite(&data, 2,1 , outputFile);
    2.92 -    break;
    2.93 -  }
    2.94 - 
    2.95 -}
    2.96 -
     3.1 --- a/modules/bluespec/Pygar/common/AudioProcessorRRR.h	Tue May 04 19:53:09 2010 -0400
     3.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.3 @@ -1,50 +0,0 @@
     3.4 -
     3.5 -#ifndef _AUDIOPROCESSORRRR_
     3.6 -#define _AUDIOPROCESSORRRR_
     3.7 -
     3.8 -#include <stdio.h>
     3.9 -#include <sys/time.h>
    3.10 -
    3.11 -#include "asim/provides/low_level_platform_interface.h"
    3.12 -
    3.13 -#include "asim/provides/rrr.h"
    3.14 -
    3.15 -
    3.16 -
    3.17 -typedef class AUDIOPROCESSORRRR_SERVER_CLASS* AUDIOPROCESSORRRR_SERVER;
    3.18 -class AUDIOPROCESSORRRR_SERVER_CLASS: public RRR_SERVER_CLASS, public PLATFORMS_MODULE_CLASS
    3.19 -{
    3.20 -  private:
    3.21 -    // self-instantiation
    3.22 -    static AUDIOPROCESSORRRR_SERVER_CLASS instance;
    3.23 -    FILE *outputFile;
    3.24 -
    3.25 -    // server stub
    3.26 -    RRR_SERVER_STUB serverStub;
    3.27 -
    3.28 -    int count;    
    3.29 -
    3.30 -  public:
    3.31 -    AUDIOPROCESSORRRR_SERVER_CLASS();
    3.32 -    ~AUDIOPROCESSORRRR_SERVER_CLASS();
    3.33 -
    3.34 -    // static methods
    3.35 -    static AUDIOPROCESSORRRR_SERVER GetInstance() { return &instance; }
    3.36 -
    3.37 -    // required RRR methods
    3.38 -    void Init(PLATFORMS_MODULE);
    3.39 -    void Uninit();
    3.40 -    void Cleanup();
    3.41 -
    3.42 -    //
    3.43 -    // RRR service methods
    3.44 -    //
    3.45 -    void SendProcessedStream(UINT16 control, UINT16 data0);
    3.46 -};
    3.47 -
    3.48 -
    3.49 -
    3.50 -// include server stub
    3.51 -#include "asim/rrr/server_stub_AUDIOPROCESSORRRR.h"
    3.52 -
    3.53 -#endif
     4.1 --- a/modules/bluespec/Pygar/common/AudioProcessorRRR.rrr	Tue May 04 19:53:09 2010 -0400
     4.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.3 @@ -1,14 +0,0 @@
     4.4 -service AUDIOPROCESSORRRR
     4.5 -{
     4.6 -    server sw (cpp, method) <- hw (bsv, connection) 
     4.7 -    {
     4.8 -       method SendProcessedStream (in UINT32[32] ctrl, in UINT32[32] sample);
     4.9 -    };
    4.10 -
    4.11 -    server hw (bsv, connection) <- sw (cpp, method)
    4.12 -    {
    4.13 -        method SendUnprocessedStream (in UINT32[32] ctrl, in UINT32[32] sample);
    4.14 -    };
    4.15 -
    4.16 -
    4.17 - };
     5.1 --- a/modules/bluespec/Pygar/core/AudioCoreRRR.rrr	Tue May 04 19:53:09 2010 -0400
     5.2 +++ b/modules/bluespec/Pygar/core/AudioCoreRRR.rrr	Tue May 04 22:32:52 2010 -0400
     5.3 @@ -3,9 +3,7 @@
     5.4      server hw (bsv, connection) <- sw (cpp, method)
     5.5      {
     5.6          method ReadCPUToHost  (out UINT32[32] regValue, in UINT32[32] dummy);
     5.7 -        method SendUnprocessedStream (in UINT32[32] ctrl, in UINT32[32] sample);
     5.8 -	//rlm: here it is modified to take N
     5.9 -//	method   SendUnprocessedStream (in UINT32[32] channel, in UINT32[32] ctrl, in UINT32[32] sample);
    5.10 +        method   SendUnprocessedStream (in UINT32[32] channel, in UINT32[32] ctrl, in UINT32[32] sample);
    5.11  
    5.12      };
    5.13  
    5.14 @@ -13,9 +11,7 @@
    5.15      {
    5.16         method SendProcessedStream (in UINT32[32] ctrl, in UINT32[32] sample);
    5.17  
    5.18 -// Not used by SCRATCHPAD
    5.19 -//     method MemoryRequestLoad  (in UINT32[32] address, out UINT32[32] value);
    5.20 -//     method MemoryRequestStore (in UINT32[32] address, in UINT32[32] value);
    5.21 +
    5.22      };
    5.23  
    5.24   };
     6.1 --- a/modules/bluespec/Pygar/core/AudioCoreSystem.cpp	Tue May 04 19:53:09 2010 -0400
     6.2 +++ b/modules/bluespec/Pygar/core/AudioCoreSystem.cpp	Tue May 04 22:32:52 2010 -0400
     6.3 @@ -69,7 +69,7 @@
     6.4  //UINT16 sample1;
     6.5  
     6.6    //rlm: not sure if normal ints are ok here; using UINT16 because I know it works
     6.7 -  UINT16 channel0 = 0;
     6.8 +  UINT16 channel0 = 5;
     6.9    //UINT16 channel1 = 1;
    6.10  
    6.11    //init processor 
    6.12 @@ -132,8 +132,8 @@
    6.13      
    6.14       printf("sending file\n");
    6.15      //rlm: two files.
    6.16 -     clientStub->SendUnprocessedStream( Data,(UINT32)sample);
    6.17 -     //clientStub->SendUnprocessedStream(channel0 , Data,(UINT32)sample);
    6.18 +    // clientStub->SendUnprocessedStream( Data,(UINT32)sample);
    6.19 +     clientStub->SendUnprocessedStream((UINT32)channel0 , Data,(UINT32)sample);
    6.20       //clientStub->SendUnprocessedStream(channel1 , Data,(UINT32)sample1);
    6.21  
    6.22    } 
    6.23 @@ -145,9 +145,9 @@
    6.24  
    6.25    //rlm: have to send end-files to both voices.  
    6.26    // all of these operations wil eventually be moved into functions.
    6.27 -  clientStub->SendUnprocessedStream(EndOfFile,0);
    6.28 -    //clientStub->SendUnprocessedStream(channel0, EndOfFile,0);
    6.29 -    // clientStub->SendUnprocessedStream(channel1, EndOfFile,0);
    6.30 +  //clientStub->SendUnprocessedStream(EndOfFile,0);
    6.31 +  clientStub->SendUnprocessedStream((UINT32)channel0, EndOfFile,0);
    6.32 +  // clientStub->SendUnprocessedStream(channel1, EndOfFile,0);
    6.33  
    6.34    printf("main: wait for end of file\n");
    6.35  
     7.1 --- a/modules/bluespec/Pygar/core/audioCorePipeline.bsv	Tue May 04 19:53:09 2010 -0400
     7.2 +++ b/modules/bluespec/Pygar/core/audioCorePipeline.bsv	Tue May 04 22:32:52 2010 -0400
     7.3 @@ -120,7 +120,12 @@
     7.4     rule feedInput;
     7.5       let command <- server_stub.acceptRequest_SendUnprocessedStream();
     7.6       AudioProcessorControl ctrl = unpack(truncate(command.ctrl));
     7.7 -     if(ctrl == EndOfFile)
     7.8 +
     7.9 +      Bit#(32) test = unpack(truncate(command.channel));
    7.10 +      $display("rlm: %x", test);
    7.11 +	   
    7.12 +
    7.13 +      if(ctrl == EndOfFile)
    7.14  	begin
    7.15  	  $display("lsp: PROCESSOR received EOF   ");
    7.16            core.sampleInput.put(tagged EndOfFile);