Mercurial > pygar
comparison modules/bluespec/Pygar/core/audioCorePipeline.bsv @ 68:44cc00df1168 pygar svn.69
[svn r69] runs separate eofs (I think)
author | punk |
---|---|
date | Wed, 12 May 2010 00:06:05 -0400 |
parents | 9b4f237e77e1 |
children |
comparison
equal
deleted
inserted
replaced
67:0ede0715dbd6 | 68:44cc00df1168 |
---|---|
48 | 48 |
49 `define MAX_VOICES 2 | 49 `define MAX_VOICES 2 |
50 | 50 |
51 module [CONNECTED_MODULE] mkConnectedApplication (); | 51 module [CONNECTED_MODULE] mkConnectedApplication (); |
52 | 52 |
53 // Core core <- mkCore(`VDEV_SCRATCH_MEMORYA); | |
54 // Core anotherCore <- mkCore(`VDEV_SCRATCH_MEMORYB); | |
55 Vector#(`MAX_VOICES, Volume) channelVols = replicate(127); | 53 Vector#(`MAX_VOICES, Volume) channelVols = replicate(127); |
56 Mixer mixer <- mkMixer(`MAX_VOICES, channelVols); //should be max voices but 2 for now | 54 Mixer mixer <- mkMixer(`MAX_VOICES, channelVols); //should be max voices but 2 for now |
57 | 55 |
58 Reg#(int) cycle <- mkReg(0); | 56 Reg#(Bit#(32)) cycle <- mkReg(0); |
59 Reg#(int) sampleCount <-mkReg(0); | 57 Reg#(Bit#(32)) sampleCountIn <-mkReg(0); |
60 Vector#(2, Reg#(Bool)) ac_fini <- replicateM(mkReg(False)); | 58 Reg#(Bit#(32)) sampleCountOut <-mkReg(0); |
59 Vector#(`MAX_VOICES, Reg#(Bit#(32))) pc <-replicateM(mkReg(0)); //tracks pcs from cores for debug purposes | |
60 Vector#(`MAX_VOICES, Reg#(Bool)) channelFini <- replicateM(mkReg(False)); | |
61 | 61 |
62 // Services Samples | 62 // Services Samples |
63 ClientStub_AUDIOCORERRR client_stub <- mkClientStub_AUDIOCORERRR(); | 63 ClientStub_AUDIOCORERRR client_stub <- mkClientStub_AUDIOCORERRR(); |
64 | 64 |
65 | |
66 //----------------------------------------------------------- | 65 //----------------------------------------------------------- |
67 // Debug port | 66 // Debug port |
68 | 67 |
69 ServerStub_AUDIOCORERRR server_stub <- mkServerStub_AUDIOCORERRR(); | 68 ServerStub_AUDIOCORERRR server_stub <- mkServerStub_AUDIOCORERRR(); |
70 | 69 |
73 for (Integer n = 0; n < `MAX_VOICES; n = n + 1) | 72 for (Integer n = 0; n < `MAX_VOICES; n = n + 1) |
74 begin | 73 begin |
75 case (n) | 74 case (n) |
76 0 : cores[n] <- mkCore(`VDEV_SCRATCH_MEMORYA); | 75 0 : cores[n] <- mkCore(`VDEV_SCRATCH_MEMORYA); |
77 1 : cores[n] <- mkCore(`VDEV_SCRATCH_MEMORYB); | 76 1 : cores[n] <- mkCore(`VDEV_SCRATCH_MEMORYB); |
77 2 : cores[n] <- mkCore(`VDEV_SCRATCH_MEMORYC); | |
78 3 : cores[n] <- mkCore(`VDEV_SCRATCH_MEMORYD); | |
79 4 : cores[n] <- mkCore(`VDEV_SCRATCH_MEMORYE); | |
80 5 : cores[n] <- mkCore(`VDEV_SCRATCH_MEMORYF); | |
81 6 : cores[n] <- mkCore(`VDEV_SCRATCH_MEMORYG); | |
82 7 : cores[n] <- mkCore(`VDEV_SCRATCH_MEMORYH); | |
83 8 : cores[n] <- mkCore(`VDEV_SCRATCH_MEMORYI); | |
84 9 : cores[n] <- mkCore(`VDEV_SCRATCH_MEMORYJ); | |
85 10 : cores[n] <- mkCore(`VDEV_SCRATCH_MEMORYK); | |
86 11 : cores[n] <- mkCore(`VDEV_SCRATCH_MEMORYL); | |
87 12 : cores[n] <- mkCore(`VDEV_SCRATCH_MEMORYM); | |
88 13 : cores[n] <- mkCore(`VDEV_SCRATCH_MEMORYN); | |
89 14 : cores[n] <- mkCore(`VDEV_SCRATCH_MEMORYO); | |
90 15 : cores[n] <- mkCore(`VDEV_SCRATCH_MEMORYP); | |
91 16 : cores[n] <- mkCore(`VDEV_SCRATCH_MEMORYQ); | |
92 17 : cores[n] <- mkCore(`VDEV_SCRATCH_MEMORYR); | |
93 18 : cores[n] <- mkCore(`VDEV_SCRATCH_MEMORYS); | |
94 19 : cores[n] <- mkCore(`VDEV_SCRATCH_MEMORYT); | |
95 20 : cores[n] <- mkCore(`VDEV_SCRATCH_MEMORYU); | |
96 21 : cores[n] <- mkCore(`VDEV_SCRATCH_MEMORYV); | |
97 22 : cores[n] <- mkCore(`VDEV_SCRATCH_MEMORYW); | |
98 23 : cores[n] <- mkCore(`VDEV_SCRATCH_MEMORYX); | |
99 24 : cores[n] <- mkCore(`VDEV_SCRATCH_MEMORYY); | |
100 25 : cores[n] <- mkCore(`VDEV_SCRATCH_MEMORYZ); | |
78 endcase | 101 endcase |
79 end | 102 end |
80 | 103 |
104 function Integer countFiniVoices(); | |
105 Integer count = 0; | |
106 for (Integer i = 0; i < `MAX_VOICES; i = i + 1) | |
107 if (channelFini[i]) count = count + 1; | |
108 return count; | |
109 endfunction | |
110 | |
81 // this is for the tracing | 111 // this is for the tracing |
82 rule printCycles; | 112 rule printCycles; |
83 cycle <= cycle+1; | 113 cycle <= cycle+1; |
84 $fdisplay(stderr, " => Cycle = %d", cycle); | 114 $fdisplay(stderr, " => Cycle = %d", cycle); |
85 endrule | 115 endrule |
116 | |
117 // get the pc for trace purposes | |
118 rule getPC; | |
119 for (Integer i = 0; i < `MAX_VOICES; i = i + 1) | |
120 begin | |
121 let val <- cores[i].pc.get(); | |
122 pc[i] <= val; | |
123 end | |
124 endrule | |
86 | 125 |
87 // Send to Mixer | 126 // Send to Mixer |
88 // Right now this is sorta retarded in that I pass from the output fifo into a new fifo | 127 // Right now this is sorta retarded in that I pass from the output fifo into a new fifo |
89 // But I have to mod a bunch of things to fix this and I am not sure I understand | 128 // But I have to mod a bunch of things to fix this and I am not sure I understand |
90 // things well enough to do this quickly. So here it is as it is for now. | 129 // things well enough to do this quickly. So here it is as it is for now. |
91 rule mix; | 130 rule mix; |
92 for (Integer i = 0; i < `MAX_VOICES; i = i + 1) | 131 for (Integer i = 0; i < `MAX_VOICES; i = i + 1) |
93 begin | 132 begin |
94 let coreOut <- cores[i].sampleOutput.get(); | 133 let coreOut <- cores[i].sampleOutput.get(); |
95 mixer.toMixer(AudioStream {voice : fromInteger(i), data: tagged Valid coreOut}); | 134 mixer.toMixer(AudioStream {voice : fromInteger(i), data:coreOut.data}); |
96 end | 135 end |
97 | 136 endrule |
98 // let coreOut <- core.sampleOutput.get(); | 137 |
99 // mixer.toMixer(AudioStream {voice : 0, data : tagged Valid coreOut}); | |
100 // mixer.toMixer(AudioStream {voice : 1, data : tagged Valid anotherOut}); | |
101 endrule | |
102 | |
103 rule feedOutput; | 138 rule feedOutput; |
104 let pipeOut <- mixer.mainOut.get(); | 139 let pipeOut <- mixer.mainOut.get(); |
105 | 140 |
106 AudioProcessorControl endOfFileTag = EndOfFile; | 141 AudioProcessorControl endOfFileTag = EndOfFile; |
107 AudioProcessorControl sampleTag = Data; | 142 AudioProcessorControl sampleTag = Data; |
108 | 143 |
109 sampleCount <= sampleCount+1; | 144 sampleCountOut <= sampleCountOut+1; |
110 | 145 |
111 $display("PIPE writes sample %d", sampleCount); | 146 $display("PIPE writes sample %d", sampleCountOut); |
112 case (pipeOut) matches | 147 case (pipeOut) matches |
113 tagged EndOfFile: | 148 tagged EndOfFile: |
114 begin | 149 begin |
115 client_stub.makeRequest_SendProcessedStream(zeroExtend(pack(endOfFileTag)),?); | 150 client_stub.makeRequest_SendProcessedStream(zeroExtend(pack(endOfFileTag)),?); |
116 ac_fini[0] <= True; | 151 for (Integer i = 1; i < `MAX_VOICES; i = i+1) channelFini[i] <= False; |
152 //This will report conflict with | |
153 //the other setting of channelFini at input except they are mutually | |
154 //exclusive since this is only hit after all input finished | |
117 end | 155 end |
118 tagged Sample .sample: | 156 tagged Sample .sample: |
119 client_stub.makeRequest_SendProcessedStream(zeroExtend(pack(sampleTag)), zeroExtend(pack(sample))); | 157 client_stub.makeRequest_SendProcessedStream(zeroExtend(pack(sampleTag)), zeroExtend(pack(sample))); |
120 endcase | 158 endcase |
121 endrule | 159 endrule |
132 | 170 |
133 endrule | 171 endrule |
134 */ | 172 */ |
135 | 173 |
136 //***** SERVER Side ***** | 174 //***** SERVER Side ***** |
137 | 175 // this requires me to switch the processor to handle this which I will do later. |
176 // When a file has finished, want the system to pass invalid audiostreams | |
177 rule fillFinished; | |
178 for (Integer i = 1; i < `MAX_VOICES; i = i+1) | |
179 begin | |
180 if (channelFini[i]) | |
181 cores[i].sampleInput.put(AudioStream {voice : fromInteger(i), data: tagged Invalid}); | |
182 end | |
183 endrule | |
184 | |
138 (* conservative_implicit_conditions *) | 185 (* conservative_implicit_conditions *) |
139 rule feedInput; | 186 rule feedInput; |
140 let command <- server_stub.acceptRequest_SendUnprocessedStream(); | 187 let command <- server_stub.acceptRequest_SendUnprocessedStream(); |
141 AudioProcessorControl ctrl = unpack(truncate(command.ctrl)); | 188 AudioProcessorControl ctrl = unpack(truncate(command.ctrl)); |
142 | 189 |
143 VoiceId channel = unpack(truncate(command.channel)); | 190 VoiceId channel = unpack(truncate(command.channel)); |
144 // $display("rlm: %x", test); | 191 // $display("PIPE: Incoming sample to channel %x", channel); |
145 | 192 |
146 AudioProcessorUnit inSample; | 193 AudioProcessorUnit inSample; |
147 | 194 |
148 if(ctrl == EndOfFile) | 195 if(ctrl == EndOfFile) |
149 begin | 196 begin |
150 $display("lsp: PIPE received EOF "); | 197 $display("lsp: PIPE received EOF "); |
151 inSample = tagged EndOfFile; | 198 inSample = tagged EndOfFile; |
152 // core.sampleInput.put(tagged EndOfFile); | 199 channelFini[channel] <= True; |
153 end | 200 end |
154 else | 201 else |
155 begin | 202 begin |
156 // $display("lsp: PIPE received Data "); | 203 // $display("lsp: PIPE received Data "); |
157 // core.sampleInput.put(tagged Sample unpack(truncate(command.sample))); | |
158 inSample = tagged Sample unpack(truncate(command.sample)); | 204 inSample = tagged Sample unpack(truncate(command.sample)); |
159 end | 205 end |
160 | 206 |
161 cores[channel].sampleInput.put(inSample); | 207 if (!channelFini[channel]) |
162 | 208 cores[channel].sampleInput.put(AudioStream {voice: channel, data: tagged Valid inSample }); |
163 endrule | 209 else $display("PIPE ERROR: Trying to send to Stream officially done"); |
210 | |
211 endrule | |
212 | |
213 (* conservative_implicit_conditions *) | |
214 rule handleCPUToHost; | |
215 let req <- server_stub.acceptRequest_ReadCPUToHost(); | |
216 case (req) | |
217 1: server_stub.sendResponse_ReadCPUToHost(cycle); | |
218 2: server_stub.sendResponse_ReadCPUToHost(sampleCountIn); | |
219 3: server_stub.sendResponse_ReadCPUToHost(sampleCountOut); | |
220 4: server_stub.sendResponse_ReadCPUToHost(fromInteger(countFiniVoices())); | |
221 default : if (req < 10 + `MAX_VOICES) | |
222 server_stub.sendResponse_ReadCPUToHost(pc[req-10]); | |
223 endcase | |
224 endrule | |
225 | |
164 endmodule | 226 endmodule |