# HG changeset patch # User punk # Date 1273637165 14400 # Node ID 44cc00df11687227342bc1a8d069620b7b6e7f5c # Parent 0ede0715dbd66885d30aec271ec64ce8a61c0454 [svn r69] runs separate eofs (I think) diff -r 0ede0715dbd6 -r 44cc00df1168 modules/bluespec/Pygar/core/AudioCoreSystem.cpp --- a/modules/bluespec/Pygar/core/AudioCoreSystem.cpp Tue May 11 23:23:21 2010 -0400 +++ b/modules/bluespec/Pygar/core/AudioCoreSystem.cpp Wed May 12 00:06:05 2010 -0400 @@ -10,10 +10,13 @@ using namespace std; +#define NUM_VOICES 2 + pthread_mutex_t CONNECTED_APPLICATION_CLASS::lock; pthread_cond_t CONNECTED_APPLICATION_CLASS::cond; sem_t CONNECTED_APPLICATION_CLASS::throttle; + // constructor CONNECTED_APPLICATION_CLASS::CONNECTED_APPLICATION_CLASS(VIRTUAL_PLATFORM vp) : @@ -72,6 +75,7 @@ UINT16 sample; UINT16 sample1; + Bool fileFini[NUM_VOICES] = {false, false}; //rlm: not sure if normal ints are ok here; using UINT16 because I know it works UINT16 channel0 = 0; UINT16 channel1 = 1; @@ -80,7 +84,7 @@ int sleepCount = 0; int result = 0; - bool coreFin = false; + int numcCoreFin = 0; printf("SendSide Main\n"); fflush(stdout); @@ -108,19 +112,9 @@ //rlm: here we read both files. later refactor into a function. // also, this will terminate when the FIRST file reaches its end. - while( (fread(&sample, 2, 1, inputFile)) || (fread(&sample1, 2 , 1, inputFile1))) - { /* - printf("hi\n"); - if (!coreFin && (result = clientStub->ReadCPUToHost(0)) != 1) - { - sleepCount++; - } - else if (!coreFin && result == 1) - { - printf("\n***SOFT_CORE PASSED***\n"); - coreFin = true; - } - */ + while( !feof(inputFile) || !feof(inputFile1)) + { + sem_wait(&throttle); if(count%1000 == 0) @@ -128,22 +122,36 @@ count++; //rlm: two files. - // clientStub->SendUnprocessedStream( Data,(UINT32)sample); - clientStub->SendUnprocessedStream((UINT32)channel0 , Data,(UINT32)sample); - clientStub->SendUnprocessedStream((UINT32)channel1 , Data,(UINT32)sample1); - } + + if (!fileFini[0]) + { + if (fread(&sample, 2, 1, inputFile)) + clientStub->SendUnprocessedStream((UINT32)channel0 , Data,(UINT32)sample); + else{ + fileFini[0] = true; + numCoreFini++; + if (numCoreFini >= NUM_VOICES) // Need lock on last eof + // Need to put lock here to prevent potential race condition + pthread_mutex_lock(&lock); + clientStub->SendUnprocessedStream((UINT32)channel0, EndOfFile,0); + } + } + if !fileFini[1]) + { + if (fread(&sample1, 2 , 1, inputFile1)) + clientStub->SendUnprocessedStream((UINT32)channel1 , Data,(UINT32)sample1); + else{ + fileFini[1] = true; + numCoreFini++; + if (numCoreFini >= NUM_VOICES) // Need lock on last eof + // Need to put lock here to prevent potential race condition + pthread_mutex_lock(&lock); + clientStub->SendUnprocessedStream((UINT32)channel1, EndOfFile,0); + } + } + } printf("main: out of loop\n"); - - // Need to put lock here to prevent potential race condition - pthread_mutex_lock(&lock); - - //rlm: have to send end-files to both voices. - // all of these operations wil eventually be moved into functions. - //clientStub->SendUnprocessedStream(EndOfFile,0); - clientStub->SendUnprocessedStream((UINT32)channel0, EndOfFile,0); - clientStub->SendUnprocessedStream((UINT32)channel1, EndOfFile,0); - printf("main: wait for end of file\n"); pthread_cond_wait(&cond, &lock); diff -r 0ede0715dbd6 -r 44cc00df1168 modules/bluespec/Pygar/core/Mixer.bsv --- a/modules/bluespec/Pygar/core/Mixer.bsv Tue May 11 23:23:21 2010 -0400 +++ b/modules/bluespec/Pygar/core/Mixer.bsv Wed May 12 00:06:05 2010 -0400 @@ -69,14 +69,17 @@ 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 + Integer numValid = 0; for (Integer i = 0; i < numVoices; i = i+1) begin if (voicesIn[i].first() matches tagged Valid .data) begin case (data) matches tagged Sample .sample : - sum = sum + ((fromInt(sample) * fromInt(scalars[i])) >> 8); - //shifting right 8 to divide by 256 + begin //shifting right 8 to divide by 256 + sum = sum + ((fromInt(sample) * fromInt(scalars[i])) >> 8); + numValid = numValid + 1; + end tagged EndOfFile : voiceFini[i] <= True; endcase @@ -84,16 +87,12 @@ else voiceFini[i] <= True; voicesIn[i].deq(); end - - masterFifo.enq(tagged Sample truncate(fxptGetInt(sum >> numVoices))); + if (numValid > 0) // If nothing is valid, don't send anything + masterFifo.enq(tagged Sample truncate(fxptGetInt(sum >> numVoices))); endrule // Internal connections -// method Action loadMixerFifos(AudioStream voiceInput); -// voicesIn[voiceInput.voice].enq(voiceInput.data); -// endmethod - method Action toMixer(AudioStream streamIn); voicesIn[streamIn.voice].enq(streamIn.data); endmethod diff -r 0ede0715dbd6 -r 44cc00df1168 modules/bluespec/Pygar/core/Processor.bsv --- a/modules/bluespec/Pygar/core/Processor.bsv Tue May 11 23:23:21 2010 -0400 +++ b/modules/bluespec/Pygar/core/Processor.bsv Wed May 12 00:06:05 2010 -0400 @@ -37,7 +37,6 @@ import ProcTypes::*; import BRegFile::*; import BranchPred::*; -//import PathTypes::*; This is only there to force the debugging //AWB includes `include "asim/provides/low_level_platform_interface.bsh" @@ -57,6 +56,7 @@ // pipeline `include "asim/provides/audio_pipe_types.bsh" +`include "asim/provides/path_types.bsh" //interface CPUToHost; // method Bit#(32) cpuToHost(int req); @@ -71,12 +71,12 @@ // Interface for enabling/disabling statistics on the rest of the core interface Get#(Bool) statsEn_get; -// // Interface to host -// interface CPUToHost tohost; + // Interface to host + interface Get#(Bit#(32)) pcCount; // Interface to Audio Pipeline - interface Get#(AudioProcessorUnit) sampleOutput; - interface Put#(AudioProcessorUnit) sampleInput; + interface Get#(AudioStream) sampleOutput; + interface Put#(AudioStream) sampleInput; endinterface @@ -179,6 +179,8 @@ endcase endfunction + + //----------------------------------------------------------- // Reference processor //----------------------------------------------------------- @@ -213,6 +215,9 @@ Reg#(Bool) cp0_statsEn <- mkReg(False); Reg#(Bool) cp0_audioEOF <- mkReg(False); // Register to let code that EOF is reached Reg#(Bool) cp0_progComp <- mkReg(False); // Register to let processor know that the program is complete (as this terminates) + + Reg#(Bool) code_bypass <- mkReg(True); // Register to enable passing invalid packets once all valid ones are passed OUT + // (this becomes false at first valid packet) // Memory request/response state @@ -223,9 +228,9 @@ FIFO#(DataResp) dataRespQ <- mkFIFO(); // Audio I/O - FIFO#(AudioProcessorUnit) inAudioFifo <- mkSizedFIFO(512); - FIFO#(AudioProcessorUnit) outAudioFifo <- mkFIFO; - + FIFO#(AudioStream) inAudioFifo <- mkSizedFIFO(512); + FIFO#(AudioStream) outAudioFifo <- mkFIFO; + Reg#(VoiceId) channel <-mkReg(0); // Set based on the reading the incoming data. Not entirely sure I like this. What if the program generates samples? // Statistics state (2010) // Reg#(Stat) num_cycles <- mkReg(0); @@ -239,6 +244,20 @@ //STAT num_inst <- mkStatCounter(`STATS_PROCESSOR_INST_COUNT); //----------------------------------------------------------- + // Internal Functions + + function Bool stallMTCO_MFCO(Instr inst); + case(inst) matches + tagged MTC0 .it : + begin + case (it.cop0dst) + 5'd26 : return cp0_progComp; // If true, processor service sendEnd which clears it. + endcase + end + endcase + endfunction + + //----------------------------------------------------------- // Rules (* descending_urgency = "exec, pcgen" *) @@ -273,7 +292,8 @@ rule exec (instRespQ.first() matches tagged LoadResp.ld &&& (ld.tag == epoch) &&& unpack(ld.data) matches .inst - &&& !stall(inst, wbQ)); + &&& !stall(inst, wbQ) + &&& !stallMTCO_MFCO(inst)); // Some abbreviations let sext = signExtend; @@ -301,6 +321,7 @@ traceTiny("mkProc", "exInstTiny",inst); traceFull("mkProc", "exInstFull",inst); +// $display("PROCESSOR: Exec Fires"); case ( inst ) matches // -- Memory Ops ------------------------------------------------ @@ -553,7 +574,8 @@ 5'd10 : cp0_statsEn <= unpack(truncate(val_rsrc1)); 5'd21 : cp0_tohost <= truncate(val_rsrc1); 5'd26 : cp0_progComp <= unpack(truncate(val_rsrc1)); //states audio program completed and termination okay - 5'd27 : outAudioFifo.enq(tagged Sample unpack(truncate(val_rsrc1))); //Bit size is 16 not 32 + 5'd27 : outAudioFifo.enq(AudioStream {voice: channel, data: tagged Valid + tagged Sample unpack(truncate(val_rsrc1)) }); //Bit size is 16 not 32 default : $display( " RTL-ERROR : %m : Illegal MTC0 cop0dst register!" ); endcase @@ -569,26 +591,35 @@ 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"); - let sample = inAudioFifo.first(); - case (sample) matches - tagged EndOfFile : - begin - $display("PROCESSOR sent toC EOF"); - wbQ.enq(tagged WB_ALU {dest:it.rdst, data:zext(pack(True)) }); // Reading clears bit - inAudioFifo.deq; - end - tagged Sample .data: - wbQ.enq(tagged WB_ALU {dest:it.rdst, data:zext(pack(False)) }); // Reading clears bit - endcase +// $display( "**** EOF Requested\n "); //Should never run if inAudioFifo.first not valid + let stream = inAudioFifo.first(); + if (stream.data matches tagged Valid .sample) + begin + case (sample) matches + tagged EndOfFile : + begin + $display("PROCESSOR sent toC EOF"); + wbQ.enq(tagged WB_ALU {dest:it.rdst, data:zext(pack(True)) }); // Reading clears bit + inAudioFifo.deq; + end + tagged Sample .audio: + wbQ.enq(tagged WB_ALU {dest:it.rdst, data:zext(pack(False)) }); // Reading clears bit + endcase + code_bypass <= False; + end + else $display("PROCESSOR code trying to read Invalid Audio Stream"); end 5'd28 : begin $display( "***** Reqesting Sample"); - 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? - else $display ( "Audio File EOF Reached. Invalid sample request."); - inAudioFifo.deq(); + let stream = inAudioFifo.first(); // is this going to cause perf. delay? + if (stream.data matches tagged Valid .sample) + begin + 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? + else $display ( "Audio File EOF Reached. Invalid sample request."); + inAudioFifo.deq(); + end + else $display("PROCESSOR code trying to read Invalid Audio Stream"); end default : $display( " RTL-ERROR : %m : Illegal MFC0 cop0src register!" ); @@ -645,14 +676,13 @@ // num_cycles.incr(); // endrule -/* - // for now, we don't do anything. - rule connectAudioReqResp; - $display("rlm: PROCESSOR copies a datum\n"); + rule bypass (code_bypass &&& + !cp0_progComp &&& //never fires at the same time as sendEnd where it is enabled + inAudioFifo.first().data matches tagged Invalid) ; outAudioFifo.enq(inAudioFifo.first()); inAudioFifo.deq; endrule -*/ + /* rule flagAudioEnd (inAudioFifo.first() matches tagged EndOfFile); $display (" PROCESSOR End Audio Flag Set "); @@ -660,10 +690,12 @@ inAudioFifo.deq; endrule */ + (* descending_urgency = "sendProcEnd, exec" *) rule sendProcEnd (cp0_progComp); $display (" PROCESSOR Says Program Complete "); - outAudioFifo.enq(tagged EndOfFile); - cp0_progComp <= False; //only send one. And functions to reset + outAudioFifo.enq(AudioStream {voice: channel, data: tagged Valid tagged EndOfFile }); // Only send one + cp0_progComp <= False; // And functions to reset + code_bypass <= True; // Enable Bypass so that invalids get thru endrule @@ -696,6 +728,7 @@ interface Get sampleOutput = fifoToGet(outAudioFifo); interface Put sampleInput = fifoToPut(inAudioFifo); + interface Get pcCount = toGet(asReg(pc)); endmodule diff -r 0ede0715dbd6 -r 44cc00df1168 modules/bluespec/Pygar/core/ProcessorSystem.dic --- a/modules/bluespec/Pygar/core/ProcessorSystem.dic Tue May 11 23:23:21 2010 -0400 +++ b/modules/bluespec/Pygar/core/ProcessorSystem.dic Wed May 12 00:06:05 2010 -0400 @@ -1,4 +1,26 @@ def VDEV.SCRATCH.MEMORYA "program.0/program.vmh"; def VDEV.SCRATCH.MEMORYB "program.0/program.vmh"; - - +def VDEV.SCRATCH.MEMORYC "program.0/program.vmh"; +def VDEV.SCRATCH.MEMORYD "program.0/program.vmh"; +def VDEV.SCRATCH.MEMORYE "program.0/program.vmh"; +def VDEV.SCRATCH.MEMORYF "program.0/program.vmh"; +def VDEV.SCRATCH.MEMORYG "program.0/program.vmh"; +def VDEV.SCRATCH.MEMORYH "program.0/program.vmh"; +def VDEV.SCRATCH.MEMORYI "program.0/program.vmh"; +def VDEV.SCRATCH.MEMORYJ "program.0/program.vmh"; +def VDEV.SCRATCH.MEMORYK "program.0/program.vmh"; +def VDEV.SCRATCH.MEMORYL "program.0/program.vmh"; +def VDEV.SCRATCH.MEMORYM "program.0/program.vmh"; +def VDEV.SCRATCH.MEMORYN "program.0/program.vmh"; +def VDEV.SCRATCH.MEMORYO "program.0/program.vmh"; +def VDEV.SCRATCH.MEMORYP "program.0/program.vmh"; +def VDEV.SCRATCH.MEMORYQ "program.0/program.vmh"; +def VDEV.SCRATCH.MEMORYR "program.0/program.vmh"; +def VDEV.SCRATCH.MEMORYS "program.0/program.vmh"; +def VDEV.SCRATCH.MEMORYT "program.0/program.vmh"; +def VDEV.SCRATCH.MEMORYU "program.0/program.vmh"; +def VDEV.SCRATCH.MEMORYV "program.0/program.vmh"; +def VDEV.SCRATCH.MEMORYW "program.0/program.vmh"; +def VDEV.SCRATCH.MEMORYX "program.0/program.vmh"; +def VDEV.SCRATCH.MEMORYY "program.0/program.vmh"; +def VDEV.SCRATCH.MEMORYZ "program.0/program.vmh"; \ No newline at end of file diff -r 0ede0715dbd6 -r 44cc00df1168 modules/bluespec/Pygar/core/audioCore.bsv --- a/modules/bluespec/Pygar/core/audioCore.bsv Tue May 11 23:23:21 2010 -0400 +++ b/modules/bluespec/Pygar/core/audioCore.bsv Wed May 12 00:06:05 2010 -0400 @@ -40,6 +40,7 @@ `include "asim/provides/data_cache.bsh" `include "asim/provides/processor.bsh" `include "asim/provides/audio_pipe_types.bsh" +`include "asim/provides/path_types.bsh" // Scratchpad includes `include "asim/provides/scratchpad_memory.bsh" @@ -48,17 +49,15 @@ interface Core; - interface Get#(AudioProcessorUnit) sampleOutput; - interface Put#(AudioProcessorUnit) sampleInput; + interface Get#(AudioStream) sampleOutput; + interface Put#(AudioStream) sampleInput; -// interface CPUToHost tohost; + interface Get#(Bit#(32)) pc; endinterface module [CONNECTED_MODULE] mkCore#(Integer prog) ( Core ); - - - // Instantiate the modules + // Instantiate the modules Proc proc <- mkProc(); ICache#(InstReq,InstResp) icache <- mkInstCache(); @@ -108,6 +107,6 @@ interface sampleOutput = proc.sampleOutput; interface sampleInput = proc.sampleInput; -// interface CPUToHost tohost = proc.tohost; + interface pc = proc.pcCount; endmodule diff -r 0ede0715dbd6 -r 44cc00df1168 modules/bluespec/Pygar/core/audioCorePipeline.bsv --- a/modules/bluespec/Pygar/core/audioCorePipeline.bsv Tue May 11 23:23:21 2010 -0400 +++ b/modules/bluespec/Pygar/core/audioCorePipeline.bsv Wed May 12 00:06:05 2010 -0400 @@ -50,19 +50,18 @@ module [CONNECTED_MODULE] mkConnectedApplication (); - // Core core <- mkCore(`VDEV_SCRATCH_MEMORYA); - // Core anotherCore <- mkCore(`VDEV_SCRATCH_MEMORYB); Vector#(`MAX_VOICES, Volume) channelVols = replicate(127); Mixer mixer <- mkMixer(`MAX_VOICES, 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)); + + Reg#(Bit#(32)) cycle <- mkReg(0); + Reg#(Bit#(32)) sampleCountIn <-mkReg(0); + Reg#(Bit#(32)) sampleCountOut <-mkReg(0); + Vector#(`MAX_VOICES, Reg#(Bit#(32))) pc <-replicateM(mkReg(0)); //tracks pcs from cores for debug purposes + Vector#(`MAX_VOICES, Reg#(Bool)) channelFini <- replicateM(mkReg(False)); // Services Samples ClientStub_AUDIOCORERRR client_stub <- mkClientStub_AUDIOCORERRR(); - //----------------------------------------------------------- // Debug port @@ -75,15 +74,55 @@ case (n) 0 : cores[n] <- mkCore(`VDEV_SCRATCH_MEMORYA); 1 : cores[n] <- mkCore(`VDEV_SCRATCH_MEMORYB); + 2 : cores[n] <- mkCore(`VDEV_SCRATCH_MEMORYC); + 3 : cores[n] <- mkCore(`VDEV_SCRATCH_MEMORYD); + 4 : cores[n] <- mkCore(`VDEV_SCRATCH_MEMORYE); + 5 : cores[n] <- mkCore(`VDEV_SCRATCH_MEMORYF); + 6 : cores[n] <- mkCore(`VDEV_SCRATCH_MEMORYG); + 7 : cores[n] <- mkCore(`VDEV_SCRATCH_MEMORYH); + 8 : cores[n] <- mkCore(`VDEV_SCRATCH_MEMORYI); + 9 : cores[n] <- mkCore(`VDEV_SCRATCH_MEMORYJ); + 10 : cores[n] <- mkCore(`VDEV_SCRATCH_MEMORYK); + 11 : cores[n] <- mkCore(`VDEV_SCRATCH_MEMORYL); + 12 : cores[n] <- mkCore(`VDEV_SCRATCH_MEMORYM); + 13 : cores[n] <- mkCore(`VDEV_SCRATCH_MEMORYN); + 14 : cores[n] <- mkCore(`VDEV_SCRATCH_MEMORYO); + 15 : cores[n] <- mkCore(`VDEV_SCRATCH_MEMORYP); + 16 : cores[n] <- mkCore(`VDEV_SCRATCH_MEMORYQ); + 17 : cores[n] <- mkCore(`VDEV_SCRATCH_MEMORYR); + 18 : cores[n] <- mkCore(`VDEV_SCRATCH_MEMORYS); + 19 : cores[n] <- mkCore(`VDEV_SCRATCH_MEMORYT); + 20 : cores[n] <- mkCore(`VDEV_SCRATCH_MEMORYU); + 21 : cores[n] <- mkCore(`VDEV_SCRATCH_MEMORYV); + 22 : cores[n] <- mkCore(`VDEV_SCRATCH_MEMORYW); + 23 : cores[n] <- mkCore(`VDEV_SCRATCH_MEMORYX); + 24 : cores[n] <- mkCore(`VDEV_SCRATCH_MEMORYY); + 25 : cores[n] <- mkCore(`VDEV_SCRATCH_MEMORYZ); endcase end - + + function Integer countFiniVoices(); + Integer count = 0; + for (Integer i = 0; i < `MAX_VOICES; i = i + 1) + if (channelFini[i]) count = count + 1; + return count; + endfunction + // this is for the tracing rule printCycles; cycle <= cycle+1; $fdisplay(stderr, " => Cycle = %d", cycle); endrule + // get the pc for trace purposes + rule getPC; + for (Integer i = 0; i < `MAX_VOICES; i = i + 1) + begin + let val <- cores[i].pc.get(); + pc[i] <= val; + end + 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 @@ -92,28 +131,27 @@ for (Integer i = 0; i < `MAX_VOICES; i = i + 1) begin let coreOut <- cores[i].sampleOutput.get(); - mixer.toMixer(AudioStream {voice : fromInteger(i), data: tagged Valid coreOut}); + mixer.toMixer(AudioStream {voice : fromInteger(i), data:coreOut.data}); end - -// let coreOut <- core.sampleOutput.get(); -// mixer.toMixer(AudioStream {voice : 0, data : tagged Valid coreOut}); -// mixer.toMixer(AudioStream {voice : 1, data : tagged Valid anotherOut}); - endrule - + endrule + rule feedOutput; let pipeOut <- mixer.mainOut.get(); AudioProcessorControl endOfFileTag = EndOfFile; AudioProcessorControl sampleTag = Data; - sampleCount <= sampleCount+1; + sampleCountOut <= sampleCountOut+1; - $display("PIPE writes sample %d", sampleCount); + $display("PIPE writes sample %d", sampleCountOut); case (pipeOut) matches tagged EndOfFile: begin client_stub.makeRequest_SendProcessedStream(zeroExtend(pack(endOfFileTag)),?); - ac_fini[0] <= True; + for (Integer i = 1; i < `MAX_VOICES; i = i+1) channelFini[i] <= False; + //This will report conflict with + //the other setting of channelFini at input except they are mutually + //exclusive since this is only hit after all input finished end tagged Sample .sample: client_stub.makeRequest_SendProcessedStream(zeroExtend(pack(sampleTag)), zeroExtend(pack(sample))); @@ -134,31 +172,55 @@ */ //***** SERVER Side ***** - + // this requires me to switch the processor to handle this which I will do later. + // When a file has finished, want the system to pass invalid audiostreams + rule fillFinished; + for (Integer i = 1; i < `MAX_VOICES; i = i+1) + begin + if (channelFini[i]) + cores[i].sampleInput.put(AudioStream {voice : fromInteger(i), data: tagged Invalid}); + end + endrule + (* conservative_implicit_conditions *) rule feedInput; let command <- server_stub.acceptRequest_SendUnprocessedStream(); AudioProcessorControl ctrl = unpack(truncate(command.ctrl)); VoiceId channel = unpack(truncate(command.channel)); -// $display("rlm: %x", test); +// $display("PIPE: Incoming sample to channel %x", channel); AudioProcessorUnit inSample; if(ctrl == EndOfFile) begin $display("lsp: PIPE received EOF "); - inSample = tagged EndOfFile; -// core.sampleInput.put(tagged EndOfFile); + inSample = tagged EndOfFile; + channelFini[channel] <= True; end else begin // $display("lsp: PIPE received Data "); -// core.sampleInput.put(tagged Sample unpack(truncate(command.sample))); inSample = tagged Sample unpack(truncate(command.sample)); end - cores[channel].sampleInput.put(inSample); + if (!channelFini[channel]) + cores[channel].sampleInput.put(AudioStream {voice: channel, data: tagged Valid inSample }); + else $display("PIPE ERROR: Trying to send to Stream officially done"); - endrule + endrule + + (* conservative_implicit_conditions *) + rule handleCPUToHost; + let req <- server_stub.acceptRequest_ReadCPUToHost(); + case (req) + 1: server_stub.sendResponse_ReadCPUToHost(cycle); + 2: server_stub.sendResponse_ReadCPUToHost(sampleCountIn); + 3: server_stub.sendResponse_ReadCPUToHost(sampleCountOut); + 4: server_stub.sendResponse_ReadCPUToHost(fromInteger(countFiniVoices())); + default : if (req < 10 + `MAX_VOICES) + server_stub.sendResponse_ReadCPUToHost(pc[req-10]); + endcase + endrule + endmodule