annotate modules/bluespec/Pygar/core/audioCorePipeline.bsv @ 52:49049f97312c pygar svn.53

[svn r53] sends to two cores (but has issues)
author punk
date Thu, 06 May 2010 08:57:53 -0400
parents 9fe5ed4af92d
children 2991344775f8
rev   line source
punk@13 1 // The MIT License
punk@13 2
punk@13 3 // Copyright (c) 2009 Massachusetts Institute of Technology
punk@13 4
punk@13 5 // Permission is hereby granted, free of charge, to any person obtaining a copy
punk@13 6 // of this software and associated documentation files (the "Software"), to deal
punk@13 7 // in the Software without restriction, including without limitation the rights
punk@13 8 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
punk@13 9 // copies of the Software, and to permit persons to whom the Software is
punk@13 10 // furnished to do so, subject to the following conditions:
punk@13 11
punk@13 12 // The above copyright notice and this permission notice shall be included in
punk@13 13 // all copies or substantial portions of the Software.
punk@13 14
punk@13 15 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
punk@13 16 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
punk@13 17 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
punk@13 18 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
punk@13 19 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
punk@13 20 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
punk@13 21 // THE SOFTWARE.
punk@13 22
punk@13 23 // Author: Kermin Fleming kfleming@mit.edu
punk@13 24
punk@13 25 import Connectable::*;
punk@13 26 import GetPut::*;
punk@13 27 import ClientServer::*;
punk@13 28 import FIFO::*;
punk@15 29 import SpecialFIFOs::*;
punk@52 30 import Vector::*;
punk@13 31
punk@13 32 //AWB includes
punk@13 33 `include "asim/provides/low_level_platform_interface.bsh"
punk@13 34 `include "asim/provides/soft_connections.bsh"
punk@13 35 `include "asim/provides/common_services.bsh"
punk@13 36
punk@13 37 //Local includes
punk@13 38 `include "asim/provides/audio_pipe_types.bsh" //provides Audio Pipeline interface
punk@33 39 `include "asim/provides/path_types.bsh"
punk@13 40 `include "asim/provides/core.bsh"
punk@43 41 `include "asim/provides/mixer.bsh"
punk@15 42 `include "asim/provides/processor_library.bsh"
punk@15 43 `include "asim/provides/fpga_components.bsh"
punk@51 44 `include "asim/dict/VDEV_SCRATCH.bsh"
punk@33 45
punk@13 46 `include "asim/rrr/remote_client_stub_AUDIOCORERRR.bsh"
punk@36 47 `include "asim/rrr/remote_server_stub_AUDIOCORERRR.bsh"
punk@13 48
punk@13 49 module [CONNECTED_MODULE] mkConnectedApplication ();
punk@51 50 Core core <- mkCore(`VDEV_SCRATCH_MEMORYA);
punk@51 51 Core anotherCore <- mkCore(`VDEV_SCRATCH_MEMORYB);
punk@52 52
punk@13 53 Reg#(int) cycle <- mkReg(0);
punk@52 54 Vector#(2, Reg#(Bool)) ac_fini <- replicateM(mkReg(False));
punk@33 55
punk@33 56 // Services Samples
punk@15 57 ClientStub_AUDIOCORERRR client_stub <- mkClientStub_AUDIOCORERRR();
punk@48 58
punk@13 59
punk@36 60 //-----------------------------------------------------------
punk@36 61 // Debug port
punk@36 62
punk@36 63 ServerStub_AUDIOCORERRR server_stub <- mkServerStub_AUDIOCORERRR();
punk@36 64
punk@36 65
punk@13 66 // this is for the tracing
punk@13 67 rule printCycles;
punk@13 68 cycle <= cycle+1;
punk@13 69 $fdisplay(stderr, " => Cycle = %d", cycle);
punk@13 70 endrule
punk@13 71
punk@48 72 rule feedOutput;
punk@13 73 let pipelineData <- core.sampleOutput.get();
punk@13 74 AudioProcessorControl endOfFileTag = EndOfFile;
punk@13 75 AudioProcessorControl sampleTag = Data;
punk@13 76
punk@52 77 $display("PIPE writes sample\n");
punk@25 78 case (pipelineData) matches
punk@52 79 tagged EndOfFile:
punk@52 80 begin
punk@52 81 client_stub.makeRequest_SendProcessedStream(zeroExtend(pack(endOfFileTag)),?);
punk@52 82 ac_fini[0] <= True;
punk@52 83 end
punk@52 84 tagged Sample .sample:
punk@52 85 client_stub.makeRequest_SendProcessedStream(zeroExtend(pack(sampleTag)), zeroExtend(pack(sample)));
punk@25 86 endcase
punk@13 87 endrule
punk@13 88
punk@52 89 // Programming ghetto style!
punk@52 90 // right now I am repeating this rule for my second core.
punk@52 91 (* conservative_implicit_conditions *)
punk@52 92 rule feedAnotherOutput;
punk@52 93 let pipelineData <- anotherCore.sampleOutput.get();
punk@52 94 AudioProcessorControl endOfFileTag = EndOfFile;
punk@52 95 AudioProcessorControl sampleTag = Data;
punk@52 96
punk@52 97 $display("PIPE writes another sample\n");
punk@52 98 case (pipelineData) matches
punk@52 99 tagged EndOfFile:
punk@52 100 begin
punk@52 101 client_stub.makeRequest_SendProcessedStream(zeroExtend(pack(endOfFileTag)),?);
punk@52 102 ac_fini[1] <= True;
punk@52 103 end
punk@52 104 tagged Sample .sample:
punk@52 105 client_stub.makeRequest_SendProcessedStream(zeroExtend(pack(sampleTag)), zeroExtend(pack(sample)));
punk@52 106 endcase
punk@52 107 endrule
punk@52 108
punk@52 109
punk@52 110 // Can generally just stick with the EOF but since I have two Cores no mixer...
punk@52 111 /*(* conservative_implicit_conditions *)
punk@52 112 rule sendTerminate;
punk@52 113 Bool done = True;
punk@52 114 for (Integer i = 1; i < 2; i = i+1)
punk@52 115 done = ac_fini[i] && done;
punk@52 116
punk@52 117 if (done)
punk@52 118 client_stub.makeRequest_SendTerminate(zeroExtend(pack(1)));
punk@52 119
punk@52 120 endrule
punk@52 121 */
punk@52 122
punk@36 123 //***** SERVER Side *****
punk@36 124
punk@52 125 (* conservative_implicit_conditions *)
punk@36 126 rule feedInput;
punk@36 127 let command <- server_stub.acceptRequest_SendUnprocessedStream();
punk@36 128 AudioProcessorControl ctrl = unpack(truncate(command.ctrl));
rlm@41 129
punk@52 130 VoiceId channel = unpack(truncate(command.channel));
punk@48 131 // $display("rlm: %x", test);
rlm@41 132
punk@52 133 AudioProcessorUnit inSample;
punk@52 134
punk@52 135 if(ctrl == EndOfFile)
punk@52 136 begin
punk@43 137 $display("lsp: PIPE received EOF ");
punk@52 138 inSample = tagged EndOfFile;
punk@52 139 // core.sampleInput.put(tagged EndOfFile);
punk@36 140 end
punk@36 141 else
punk@36 142 begin
punk@43 143 // $display("lsp: PIPE received Data ");
punk@52 144 // core.sampleInput.put(tagged Sample unpack(truncate(command.sample)));
punk@52 145 inSample = tagged Sample unpack(truncate(command.sample));
punk@52 146 end
punk@52 147
punk@52 148 case (channel)
punk@52 149 0 : core.sampleInput.put(inSample);
punk@52 150 1 : anotherCore.sampleInput.put(inSample);
punk@52 151 endcase
punk@52 152
punk@36 153 endrule
punk@13 154 endmodule