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@13
|
29
|
punk@13
|
30 //AWB includes
|
punk@13
|
31 `include "asim/provides/low_level_platform_interface.bsh"
|
punk@13
|
32 `include "asim/provides/soft_connections.bsh"
|
punk@13
|
33 `include "asim/provides/common_services.bsh"
|
punk@13
|
34
|
punk@13
|
35 //Local includes
|
punk@13
|
36 `include "asim/provides/audio_processor_types.bsh" //provides Audio Pipeline interface
|
punk@13
|
37 `include "asim/provides/core.bsh"
|
punk@13
|
38
|
punk@13
|
39 `include "asim/rrr/remote_client_stub_AUDIOCORERRR.bsh"
|
punk@13
|
40 `include "asim/rrr/remote_server_stub_AUDIOCORERRR.bsh"
|
punk@13
|
41
|
punk@13
|
42 module [CONNECTED_MODULE] mkConnectedApplication ();
|
punk@13
|
43 Core core <- mkCore;
|
punk@13
|
44 Reg#(int) cycle <- mkReg(0);
|
punk@13
|
45
|
punk@13
|
46 //External memory
|
punk@13
|
47 // I'm not comfortable assuming that the memory subsystem is in order
|
punk@13
|
48 // So I'll insert a completion buffer here.
|
punk@13
|
49 ClientStub_PROCESSORSYSTEMRRR client_stub <- mkClientStub_PROCESSORSYSTEMRRR();
|
punk@13
|
50 // Make this big enough so that several outstanding requests may be supported
|
punk@13
|
51 FIFO#(Bit#(MainMemTagSz)) tags <- mkSizedFIFO(8);
|
punk@13
|
52
|
punk@13
|
53 // this is for the tracing
|
punk@13
|
54 rule printCycles;
|
punk@13
|
55 cycle <= cycle+1;
|
punk@13
|
56 $fdisplay(stderr, " => Cycle = %d", cycle);
|
punk@13
|
57 endrule
|
punk@13
|
58
|
punk@13
|
59 rule sendMemReq;
|
punk@13
|
60 let coreReq <- core.mmem_client.request.get;
|
punk@13
|
61 case (coreReq) matches
|
punk@13
|
62 tagged LoadReq .load: begin
|
punk@13
|
63 //Allocate ROB space
|
punk@13
|
64 client_stub.makeRequest_MemoryRequestLoad(load.addr);
|
punk@13
|
65 tags.enq(load.tag);
|
punk@13
|
66 end
|
punk@13
|
67 tagged StoreReq .store: begin
|
punk@13
|
68 client_stub.makeRequest_MemoryRequestStore(store.addr,store.data);
|
punk@13
|
69 end
|
punk@13
|
70 endcase
|
punk@13
|
71 endrule
|
punk@13
|
72
|
punk@13
|
73 rule receiveMemResp;
|
punk@13
|
74 let memResp <- client_stub.getResponse_MemoryRequestLoad();
|
punk@13
|
75 tags.deq;
|
punk@13
|
76 core.mmem_client.response.put(tagged LoadResp {data:memResp,
|
punk@13
|
77 tag: tags.first});
|
punk@13
|
78 endrule
|
punk@13
|
79
|
punk@13
|
80 // this isn't particularly correct as it doesn't actually connect the processor interfaces, but this should allow me to verify the data path before fully blending the two items together.
|
punk@13
|
81
|
punk@13
|
82 rule feedOutput;
|
punk@13
|
83 let pipelineData <- core.sampleOutput.get();
|
punk@13
|
84 AudioProcessorControl endOfFileTag = EndOfFile;
|
punk@13
|
85 AudioProcessorControl sampleTag = Data;
|
punk@13
|
86
|
punk@13
|
87 case (pipelineData) matches
|
punk@13
|
88 tagged EndOfFile: client_stub.makeRequest_SendProcessedStream(zeroExtend(pack(endOfFileTag)),?);
|
punk@13
|
89 tagged Sample .sample:client_stub.makeRequest_SendProcessedStream(zeroExtend(pack(sampleTag)),
|
punk@13
|
90 zeroExtend(pack(sample)));
|
punk@13
|
91 endcase
|
punk@13
|
92 endrule
|
punk@13
|
93
|
punk@13
|
94 endmodule
|