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