diff modules/bluespec/Pygar/common/AudioProcessor.bsv @ 8:74716e9a81cc pygar svn.9

[svn r9] Pygar now has the proper directory structure to play nicely with awb. Also, the apm file for audio-core willcompile successfully.
author rlm
date Fri, 23 Apr 2010 02:32:05 -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/common/AudioProcessor.bsv	Fri Apr 23 02:32:05 2010 -0400
     1.3 @@ -0,0 +1,77 @@
     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 +