# HG changeset patch # User rlm # Date 1273026772 14400 # Node ID 16ba43f0a7c39b60cd5ec096620bd7b6fff4d62f # Parent 7ac38b0f93faca271d8f773f903f3b634ac14a9b [svn r42] got channels working diff -r 7ac38b0f93fa -r 16ba43f0a7c3 modules/bluespec/Pygar/common/AudioProcessor.bsv --- a/modules/bluespec/Pygar/common/AudioProcessor.bsv Tue May 04 19:53:09 2010 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,77 +0,0 @@ -// The MIT License - -// Copyright (c) 2009 Massachusetts Institute of Technology - -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: - -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. - -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -import Connectable::*; -import GetPut::*; -import ClientServer::*; - -//AWB includes -`include "asim/provides/low_level_platform_interface.bsh" -`include "asim/provides/soft_connections.bsh" -`include "asim/provides/common_services.bsh" - -// Local includes -`include "asim/provides/audio_processor_types.bsh" -`include "asim/provides/audio_pipeline.bsh" - -`include "asim/rrr/remote_client_stub_AUDIOPROCESSORRRR.bsh" -`include "asim/rrr/remote_server_stub_AUDIOPROCESSORRRR.bsh" - - -module [CONNECTED_MODULE] mkConnectedApplication (); - - // Instantiate the rrr stubs - ClientStub_AUDIOPROCESSORRRR client_stub <- mkClientStub_AUDIOPROCESSORRRR(); - ServerStub_AUDIOPROCESSORRRR server_stub <- mkServerStub_AUDIOPROCESSORRRR(); - - // Instantiate the audio pipeline - AudioPipeline pipeline <- mkAudioPipeline(); - - rule feedInput; - let command <- server_stub.acceptRequest_SendUnprocessedStream(); - AudioProcessorControl ctrl = unpack(truncate(command.ctrl)); - - if(ctrl == EndOfFile) - begin - pipeline.sampleInput.put(tagged EndOfFile); - end - else - begin - pipeline.sampleInput.put(tagged Sample unpack(truncate(command.sample))); - end - endrule - - rule feedOutput; - let pipelineData <- pipeline.sampleOutput.get(); - AudioProcessorControl endOfFileTag = EndOfFile; - AudioProcessorControl sampleTag = Data; - - case (pipelineData) matches - tagged EndOfFile: client_stub.makeRequest_SendProcessedStream(zeroExtend(pack(endOfFileTag)),?); - tagged Sample .sample:client_stub.makeRequest_SendProcessedStream(zeroExtend(pack(sampleTag)), - zeroExtend(pack(sample))); - endcase - endrule - -endmodule - - diff -r 7ac38b0f93fa -r 16ba43f0a7c3 modules/bluespec/Pygar/common/AudioProcessorRRR.cpp --- a/modules/bluespec/Pygar/common/AudioProcessorRRR.cpp Tue May 04 19:53:09 2010 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,93 +0,0 @@ -#include -#include -#include -#include -#include -#include - -#include "asim/rrr/service_ids.h" - -#include "asim/provides/connected_application.h" - - - -using namespace std; - -// ===== service instantiation ===== -AUDIOPROCESSORRRR_SERVER_CLASS AUDIOPROCESSORRRR_SERVER_CLASS::instance; - -// constructor -AUDIOPROCESSORRRR_SERVER_CLASS::AUDIOPROCESSORRRR_SERVER_CLASS() : - serverStub(new AUDIOPROCESSORRRR_SERVER_STUB_CLASS(this)) -{ - // instantiate stub - printf("AUDIOPROCESSORRR init called\n"); - outputFile = NULL; -} - -// destructor -AUDIOPROCESSORRRR_SERVER_CLASS::~AUDIOPROCESSORRRR_SERVER_CLASS() -{ - Cleanup(); -} - -// init -void -AUDIOPROCESSORRRR_SERVER_CLASS::Init(PLATFORMS_MODULE p) -{ - parent = p; -} - -// uninit -void -AUDIOPROCESSORRRR_SERVER_CLASS::Uninit() -{ - Cleanup(); -} - -// cleanup -void -AUDIOPROCESSORRRR_SERVER_CLASS::Cleanup() -{ - delete serverStub; -} - - -// -// RRR service methods -// - -void -AUDIOPROCESSORRRR_SERVER_CLASS::SendProcessedStream(UINT16 control, UINT16 data) -{ - - AudioProcessorControl audioProcessorControl = (AudioProcessorControl) control; - switch(control) { - case EndOfFile: - if(outputFile != NULL) { - fflush(outputFile); - fclose(outputFile); - outputFile = NULL; - } else { - outputFile = fopen("out_hw.pcm","w"); - assert(outputFile); - fflush(outputFile); - fclose(outputFile); - } - - CONNECTED_APPLICATION_CLASS::EndSimulation(); - break; - - case Data: - if(outputFile == NULL) { - outputFile = fopen("out_hw.pcm","w"); - assert(outputFile); - } - - CONNECTED_APPLICATION_CLASS::UpdateSemaphore(); - fwrite(&data, 2,1 , outputFile); - break; - } - -} - diff -r 7ac38b0f93fa -r 16ba43f0a7c3 modules/bluespec/Pygar/common/AudioProcessorRRR.h --- a/modules/bluespec/Pygar/common/AudioProcessorRRR.h Tue May 04 19:53:09 2010 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,50 +0,0 @@ - -#ifndef _AUDIOPROCESSORRRR_ -#define _AUDIOPROCESSORRRR_ - -#include -#include - -#include "asim/provides/low_level_platform_interface.h" - -#include "asim/provides/rrr.h" - - - -typedef class AUDIOPROCESSORRRR_SERVER_CLASS* AUDIOPROCESSORRRR_SERVER; -class AUDIOPROCESSORRRR_SERVER_CLASS: public RRR_SERVER_CLASS, public PLATFORMS_MODULE_CLASS -{ - private: - // self-instantiation - static AUDIOPROCESSORRRR_SERVER_CLASS instance; - FILE *outputFile; - - // server stub - RRR_SERVER_STUB serverStub; - - int count; - - public: - AUDIOPROCESSORRRR_SERVER_CLASS(); - ~AUDIOPROCESSORRRR_SERVER_CLASS(); - - // static methods - static AUDIOPROCESSORRRR_SERVER GetInstance() { return &instance; } - - // required RRR methods - void Init(PLATFORMS_MODULE); - void Uninit(); - void Cleanup(); - - // - // RRR service methods - // - void SendProcessedStream(UINT16 control, UINT16 data0); -}; - - - -// include server stub -#include "asim/rrr/server_stub_AUDIOPROCESSORRRR.h" - -#endif diff -r 7ac38b0f93fa -r 16ba43f0a7c3 modules/bluespec/Pygar/common/AudioProcessorRRR.rrr --- a/modules/bluespec/Pygar/common/AudioProcessorRRR.rrr Tue May 04 19:53:09 2010 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,14 +0,0 @@ -service AUDIOPROCESSORRRR -{ - server sw (cpp, method) <- hw (bsv, connection) - { - method SendProcessedStream (in UINT32[32] ctrl, in UINT32[32] sample); - }; - - server hw (bsv, connection) <- sw (cpp, method) - { - method SendUnprocessedStream (in UINT32[32] ctrl, in UINT32[32] sample); - }; - - - }; diff -r 7ac38b0f93fa -r 16ba43f0a7c3 modules/bluespec/Pygar/core/AudioCoreRRR.rrr --- a/modules/bluespec/Pygar/core/AudioCoreRRR.rrr Tue May 04 19:53:09 2010 -0400 +++ b/modules/bluespec/Pygar/core/AudioCoreRRR.rrr Tue May 04 22:32:52 2010 -0400 @@ -3,9 +3,7 @@ server hw (bsv, connection) <- sw (cpp, method) { method ReadCPUToHost (out UINT32[32] regValue, in UINT32[32] dummy); - method SendUnprocessedStream (in UINT32[32] ctrl, in UINT32[32] sample); - //rlm: here it is modified to take N -// method SendUnprocessedStream (in UINT32[32] channel, in UINT32[32] ctrl, in UINT32[32] sample); + method SendUnprocessedStream (in UINT32[32] channel, in UINT32[32] ctrl, in UINT32[32] sample); }; @@ -13,9 +11,7 @@ { method SendProcessedStream (in UINT32[32] ctrl, in UINT32[32] sample); -// Not used by SCRATCHPAD -// method MemoryRequestLoad (in UINT32[32] address, out UINT32[32] value); -// method MemoryRequestStore (in UINT32[32] address, in UINT32[32] value); + }; }; diff -r 7ac38b0f93fa -r 16ba43f0a7c3 modules/bluespec/Pygar/core/AudioCoreSystem.cpp --- a/modules/bluespec/Pygar/core/AudioCoreSystem.cpp Tue May 04 19:53:09 2010 -0400 +++ b/modules/bluespec/Pygar/core/AudioCoreSystem.cpp Tue May 04 22:32:52 2010 -0400 @@ -69,7 +69,7 @@ //UINT16 sample1; //rlm: not sure if normal ints are ok here; using UINT16 because I know it works - UINT16 channel0 = 0; + UINT16 channel0 = 5; //UINT16 channel1 = 1; //init processor @@ -132,8 +132,8 @@ printf("sending file\n"); //rlm: two files. - clientStub->SendUnprocessedStream( Data,(UINT32)sample); - //clientStub->SendUnprocessedStream(channel0 , Data,(UINT32)sample); + // clientStub->SendUnprocessedStream( Data,(UINT32)sample); + clientStub->SendUnprocessedStream((UINT32)channel0 , Data,(UINT32)sample); //clientStub->SendUnprocessedStream(channel1 , Data,(UINT32)sample1); } @@ -145,9 +145,9 @@ //rlm: have to send end-files to both voices. // all of these operations wil eventually be moved into functions. - clientStub->SendUnprocessedStream(EndOfFile,0); - //clientStub->SendUnprocessedStream(channel0, EndOfFile,0); - // clientStub->SendUnprocessedStream(channel1, EndOfFile,0); + //clientStub->SendUnprocessedStream(EndOfFile,0); + clientStub->SendUnprocessedStream((UINT32)channel0, EndOfFile,0); + // clientStub->SendUnprocessedStream(channel1, EndOfFile,0); printf("main: wait for end of file\n"); diff -r 7ac38b0f93fa -r 16ba43f0a7c3 modules/bluespec/Pygar/core/audioCorePipeline.bsv --- a/modules/bluespec/Pygar/core/audioCorePipeline.bsv Tue May 04 19:53:09 2010 -0400 +++ b/modules/bluespec/Pygar/core/audioCorePipeline.bsv Tue May 04 22:32:52 2010 -0400 @@ -120,7 +120,12 @@ rule feedInput; let command <- server_stub.acceptRequest_SendUnprocessedStream(); AudioProcessorControl ctrl = unpack(truncate(command.ctrl)); - if(ctrl == EndOfFile) + + Bit#(32) test = unpack(truncate(command.channel)); + $display("rlm: %x", test); + + + if(ctrl == EndOfFile) begin $display("lsp: PROCESSOR received EOF "); core.sampleInput.put(tagged EndOfFile);