comparison 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
comparison
equal deleted inserted replaced
53:2991344775f8 54:9b4f237e77e1
44 `include "asim/dict/VDEV_SCRATCH.bsh" 44 `include "asim/dict/VDEV_SCRATCH.bsh"
45 45
46 `include "asim/rrr/remote_client_stub_AUDIOCORERRR.bsh" 46 `include "asim/rrr/remote_client_stub_AUDIOCORERRR.bsh"
47 `include "asim/rrr/remote_server_stub_AUDIOCORERRR.bsh" 47 `include "asim/rrr/remote_server_stub_AUDIOCORERRR.bsh"
48 48
49 `define MAX_VOICES 2
50
49 module [CONNECTED_MODULE] mkConnectedApplication (); 51 module [CONNECTED_MODULE] mkConnectedApplication ();
50 Core core <- mkCore(`VDEV_SCRATCH_MEMORYA); 52
51 Core anotherCore <- mkCore(`VDEV_SCRATCH_MEMORYB); 53 // Core core <- mkCore(`VDEV_SCRATCH_MEMORYA);
52 Vector#(2, Volume) channelVols = replicate(127); 54 // Core anotherCore <- mkCore(`VDEV_SCRATCH_MEMORYB);
53 Mixer mixer <- mkMixer(2, channelVols); //should be max voices but 2 for now 55 Vector#(`MAX_VOICES, Volume) channelVols = replicate(127);
56 Mixer mixer <- mkMixer(`MAX_VOICES, channelVols); //should be max voices but 2 for now
54 57
55 Reg#(int) cycle <- mkReg(0); 58 Reg#(int) cycle <- mkReg(0);
56 Reg#(int) sampleCount <-mkReg(0); 59 Reg#(int) sampleCount <-mkReg(0);
57 Vector#(2, Reg#(Bool)) ac_fini <- replicateM(mkReg(False)); 60 Vector#(2, Reg#(Bool)) ac_fini <- replicateM(mkReg(False));
58 61
59 // FIFO#(AudioProcessorUnit) coreOut <- mkFIFO();
60 // Services Samples 62 // Services Samples
61 ClientStub_AUDIOCORERRR client_stub <- mkClientStub_AUDIOCORERRR(); 63 ClientStub_AUDIOCORERRR client_stub <- mkClientStub_AUDIOCORERRR();
62 64
63 65
64 //----------------------------------------------------------- 66 //-----------------------------------------------------------
65 // Debug port 67 // Debug port
66 68
67 ServerStub_AUDIOCORERRR server_stub <- mkServerStub_AUDIOCORERRR(); 69 ServerStub_AUDIOCORERRR server_stub <- mkServerStub_AUDIOCORERRR();
68 70
71 // Create Cores
72 Vector#(`MAX_VOICES, Core) cores;
73 for (Integer n = 0; n < `MAX_VOICES; n = n + 1)
74 begin
75 case (n)
76 0 : cores[n] <- mkCore(`VDEV_SCRATCH_MEMORYA);
77 1 : cores[n] <- mkCore(`VDEV_SCRATCH_MEMORYB);
78 endcase
79 end
69 80
70 // this is for the tracing 81 // this is for the tracing
71 rule printCycles; 82 rule printCycles;
72 cycle <= cycle+1; 83 cycle <= cycle+1;
73 $fdisplay(stderr, " => Cycle = %d", cycle); 84 $fdisplay(stderr, " => Cycle = %d", cycle);
75 86
76 // Send to Mixer 87 // Send to Mixer
77 // Right now this is sorta retarded in that I pass from the output fifo into a new fifo 88 // Right now this is sorta retarded in that I pass from the output fifo into a new fifo
78 // But I have to mod a bunch of things to fix this and I am not sure I understand 89 // But I have to mod a bunch of things to fix this and I am not sure I understand
79 // things well enough to do this quickly. So here it is as it is for now. 90 // things well enough to do this quickly. So here it is as it is for now.
80 rule mix; 91 rule mix;
81 let coreOut <- core.sampleOutput.get(); 92 for (Integer i = 0; i < `MAX_VOICES; i = i + 1)
82 let anotherOut <- anotherCore.sampleOutput.get(); 93 begin
83 mixer.toMixer(AudioStream {voice : 0, data : tagged Valid coreOut}); 94 let coreOut <- cores[i].sampleOutput.get();
84 mixer.toMixer(AudioStream {voice : 1, data : tagged Valid anotherOut}); 95 mixer.toMixer(AudioStream {voice : fromInteger(i), data: tagged Valid coreOut});
96 end
97
98 // let coreOut <- core.sampleOutput.get();
99 // mixer.toMixer(AudioStream {voice : 0, data : tagged Valid coreOut});
100 // mixer.toMixer(AudioStream {voice : 1, data : tagged Valid anotherOut});
85 endrule 101 endrule
86 102
87 rule feedOutput; 103 rule feedOutput;
88 // let pipelineData <- core.sampleOutput.get();
89 let pipeOut <- mixer.mainOut.get(); 104 let pipeOut <- mixer.mainOut.get();
90 105
91 AudioProcessorControl endOfFileTag = EndOfFile; 106 AudioProcessorControl endOfFileTag = EndOfFile;
92 AudioProcessorControl sampleTag = Data; 107 AudioProcessorControl sampleTag = Data;
93 108
94 sampleCount <= sampleCount+1; 109 sampleCount <= sampleCount+1;
95 110
96 $display("PIPE writes sample %x\n", sampleCount); 111 $display("PIPE writes sample %d", sampleCount);
97 case (pipeOut) matches 112 case (pipeOut) matches
98 tagged EndOfFile: 113 tagged EndOfFile:
99 begin 114 begin
100 client_stub.makeRequest_SendProcessedStream(zeroExtend(pack(endOfFileTag)),?); 115 client_stub.makeRequest_SendProcessedStream(zeroExtend(pack(endOfFileTag)),?);
101 ac_fini[0] <= True; 116 ac_fini[0] <= True;
102 end 117 end
103 tagged Sample .sample: 118 tagged Sample .sample:
104 client_stub.makeRequest_SendProcessedStream(zeroExtend(pack(sampleTag)), zeroExtend(pack(sample))); 119 client_stub.makeRequest_SendProcessedStream(zeroExtend(pack(sampleTag)), zeroExtend(pack(sample)));
105 endcase 120 endcase
106 endrule 121 endrule
107
108 // Programming ghetto style!
109 // right now I am repeating this rule for my second core.
110 /* (* conservative_implicit_conditions *)
111 rule feedAnotherOutput;
112 let pipelineData <- anotherCore.sampleOutput.get();
113 AudioProcessorControl endOfFileTag = EndOfFile;
114 AudioProcessorControl sampleTag = Data;
115
116 $display("PIPE writes another sample\n");
117 case (pipelineData) matches
118 tagged EndOfFile:
119 begin
120 client_stub.makeRequest_SendProcessedStream(zeroExtend(pack(endOfFileTag)),?);
121 ac_fini[1] <= True;
122 end
123 tagged Sample .sample:
124 client_stub.makeRequest_SendProcessedStream(zeroExtend(pack(sampleTag)), zeroExtend(pack(sample)));
125 endcase
126 endrule
127 */
128 122
129 // Can generally just stick with the EOF but since I have two Cores no mixer... 123 // Can generally just stick with the EOF but since I have two Cores no mixer...
130 /*(* conservative_implicit_conditions *) 124 /*(* conservative_implicit_conditions *)
131 rule sendTerminate; 125 rule sendTerminate;
132 Bool done = True; 126 Bool done = True;
162 // $display("lsp: PIPE received Data "); 156 // $display("lsp: PIPE received Data ");
163 // core.sampleInput.put(tagged Sample unpack(truncate(command.sample))); 157 // core.sampleInput.put(tagged Sample unpack(truncate(command.sample)));
164 inSample = tagged Sample unpack(truncate(command.sample)); 158 inSample = tagged Sample unpack(truncate(command.sample));
165 end 159 end
166 160
167 case (channel) 161 cores[channel].sampleInput.put(inSample);
168 0 : core.sampleInput.put(inSample);
169 1 : anotherCore.sampleInput.put(inSample);
170 endcase
171 162
172 endrule 163 endrule
173 endmodule 164 endmodule