# HG changeset patch # User punk # Date 1273417120 14400 # Node ID 2991344775f8aeed66121067cdc9e78b895899ff # Parent 49049f97312cceb9fd211658ef433382bd50786e [svn r54] mixer integrated diff -r 49049f97312c -r 2991344775f8 modules/bluespec/Pygar/core/AudioCoreRRR.cpp --- a/modules/bluespec/Pygar/core/AudioCoreRRR.cpp Thu May 06 08:57:53 2010 -0400 +++ b/modules/bluespec/Pygar/core/AudioCoreRRR.cpp Sun May 09 10:58:40 2010 -0400 @@ -120,8 +120,8 @@ } // Long term this should be in the data portion. But until I have code running, keep it here. - count++; - if (count == 2) + // count++; + //if (count == 2) CONNECTED_APPLICATION_CLASS::EndSimulation(); break; diff -r 49049f97312c -r 2991344775f8 modules/bluespec/Pygar/core/AudioCoreSystem.cpp --- a/modules/bluespec/Pygar/core/AudioCoreSystem.cpp Thu May 06 08:57:53 2010 -0400 +++ b/modules/bluespec/Pygar/core/AudioCoreSystem.cpp Sun May 09 10:58:40 2010 -0400 @@ -92,7 +92,7 @@ //Send data to the machine here. //rlm: two files inputFile = fopen("input.pcm","r"); - inputFile = fopen("input1.pcm", "r"); + inputFile1 = fopen("input1.pcm", "r"); assert(inputFile1); assert(inputFile); @@ -159,5 +159,5 @@ STATS_DEVICE_SERVER_CLASS::GetInstance()->EmitFile(); fflush(stdout); - exit(0); + // exit(0); } diff -r 49049f97312c -r 2991344775f8 modules/bluespec/Pygar/core/Mixer.bsv --- a/modules/bluespec/Pygar/core/Mixer.bsv Thu May 06 08:57:53 2010 -0400 +++ b/modules/bluespec/Pygar/core/Mixer.bsv Sun May 09 10:58:40 2010 -0400 @@ -27,8 +27,6 @@ import FIFO::*; import FixedPoint::*; -`define MAX_VOICES 2 - //AWB includes `include "asim/provides/low_level_platform_interface.bsh" `include "asim/provides/soft_connections.bsh" @@ -38,44 +36,40 @@ `include "asim/provides/audio_pipe_types.bsh" `include "asim/provides/path_types.bsh" -interface PutMixerIn; - method Action sendVoiceIn(AudioStream voiceInput); -endinterface - interface Mixer; - interface PutMixerIn toMixer; - interface Get#(AudioProcessorUnit) mixerOut; + method Action toMixer(AudioStream streamIn); + interface Get#(AudioProcessorUnit) mainOut; endinterface -function Bool isAudioFini(Vector#(`MAX_VOICES, Reg#(Bool)) voiceStat); - Bool result = True; - for (Integer i = 0; i < `MAX_VOICES; i = i+1) - begin - result = voiceStat[i] && result; - end - return result; -endfunction +module [CONNECTED_MODULE] mkMixer#(Integer numVoices, Vector#(numVoices, Volume) scalars) (Mixer); -module [CONNECTED_MODULE] mkMixer#(Vector#(`MAX_VOICES, Volume) scalars) (Mixer); + function Bool isAudioFini(Vector#(numVoices, Reg#(Bool)) voiceStat); + Bool result = True; + for (Integer i = 0; i < numVoices; i = i+1) + begin + result = voiceStat[i] && result; + end + return result; + endfunction // Instantiate the modules - Vector#(`MAX_VOICES, FIFO#(AudioPipeUnit)) voicesIn <- replicateM(mkFIFO()); + Vector#(numVoices, FIFO#(AudioPipeUnit)) voicesIn <- replicateM(mkFIFO()); // <- newVector(); - Vector#(`MAX_VOICES, Reg#(Bool)) voiceFini <- replicateM(mkReg(False)); + Vector#(numVoices, Reg#(Bool)) voiceFini <- replicateM(mkReg(False)); FIFO#(AudioProcessorUnit) masterFifo <- mkFIFO(); rule sendEnd(isAudioFini(voiceFini)); masterFifo.enq(tagged EndOfFile); //prep for reset - for (Integer i = 0; i < `MAX_VOICES; i = i+1) + for (Integer i = 0; i < numVoices; i = i+1) voiceFini[i] <= False; endrule rule processSample(!isAudioFini(voiceFini)); //implicit on all voiceFifos having data FixedPoint#(32,32) sum = 0; //this should allow 16 voices at 16 bits without messing up - for (Integer i = 0; i < `MAX_VOICES; i = i+1) + for (Integer i = 0; i < numVoices; i = i+1) begin if (voicesIn[i].first() matches tagged Valid .data) begin @@ -91,17 +85,19 @@ voicesIn[i].deq(); end - masterFifo.enq(tagged Sample truncate(fxptGetInt(sum >> `MAX_VOICES))); + masterFifo.enq(tagged Sample truncate(fxptGetInt(sum >> numVoices))); endrule // Internal connections - interface PutMixerIn toMixer; - method Action sendVoiceIn(AudioStream voiceInput); - voicesIn[voiceInput.voice].enq(voiceInput.data); - endmethod - endinterface - - interface Get mixerOut = fifoToGet(masterFifo); +// method Action loadMixerFifos(AudioStream voiceInput); +// voicesIn[voiceInput.voice].enq(voiceInput.data); +// endmethod + + method Action toMixer(AudioStream streamIn); + voicesIn[streamIn.voice].enq(streamIn.data); + endmethod + + interface Get mainOut = fifoToGet(masterFifo); endmodule diff -r 49049f97312c -r 2991344775f8 modules/bluespec/Pygar/core/Processor.bsv --- a/modules/bluespec/Pygar/core/Processor.bsv Thu May 06 08:57:53 2010 -0400 +++ b/modules/bluespec/Pygar/core/Processor.bsv Sun May 09 10:58:40 2010 -0400 @@ -501,7 +501,7 @@ 5'd20 : wbQ.enq(tagged WB_ALU {dest:it.rdst, data:cp0_fromhost }); 5'd21 : wbQ.enq(tagged WB_ALU {dest:it.rdst, data:cp0_tohost }); 5'd25 : begin - $display( "**** EOF Requested\n "); +// $display( "**** EOF Requested\n "); let sample = inAudioFifo.first(); case (sample) matches tagged EndOfFile : @@ -515,7 +515,7 @@ endcase end 5'd28 : begin - $display( "***** Reqesting Sample \n"); +// $display( "***** Reqesting Sample \n"); let sample = inAudioFifo.first(); // is this going to cause perf. delay? if (sample matches tagged Sample .audio) // if it is EOF another rule sets the cp0_audioEOF wbQ.enq(tagged WB_ALU {dest:it.rdst, data:zext(pack(audio)) }); // do I need pack? diff -r 49049f97312c -r 2991344775f8 modules/bluespec/Pygar/core/audioCorePipeline.bsv --- a/modules/bluespec/Pygar/core/audioCorePipeline.bsv Thu May 06 08:57:53 2010 -0400 +++ b/modules/bluespec/Pygar/core/audioCorePipeline.bsv Sun May 09 10:58:40 2010 -0400 @@ -49,12 +49,16 @@ module [CONNECTED_MODULE] mkConnectedApplication (); Core core <- mkCore(`VDEV_SCRATCH_MEMORYA); Core anotherCore <- mkCore(`VDEV_SCRATCH_MEMORYB); - + Vector#(2, Volume) channelVols = replicate(127); + Mixer mixer <- mkMixer(2, channelVols); //should be max voices but 2 for now + Reg#(int) cycle <- mkReg(0); + Reg#(int) sampleCount <-mkReg(0); Vector#(2, Reg#(Bool)) ac_fini <- replicateM(mkReg(False)); - // Services Samples - ClientStub_AUDIOCORERRR client_stub <- mkClientStub_AUDIOCORERRR(); +// FIFO#(AudioProcessorUnit) coreOut <- mkFIFO(); + // Services Samples + ClientStub_AUDIOCORERRR client_stub <- mkClientStub_AUDIOCORERRR(); //----------------------------------------------------------- @@ -69,13 +73,28 @@ $fdisplay(stderr, " => Cycle = %d", cycle); endrule + // Send to Mixer + // Right now this is sorta retarded in that I pass from the output fifo into a new fifo + // But I have to mod a bunch of things to fix this and I am not sure I understand + // things well enough to do this quickly. So here it is as it is for now. + rule mix; + let coreOut <- core.sampleOutput.get(); + let anotherOut <- anotherCore.sampleOutput.get(); + mixer.toMixer(AudioStream {voice : 0, data : tagged Valid coreOut}); + mixer.toMixer(AudioStream {voice : 1, data : tagged Valid anotherOut}); + endrule + rule feedOutput; - let pipelineData <- core.sampleOutput.get(); + // let pipelineData <- core.sampleOutput.get(); + let pipeOut <- mixer.mainOut.get(); + AudioProcessorControl endOfFileTag = EndOfFile; AudioProcessorControl sampleTag = Data; - $display("PIPE writes sample\n"); - case (pipelineData) matches + sampleCount <= sampleCount+1; + + $display("PIPE writes sample %x\n", sampleCount); + case (pipeOut) matches tagged EndOfFile: begin client_stub.makeRequest_SendProcessedStream(zeroExtend(pack(endOfFileTag)),?); @@ -84,11 +103,11 @@ tagged Sample .sample: client_stub.makeRequest_SendProcessedStream(zeroExtend(pack(sampleTag)), zeroExtend(pack(sample))); endcase - endrule + endrule // Programming ghetto style! // right now I am repeating this rule for my second core. - (* conservative_implicit_conditions *) +/* (* conservative_implicit_conditions *) rule feedAnotherOutput; let pipelineData <- anotherCore.sampleOutput.get(); AudioProcessorControl endOfFileTag = EndOfFile; @@ -105,7 +124,7 @@ client_stub.makeRequest_SendProcessedStream(zeroExtend(pack(sampleTag)), zeroExtend(pack(sample))); endcase endrule - +*/ // Can generally just stick with the EOF but since I have two Cores no mixer... /*(* conservative_implicit_conditions *)