Mercurial > pygar
changeset 53:2991344775f8 pygar svn.54
[svn r54] mixer integrated
author | punk |
---|---|
date | Sun, 09 May 2010 10:58:40 -0400 |
parents | 49049f97312c |
children | 9b4f237e77e1 |
files | modules/bluespec/Pygar/core/AudioCoreRRR.cpp modules/bluespec/Pygar/core/AudioCoreSystem.cpp modules/bluespec/Pygar/core/Mixer.bsv modules/bluespec/Pygar/core/Processor.bsv modules/bluespec/Pygar/core/audioCorePipeline.bsv |
diffstat | 5 files changed, 59 insertions(+), 44 deletions(-) [+] |
line wrap: on
line diff
1.1 --- a/modules/bluespec/Pygar/core/AudioCoreRRR.cpp Thu May 06 08:57:53 2010 -0400 1.2 +++ b/modules/bluespec/Pygar/core/AudioCoreRRR.cpp Sun May 09 10:58:40 2010 -0400 1.3 @@ -120,8 +120,8 @@ 1.4 } 1.5 1.6 // Long term this should be in the data portion. But until I have code running, keep it here. 1.7 - count++; 1.8 - if (count == 2) 1.9 + // count++; 1.10 + //if (count == 2) 1.11 CONNECTED_APPLICATION_CLASS::EndSimulation(); 1.12 break; 1.13
2.1 --- a/modules/bluespec/Pygar/core/AudioCoreSystem.cpp Thu May 06 08:57:53 2010 -0400 2.2 +++ b/modules/bluespec/Pygar/core/AudioCoreSystem.cpp Sun May 09 10:58:40 2010 -0400 2.3 @@ -92,7 +92,7 @@ 2.4 //Send data to the machine here. 2.5 //rlm: two files 2.6 inputFile = fopen("input.pcm","r"); 2.7 - inputFile = fopen("input1.pcm", "r"); 2.8 + inputFile1 = fopen("input1.pcm", "r"); 2.9 2.10 assert(inputFile1); 2.11 assert(inputFile); 2.12 @@ -159,5 +159,5 @@ 2.13 STATS_DEVICE_SERVER_CLASS::GetInstance()->EmitFile(); 2.14 2.15 fflush(stdout); 2.16 - exit(0); 2.17 + // exit(0); 2.18 }
3.1 --- a/modules/bluespec/Pygar/core/Mixer.bsv Thu May 06 08:57:53 2010 -0400 3.2 +++ b/modules/bluespec/Pygar/core/Mixer.bsv Sun May 09 10:58:40 2010 -0400 3.3 @@ -27,8 +27,6 @@ 3.4 import FIFO::*; 3.5 import FixedPoint::*; 3.6 3.7 -`define MAX_VOICES 2 3.8 - 3.9 //AWB includes 3.10 `include "asim/provides/low_level_platform_interface.bsh" 3.11 `include "asim/provides/soft_connections.bsh" 3.12 @@ -38,44 +36,40 @@ 3.13 `include "asim/provides/audio_pipe_types.bsh" 3.14 `include "asim/provides/path_types.bsh" 3.15 3.16 -interface PutMixerIn; 3.17 - method Action sendVoiceIn(AudioStream voiceInput); 3.18 -endinterface 3.19 - 3.20 interface Mixer; 3.21 - interface PutMixerIn toMixer; 3.22 - interface Get#(AudioProcessorUnit) mixerOut; 3.23 + method Action toMixer(AudioStream streamIn); 3.24 + interface Get#(AudioProcessorUnit) mainOut; 3.25 endinterface 3.26 3.27 -function Bool isAudioFini(Vector#(`MAX_VOICES, Reg#(Bool)) voiceStat); 3.28 - Bool result = True; 3.29 - for (Integer i = 0; i < `MAX_VOICES; i = i+1) 3.30 - begin 3.31 - result = voiceStat[i] && result; 3.32 - end 3.33 - return result; 3.34 -endfunction 3.35 +module [CONNECTED_MODULE] mkMixer#(Integer numVoices, Vector#(numVoices, Volume) scalars) (Mixer); 3.36 3.37 -module [CONNECTED_MODULE] mkMixer#(Vector#(`MAX_VOICES, Volume) scalars) (Mixer); 3.38 + function Bool isAudioFini(Vector#(numVoices, Reg#(Bool)) voiceStat); 3.39 + Bool result = True; 3.40 + for (Integer i = 0; i < numVoices; i = i+1) 3.41 + begin 3.42 + result = voiceStat[i] && result; 3.43 + end 3.44 + return result; 3.45 + endfunction 3.46 3.47 3.48 // Instantiate the modules 3.49 - Vector#(`MAX_VOICES, FIFO#(AudioPipeUnit)) voicesIn <- replicateM(mkFIFO()); 3.50 + Vector#(numVoices, FIFO#(AudioPipeUnit)) voicesIn <- replicateM(mkFIFO()); 3.51 // <- newVector(); 3.52 - Vector#(`MAX_VOICES, Reg#(Bool)) voiceFini <- replicateM(mkReg(False)); 3.53 + Vector#(numVoices, Reg#(Bool)) voiceFini <- replicateM(mkReg(False)); 3.54 3.55 FIFO#(AudioProcessorUnit) masterFifo <- mkFIFO(); 3.56 3.57 rule sendEnd(isAudioFini(voiceFini)); 3.58 masterFifo.enq(tagged EndOfFile); 3.59 //prep for reset 3.60 - for (Integer i = 0; i < `MAX_VOICES; i = i+1) 3.61 + for (Integer i = 0; i < numVoices; i = i+1) 3.62 voiceFini[i] <= False; 3.63 endrule 3.64 3.65 rule processSample(!isAudioFini(voiceFini)); //implicit on all voiceFifos having data 3.66 FixedPoint#(32,32) sum = 0; //this should allow 16 voices at 16 bits without messing up 3.67 - for (Integer i = 0; i < `MAX_VOICES; i = i+1) 3.68 + for (Integer i = 0; i < numVoices; i = i+1) 3.69 begin 3.70 if (voicesIn[i].first() matches tagged Valid .data) 3.71 begin 3.72 @@ -91,17 +85,19 @@ 3.73 voicesIn[i].deq(); 3.74 end 3.75 3.76 - masterFifo.enq(tagged Sample truncate(fxptGetInt(sum >> `MAX_VOICES))); 3.77 + masterFifo.enq(tagged Sample truncate(fxptGetInt(sum >> numVoices))); 3.78 endrule 3.79 3.80 // Internal connections 3.81 3.82 - interface PutMixerIn toMixer; 3.83 - method Action sendVoiceIn(AudioStream voiceInput); 3.84 - voicesIn[voiceInput.voice].enq(voiceInput.data); 3.85 - endmethod 3.86 - endinterface 3.87 - 3.88 - interface Get mixerOut = fifoToGet(masterFifo); 3.89 +// method Action loadMixerFifos(AudioStream voiceInput); 3.90 +// voicesIn[voiceInput.voice].enq(voiceInput.data); 3.91 +// endmethod 3.92 + 3.93 + method Action toMixer(AudioStream streamIn); 3.94 + voicesIn[streamIn.voice].enq(streamIn.data); 3.95 + endmethod 3.96 + 3.97 + interface Get mainOut = fifoToGet(masterFifo); 3.98 3.99 endmodule
4.1 --- a/modules/bluespec/Pygar/core/Processor.bsv Thu May 06 08:57:53 2010 -0400 4.2 +++ b/modules/bluespec/Pygar/core/Processor.bsv Sun May 09 10:58:40 2010 -0400 4.3 @@ -501,7 +501,7 @@ 4.4 5'd20 : wbQ.enq(tagged WB_ALU {dest:it.rdst, data:cp0_fromhost }); 4.5 5'd21 : wbQ.enq(tagged WB_ALU {dest:it.rdst, data:cp0_tohost }); 4.6 5'd25 : begin 4.7 - $display( "**** EOF Requested\n "); 4.8 +// $display( "**** EOF Requested\n "); 4.9 let sample = inAudioFifo.first(); 4.10 case (sample) matches 4.11 tagged EndOfFile : 4.12 @@ -515,7 +515,7 @@ 4.13 endcase 4.14 end 4.15 5'd28 : begin 4.16 - $display( "***** Reqesting Sample \n"); 4.17 +// $display( "***** Reqesting Sample \n"); 4.18 let sample = inAudioFifo.first(); // is this going to cause perf. delay? 4.19 if (sample matches tagged Sample .audio) // if it is EOF another rule sets the cp0_audioEOF 4.20 wbQ.enq(tagged WB_ALU {dest:it.rdst, data:zext(pack(audio)) }); // do I need pack?
5.1 --- a/modules/bluespec/Pygar/core/audioCorePipeline.bsv Thu May 06 08:57:53 2010 -0400 5.2 +++ b/modules/bluespec/Pygar/core/audioCorePipeline.bsv Sun May 09 10:58:40 2010 -0400 5.3 @@ -49,12 +49,16 @@ 5.4 module [CONNECTED_MODULE] mkConnectedApplication (); 5.5 Core core <- mkCore(`VDEV_SCRATCH_MEMORYA); 5.6 Core anotherCore <- mkCore(`VDEV_SCRATCH_MEMORYB); 5.7 - 5.8 + Vector#(2, Volume) channelVols = replicate(127); 5.9 + Mixer mixer <- mkMixer(2, channelVols); //should be max voices but 2 for now 5.10 + 5.11 Reg#(int) cycle <- mkReg(0); 5.12 + Reg#(int) sampleCount <-mkReg(0); 5.13 Vector#(2, Reg#(Bool)) ac_fini <- replicateM(mkReg(False)); 5.14 5.15 - // Services Samples 5.16 - ClientStub_AUDIOCORERRR client_stub <- mkClientStub_AUDIOCORERRR(); 5.17 +// FIFO#(AudioProcessorUnit) coreOut <- mkFIFO(); 5.18 + // Services Samples 5.19 + ClientStub_AUDIOCORERRR client_stub <- mkClientStub_AUDIOCORERRR(); 5.20 5.21 5.22 //----------------------------------------------------------- 5.23 @@ -69,13 +73,28 @@ 5.24 $fdisplay(stderr, " => Cycle = %d", cycle); 5.25 endrule 5.26 5.27 + // Send to Mixer 5.28 + // Right now this is sorta retarded in that I pass from the output fifo into a new fifo 5.29 + // But I have to mod a bunch of things to fix this and I am not sure I understand 5.30 + // things well enough to do this quickly. So here it is as it is for now. 5.31 + rule mix; 5.32 + let coreOut <- core.sampleOutput.get(); 5.33 + let anotherOut <- anotherCore.sampleOutput.get(); 5.34 + mixer.toMixer(AudioStream {voice : 0, data : tagged Valid coreOut}); 5.35 + mixer.toMixer(AudioStream {voice : 1, data : tagged Valid anotherOut}); 5.36 + endrule 5.37 + 5.38 rule feedOutput; 5.39 - let pipelineData <- core.sampleOutput.get(); 5.40 + // let pipelineData <- core.sampleOutput.get(); 5.41 + let pipeOut <- mixer.mainOut.get(); 5.42 + 5.43 AudioProcessorControl endOfFileTag = EndOfFile; 5.44 AudioProcessorControl sampleTag = Data; 5.45 5.46 - $display("PIPE writes sample\n"); 5.47 - case (pipelineData) matches 5.48 + sampleCount <= sampleCount+1; 5.49 + 5.50 + $display("PIPE writes sample %x\n", sampleCount); 5.51 + case (pipeOut) matches 5.52 tagged EndOfFile: 5.53 begin 5.54 client_stub.makeRequest_SendProcessedStream(zeroExtend(pack(endOfFileTag)),?); 5.55 @@ -84,11 +103,11 @@ 5.56 tagged Sample .sample: 5.57 client_stub.makeRequest_SendProcessedStream(zeroExtend(pack(sampleTag)), zeroExtend(pack(sample))); 5.58 endcase 5.59 - endrule 5.60 + endrule 5.61 5.62 // Programming ghetto style! 5.63 // right now I am repeating this rule for my second core. 5.64 - (* conservative_implicit_conditions *) 5.65 +/* (* conservative_implicit_conditions *) 5.66 rule feedAnotherOutput; 5.67 let pipelineData <- anotherCore.sampleOutput.get(); 5.68 AudioProcessorControl endOfFileTag = EndOfFile; 5.69 @@ -105,7 +124,7 @@ 5.70 client_stub.makeRequest_SendProcessedStream(zeroExtend(pack(sampleTag)), zeroExtend(pack(sample))); 5.71 endcase 5.72 endrule 5.73 - 5.74 +*/ 5.75 5.76 // Can generally just stick with the EOF but since I have two Cores no mixer... 5.77 /*(* conservative_implicit_conditions *)