view modules/bluespec/Pygar/core/audioCorePipeline.bsv @ 47:97d1959f7c5c pygar svn.48

[svn r48] changed sctipt to use our own programs, changed rlp.wav and rlp1.wav to be shorter
author rlm
date Wed, 05 May 2010 13:23:58 -0400
parents 4d87fa55a776
children a139cc07b773
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::*;
31 //AWB includes
32 `include "asim/provides/low_level_platform_interface.bsh"
33 `include "asim/provides/soft_connections.bsh"
34 `include "asim/provides/common_services.bsh"
36 //Local includes
37 `include "asim/provides/audio_pipe_types.bsh" //provides Audio Pipeline interface
38 `include "asim/provides/path_types.bsh"
39 `include "asim/provides/core.bsh"
40 `include "asim/provides/mixer.bsh"
41 `include "asim/provides/processor_library.bsh"
42 `include "asim/provides/fpga_components.bsh"
43 `include "asim/provides/scratchpad_memory.bsh"
44 `include "asim/provides/mem_services.bsh"
45 `include "asim/dict/VDEV_SCRATCH.bsh"
47 `include "asim/rrr/remote_client_stub_AUDIOCORERRR.bsh"
48 `include "asim/rrr/remote_server_stub_AUDIOCORERRR.bsh"
50 module [CONNECTED_MODULE] mkConnectedApplication ();
51 Core core <- mkCore;
52 // RLM::
53 // the simple existance of this additional core causes the dreaded
54 // beast to emerge --- the ASSERTION FAILURE: sw/model/stats-device.cpp:317 Cycle:0
55 //stats device: Duplicate entry DATA_CACHE_NUM_WRITEBACKS, postion 0
56 //Core core1 <- mkCore;
57 Reg#(int) cycle <- mkReg(0);
59 // Reg#(Bit#(32)) ac_fini <- mkReg(0);
61 //External memory
62 // I'm not comfortable assuming that the memory subsystem is in order
63 // So I'll insert a completion buffer here.
64 MEMORY_IFC#(Bit#(18), Bit#(32)) memory <- mkScratchpad(`VDEV_SCRATCH_MEMORY, SCRATCHPAD_CACHED); //Services Memory items
66 // Services Samples
67 ClientStub_AUDIOCORERRR client_stub <- mkClientStub_AUDIOCORERRR();
68 // Make this big enough so that several outstanding requests may be supported
69 FIFO#(Bit#(MainMemTagSz)) tags <- mkSizedFIFO(8);
71 //-----------------------------------------------------------
72 // Debug port
74 ServerStub_AUDIOCORERRR server_stub <- mkServerStub_AUDIOCORERRR();
77 // this is for the tracing
78 rule printCycles;
79 cycle <= cycle+1;
80 $fdisplay(stderr, " => Cycle = %d", cycle);
81 endrule
83 rule sendMemReq;
84 let coreReq <- core.mmem_client.request.get;
85 case (coreReq) matches
86 tagged LoadReq .load: begin
87 // $display("PIPE Load Addr Req %h", load.addr);
88 //Allocate ROB space
89 memory.readReq(truncate(load.addr>>2));
90 tags.enq(load.tag);
91 end
92 tagged StoreReq .store: begin
93 // $display("PIPE Write Addr Req %h", store.addr);
94 memory.write(truncate(store.addr>>2),store.data);
95 end
96 endcase
97 endrule
99 rule receiveMemResp;
100 let memResp <- memory.readRsp();
101 tags.deq;
102 core.mmem_client.response.put(tagged LoadResp {data:memResp,
103 tag: tags.first});
104 // $display("PIPE Receive MemReq %x", memResp);
105 endrule
107 rule feedOutput;
108 let pipelineData <- core.sampleOutput.get();
109 AudioProcessorControl endOfFileTag = EndOfFile;
110 AudioProcessorControl sampleTag = Data;
112 case (pipelineData) matches
113 tagged EndOfFile:
114 client_stub.makeRequest_SendProcessedStream(zeroExtend(pack(endOfFileTag)),?);
115 tagged Sample .sample:client_stub.makeRequest_SendProcessedStream(zeroExtend(pack(sampleTag)), zeroExtend(pack(sample)));
116 endcase
117 endrule
119 //***** SERVER Side *****
121 /* (* conservative_implicit_conditions *)
122 rule handleCPUToHost;
123 let req <- server_stub.acceptRequest_ReadCPUToHost();
124 case (req)
125 0: server_stub.sendResponse_ReadCPUToHost(cp0_tohost);
126 endcase
127 endrule
128 */
129 rule feedInput;
130 let command <- server_stub.acceptRequest_SendUnprocessedStream();
131 AudioProcessorControl ctrl = unpack(truncate(command.ctrl));
133 Bit#(32) test = unpack(truncate(command.channel));
134 $display("rlm: %x", test);
137 if(ctrl == EndOfFile)
138 begin
139 $display("lsp: PIPE received EOF ");
140 core.sampleInput.put(tagged EndOfFile);
141 end
142 else
143 begin
144 // $display("lsp: PIPE received Data ");
145 core.sampleInput.put(tagged Sample unpack(truncate(command.sample)));
146 end
147 endrule
148 endmodule