Mercurial > pygar
diff modules/bluespec/Pygar/core/audioCorePipeline.bsv @ 54:9b4f237e77e1 pygar svn.55
[svn r55] input a bit more parameterized
author | punk |
---|---|
date | Sun, 09 May 2010 12:24:35 -0400 |
parents | 2991344775f8 |
children | 44cc00df1168 |
line wrap: on
line diff
1.1 --- a/modules/bluespec/Pygar/core/audioCorePipeline.bsv Sun May 09 10:58:40 2010 -0400 1.2 +++ b/modules/bluespec/Pygar/core/audioCorePipeline.bsv Sun May 09 12:24:35 2010 -0400 1.3 @@ -46,17 +46,19 @@ 1.4 `include "asim/rrr/remote_client_stub_AUDIOCORERRR.bsh" 1.5 `include "asim/rrr/remote_server_stub_AUDIOCORERRR.bsh" 1.6 1.7 +`define MAX_VOICES 2 1.8 + 1.9 module [CONNECTED_MODULE] mkConnectedApplication (); 1.10 - Core core <- mkCore(`VDEV_SCRATCH_MEMORYA); 1.11 - Core anotherCore <- mkCore(`VDEV_SCRATCH_MEMORYB); 1.12 - Vector#(2, Volume) channelVols = replicate(127); 1.13 - Mixer mixer <- mkMixer(2, channelVols); //should be max voices but 2 for now 1.14 + 1.15 + // Core core <- mkCore(`VDEV_SCRATCH_MEMORYA); 1.16 + // Core anotherCore <- mkCore(`VDEV_SCRATCH_MEMORYB); 1.17 + Vector#(`MAX_VOICES, Volume) channelVols = replicate(127); 1.18 + Mixer mixer <- mkMixer(`MAX_VOICES, channelVols); //should be max voices but 2 for now 1.19 1.20 Reg#(int) cycle <- mkReg(0); 1.21 Reg#(int) sampleCount <-mkReg(0); 1.22 Vector#(2, Reg#(Bool)) ac_fini <- replicateM(mkReg(False)); 1.23 1.24 -// FIFO#(AudioProcessorUnit) coreOut <- mkFIFO(); 1.25 // Services Samples 1.26 ClientStub_AUDIOCORERRR client_stub <- mkClientStub_AUDIOCORERRR(); 1.27 1.28 @@ -66,6 +68,15 @@ 1.29 1.30 ServerStub_AUDIOCORERRR server_stub <- mkServerStub_AUDIOCORERRR(); 1.31 1.32 + // Create Cores 1.33 + Vector#(`MAX_VOICES, Core) cores; 1.34 + for (Integer n = 0; n < `MAX_VOICES; n = n + 1) 1.35 + begin 1.36 + case (n) 1.37 + 0 : cores[n] <- mkCore(`VDEV_SCRATCH_MEMORYA); 1.38 + 1 : cores[n] <- mkCore(`VDEV_SCRATCH_MEMORYB); 1.39 + endcase 1.40 + end 1.41 1.42 // this is for the tracing 1.43 rule printCycles; 1.44 @@ -77,15 +88,19 @@ 1.45 // Right now this is sorta retarded in that I pass from the output fifo into a new fifo 1.46 // But I have to mod a bunch of things to fix this and I am not sure I understand 1.47 // things well enough to do this quickly. So here it is as it is for now. 1.48 - rule mix; 1.49 - let coreOut <- core.sampleOutput.get(); 1.50 - let anotherOut <- anotherCore.sampleOutput.get(); 1.51 - mixer.toMixer(AudioStream {voice : 0, data : tagged Valid coreOut}); 1.52 - mixer.toMixer(AudioStream {voice : 1, data : tagged Valid anotherOut}); 1.53 + rule mix; 1.54 + for (Integer i = 0; i < `MAX_VOICES; i = i + 1) 1.55 + begin 1.56 + let coreOut <- cores[i].sampleOutput.get(); 1.57 + mixer.toMixer(AudioStream {voice : fromInteger(i), data: tagged Valid coreOut}); 1.58 + end 1.59 + 1.60 +// let coreOut <- core.sampleOutput.get(); 1.61 +// mixer.toMixer(AudioStream {voice : 0, data : tagged Valid coreOut}); 1.62 +// mixer.toMixer(AudioStream {voice : 1, data : tagged Valid anotherOut}); 1.63 endrule 1.64 1.65 rule feedOutput; 1.66 - // let pipelineData <- core.sampleOutput.get(); 1.67 let pipeOut <- mixer.mainOut.get(); 1.68 1.69 AudioProcessorControl endOfFileTag = EndOfFile; 1.70 @@ -93,7 +108,7 @@ 1.71 1.72 sampleCount <= sampleCount+1; 1.73 1.74 - $display("PIPE writes sample %x\n", sampleCount); 1.75 + $display("PIPE writes sample %d", sampleCount); 1.76 case (pipeOut) matches 1.77 tagged EndOfFile: 1.78 begin 1.79 @@ -105,27 +120,6 @@ 1.80 endcase 1.81 endrule 1.82 1.83 - // Programming ghetto style! 1.84 - // right now I am repeating this rule for my second core. 1.85 -/* (* conservative_implicit_conditions *) 1.86 - rule feedAnotherOutput; 1.87 - let pipelineData <- anotherCore.sampleOutput.get(); 1.88 - AudioProcessorControl endOfFileTag = EndOfFile; 1.89 - AudioProcessorControl sampleTag = Data; 1.90 - 1.91 - $display("PIPE writes another sample\n"); 1.92 - case (pipelineData) matches 1.93 - tagged EndOfFile: 1.94 - begin 1.95 - client_stub.makeRequest_SendProcessedStream(zeroExtend(pack(endOfFileTag)),?); 1.96 - ac_fini[1] <= True; 1.97 - end 1.98 - tagged Sample .sample: 1.99 - client_stub.makeRequest_SendProcessedStream(zeroExtend(pack(sampleTag)), zeroExtend(pack(sample))); 1.100 - endcase 1.101 - endrule 1.102 -*/ 1.103 - 1.104 // Can generally just stick with the EOF but since I have two Cores no mixer... 1.105 /*(* conservative_implicit_conditions *) 1.106 rule sendTerminate; 1.107 @@ -164,10 +158,7 @@ 1.108 inSample = tagged Sample unpack(truncate(command.sample)); 1.109 end 1.110 1.111 - case (channel) 1.112 - 0 : core.sampleInput.put(inSample); 1.113 - 1 : anotherCore.sampleInput.put(inSample); 1.114 - endcase 1.115 + cores[channel].sampleInput.put(inSample); 1.116 1.117 endrule 1.118 endmodule