# HG changeset patch # User punk # Date 1273150673 14400 # Node ID 49049f97312cceb9fd211658ef433382bd50786e # Parent 9fe5ed4af92d55f0719a5a1d213aa1cc8d3a0139 [svn r53] sends to two cores (but has issues) diff -r 9fe5ed4af92d -r 49049f97312c modules/bluespec/Pygar/core/AudioCoreRRR.cpp --- a/modules/bluespec/Pygar/core/AudioCoreRRR.cpp Wed May 05 17:01:04 2010 -0400 +++ b/modules/bluespec/Pygar/core/AudioCoreRRR.cpp Thu May 06 08:57:53 2010 -0400 @@ -24,6 +24,7 @@ outputFile = NULL; memory = NULL; fflush(stdout); + count = 0; } // destructor @@ -90,6 +91,13 @@ */ void +AUDIOCORERRR_SERVER_CLASS::SendTerminate(UINT32 flag) +{ + printf("lsp: Received Process Termination\n"); + CONNECTED_APPLICATION_CLASS::EndSimulation(); +} + +void AUDIOCORERRR_SERVER_CLASS::SendProcessedStream(UINT16 control, UINT16 data) { @@ -112,7 +120,9 @@ } // Long term this should be in the data portion. But until I have code running, keep it here. - CONNECTED_APPLICATION_CLASS::EndSimulation(); + count++; + if (count == 2) + CONNECTED_APPLICATION_CLASS::EndSimulation(); break; case Data: diff -r 9fe5ed4af92d -r 49049f97312c modules/bluespec/Pygar/core/AudioCoreRRR.h --- a/modules/bluespec/Pygar/core/AudioCoreRRR.h Wed May 05 17:01:04 2010 -0400 +++ b/modules/bluespec/Pygar/core/AudioCoreRRR.h Thu May 06 08:57:53 2010 -0400 @@ -10,7 +10,6 @@ #include "asim/provides/rrr.h" - typedef class AUDIOCORERRR_SERVER_CLASS* AUDIOCORERRR_SERVER; class AUDIOCORERRR_SERVER_CLASS: public RRR_SERVER_CLASS, public PLATFORMS_MODULE_CLASS { @@ -45,7 +44,7 @@ UINT32 MemoryRequestLoad (UINT32 address); void MemoryRequestStore (UINT32 address, UINT32 data); */ - + void SendTerminate(UINT32 flag); void SendProcessedStream(UINT16 control, UINT16 data0); }; diff -r 9fe5ed4af92d -r 49049f97312c modules/bluespec/Pygar/core/AudioCoreRRR.rrr --- a/modules/bluespec/Pygar/core/AudioCoreRRR.rrr Wed May 05 17:01:04 2010 -0400 +++ b/modules/bluespec/Pygar/core/AudioCoreRRR.rrr Thu May 06 08:57:53 2010 -0400 @@ -3,14 +3,14 @@ server hw (bsv, connection) <- sw (cpp, method) { method ReadCPUToHost (out UINT32[32] regValue, in UINT32[32] dummy); - method SendUnprocessedStream (in UINT32[32] channel, in UINT32[32] ctrl, in UINT32[32] sample); + method SendUnprocessedStream (in UINT32[32] channel, in UINT32[32] ctrl, in UINT32[32] sample); }; server sw (cpp, method) <- hw (bsv, connection) { method SendProcessedStream (in UINT32[32] ctrl, in UINT32[32] sample); - + method SendTerminate(in UINT32[32] flag); }; diff -r 9fe5ed4af92d -r 49049f97312c modules/bluespec/Pygar/core/AudioCoreSystem.cpp --- a/modules/bluespec/Pygar/core/AudioCoreSystem.cpp Wed May 05 17:01:04 2010 -0400 +++ b/modules/bluespec/Pygar/core/AudioCoreSystem.cpp Thu May 06 08:57:53 2010 -0400 @@ -64,13 +64,13 @@ { //rlm: two files FILE *inputFile; -// FILE *inputFile1; + FILE *inputFile1; UINT16 sample; -//UINT16 sample1; + UINT16 sample1; //rlm: not sure if normal ints are ok here; using UINT16 because I know it works - UINT16 channel0 = 5; - //UINT16 channel1 = 1; + UINT16 channel0 = 0; + UINT16 channel1 = 1; //init processor int sleepCount = 0; @@ -86,15 +86,15 @@ //rlm: for now we are going to going to just have 2 files with "common names" generate_pcm("input.wav","input.pcm"); - //generate_pcm("input1.wav", "input1.pcm"); + generate_pcm("input1.wav", "input1.pcm"); //Send data to the machine here. //rlm: two files inputFile = fopen("input.pcm","r"); - // inputFile = fopen("input1.pcm", "r"); + inputFile = fopen("input1.pcm", "r"); - //assert(inputFile1); + assert(inputFile1); assert(inputFile); int count = 0; @@ -103,20 +103,12 @@ //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))) + while( (fread(&sample, 2, 1, inputFile)) || (fread(&sample1, 2 , 1, inputFile1))) { /* printf("hi\n"); if (!coreFin && (result = clientStub->ReadCPUToHost(0)) != 1) { sleepCount++; - if(sleepCount == 200) { - printf("Failed to get response from hardware, bailing\n\n"); - printf("This means that either your hardware is hanging\n"); - printf("or that the software hasn't given it enough time\n"); - printf("to complete. If you think it needs more time, then\n"); - printf("edit CONNECTED_APPLICATION_CLASS::Main() in ProcessorSystem.cpp\n"); - printf("(connected_application)\n"); - } } else if (!coreFin && result == 1) { @@ -132,9 +124,8 @@ //rlm: two files. // clientStub->SendUnprocessedStream( Data,(UINT32)sample); - clientStub->SendUnprocessedStream((UINT32)channel0 , Data,(UINT32)sample); - //clientStub->SendUnprocessedStream(channel1 , Data,(UINT32)sample1); - + clientStub->SendUnprocessedStream((UINT32)channel0 , Data,(UINT32)sample); + clientStub->SendUnprocessedStream((UINT32)channel1 , Data,(UINT32)sample1); } printf("main: out of loop\n"); @@ -146,7 +137,7 @@ // all of these operations wil eventually be moved into functions. //clientStub->SendUnprocessedStream(EndOfFile,0); clientStub->SendUnprocessedStream((UINT32)channel0, EndOfFile,0); - // clientStub->SendUnprocessedStream(channel1, EndOfFile,0); + clientStub->SendUnprocessedStream((UINT32)channel1, EndOfFile,0); printf("main: wait for end of file\n"); diff -r 9fe5ed4af92d -r 49049f97312c modules/bluespec/Pygar/core/AudioPipeTypes.bsv --- a/modules/bluespec/Pygar/core/AudioPipeTypes.bsv Wed May 05 17:01:04 2010 -0400 +++ b/modules/bluespec/Pygar/core/AudioPipeTypes.bsv Thu May 06 08:57:53 2010 -0400 @@ -29,6 +29,7 @@ import ClientServer::*; typedef Int#(16) Sample; +typedef Int#(16) Channel; typedef enum { EndOfFile = 0, diff -r 9fe5ed4af92d -r 49049f97312c modules/bluespec/Pygar/core/audioCorePipeline.bsv --- a/modules/bluespec/Pygar/core/audioCorePipeline.bsv Wed May 05 17:01:04 2010 -0400 +++ b/modules/bluespec/Pygar/core/audioCorePipeline.bsv Thu May 06 08:57:53 2010 -0400 @@ -27,6 +27,7 @@ import ClientServer::*; import FIFO::*; import SpecialFIFOs::*; +import Vector::*; //AWB includes `include "asim/provides/low_level_platform_interface.bsh" @@ -48,18 +49,9 @@ module [CONNECTED_MODULE] mkConnectedApplication (); Core core <- mkCore(`VDEV_SCRATCH_MEMORYA); Core anotherCore <- mkCore(`VDEV_SCRATCH_MEMORYB); - // RLM:: - // the simple existance of this additional core causes the dreaded - // beast to emerge --- the ASSERTION FAILURE: sw/model/stats-device.cpp:317 Cycle:0 - //stats device: Duplicate entry DATA_CACHE_NUM_WRITEBACKS, postion 0 - //Core core1 <- mkCore; + Reg#(int) cycle <- mkReg(0); - -// Reg#(Bit#(32)) ac_fini <- mkReg(0); - - //External memory - // I'm not comfortable assuming that the memory subsystem is in order - // So I'll insert a completion buffer here. + Vector#(2, Reg#(Bool)) ac_fini <- replicateM(mkReg(False)); // Services Samples ClientStub_AUDIOCORERRR client_stub <- mkClientStub_AUDIOCORERRR(); @@ -82,40 +74,81 @@ AudioProcessorControl endOfFileTag = EndOfFile; AudioProcessorControl sampleTag = Data; + $display("PIPE writes sample\n"); case (pipelineData) matches - tagged EndOfFile: - client_stub.makeRequest_SendProcessedStream(zeroExtend(pack(endOfFileTag)),?); - tagged Sample .sample:client_stub.makeRequest_SendProcessedStream(zeroExtend(pack(sampleTag)), zeroExtend(pack(sample))); + tagged EndOfFile: + begin + client_stub.makeRequest_SendProcessedStream(zeroExtend(pack(endOfFileTag)),?); + ac_fini[0] <= True; + end + tagged Sample .sample: + client_stub.makeRequest_SendProcessedStream(zeroExtend(pack(sampleTag)), zeroExtend(pack(sample))); endcase endrule + // Programming ghetto style! + // right now I am repeating this rule for my second core. + (* conservative_implicit_conditions *) + rule feedAnotherOutput; + let pipelineData <- anotherCore.sampleOutput.get(); + AudioProcessorControl endOfFileTag = EndOfFile; + AudioProcessorControl sampleTag = Data; + + $display("PIPE writes another sample\n"); + case (pipelineData) matches + tagged EndOfFile: + begin + client_stub.makeRequest_SendProcessedStream(zeroExtend(pack(endOfFileTag)),?); + ac_fini[1] <= True; + end + tagged Sample .sample: + client_stub.makeRequest_SendProcessedStream(zeroExtend(pack(sampleTag)), zeroExtend(pack(sample))); + endcase + endrule + + + // Can generally just stick with the EOF but since I have two Cores no mixer... + /*(* conservative_implicit_conditions *) + rule sendTerminate; + Bool done = True; + for (Integer i = 1; i < 2; i = i+1) + done = ac_fini[i] && done; + + if (done) + client_stub.makeRequest_SendTerminate(zeroExtend(pack(1))); + + endrule +*/ + //***** SERVER Side ***** -/* (* conservative_implicit_conditions *) - rule handleCPUToHost; - let req <- server_stub.acceptRequest_ReadCPUToHost(); - case (req) - 0: server_stub.sendResponse_ReadCPUToHost(cp0_tohost); - endcase - endrule -*/ + (* conservative_implicit_conditions *) rule feedInput; let command <- server_stub.acceptRequest_SendUnprocessedStream(); AudioProcessorControl ctrl = unpack(truncate(command.ctrl)); - Bit#(32) test = unpack(truncate(command.channel)); + VoiceId channel = unpack(truncate(command.channel)); // $display("rlm: %x", test); - - if(ctrl == EndOfFile) - begin + AudioProcessorUnit inSample; + + if(ctrl == EndOfFile) + begin $display("lsp: PIPE received EOF "); - core.sampleInput.put(tagged EndOfFile); + inSample = tagged EndOfFile; +// core.sampleInput.put(tagged EndOfFile); end else begin // $display("lsp: PIPE received Data "); - core.sampleInput.put(tagged Sample unpack(truncate(command.sample))); - end +// core.sampleInput.put(tagged Sample unpack(truncate(command.sample))); + inSample = tagged Sample unpack(truncate(command.sample)); + end + + case (channel) + 0 : core.sampleInput.put(inSample); + 1 : anotherCore.sampleInput.put(inSample); + endcase + endrule endmodule