punk@33: // The MIT License punk@33: punk@33: // Copyright (c) 2009 Massachusetts Institute of Technology punk@33: punk@33: // Permission is hereby granted, free of charge, to any person obtaining a copy punk@33: // of this software and associated documentation files (the "Software"), to deal punk@33: // in the Software without restriction, including without limitation the rights punk@33: // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell punk@33: // copies of the Software, and to permit persons to whom the Software is punk@33: // furnished to do so, subject to the following conditions: punk@33: punk@33: // The above copyright notice and this permission notice shall be included in punk@33: // all copies or substantial portions of the Software. punk@33: punk@33: // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR punk@33: // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, punk@33: // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE punk@33: // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER punk@33: // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, punk@33: // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN punk@33: // THE SOFTWARE. punk@33: punk@33: // Author: Kermin Fleming kfleming@mit.edu punk@33: punk@33: import Connectable::*; punk@33: import GetPut::*; punk@33: import ClientServer::*; punk@33: import FIFO::*; punk@33: import SpecialFIFOs::*; punk@33: punk@33: //AWB includes punk@33: `include "asim/provides/low_level_platform_interface.bsh" punk@33: `include "asim/provides/soft_connections.bsh" punk@33: `include "asim/provides/common_services.bsh" punk@33: punk@33: //Local includes punk@33: `include "asim/provides/audio_pipe_types.bsh" //provides Audio Pipeline interface punk@33: `include "asim/provides/core.bsh" punk@33: `include "asim/provides/processor_library.bsh" punk@33: `include "asim/provides/fpga_components.bsh" punk@33: `include "asim/provides/scratchpad_memory.bsh" punk@33: `include "asim/provides/mem_services.bsh" punk@33: `include "asim/dict/VDEV_SCRATCH.bsh" punk@33: punk@33: `include "asim/rrr/remote_client_stub_AUDIOCORERRR.bsh" punk@33: //`include "asim/rrr/remote_server_stub_AUDIOCORERRR.bsh" punk@33: punk@33: function punk@33: module [CONNECTED_MODULE] mkConnectedApplication (); punk@33: Core core <- mkCore; punk@33: Reg#(int) cycle <- mkReg(0); punk@33: punk@33: punk@33: //get volumes punk@33: //mkMixer(); punk@33: punk@33: //External memory punk@33: // I'm not comfortable assuming that the memory subsystem is in order punk@33: // So I'll insert a completion buffer here. punk@33: MEMORY_IFC#(Bit#(18), Bit#(32)) memory <- mkScratchpad(`VDEV_SCRATCH_MEMORY, SCRATCHPAD_CACHED); //Services Memory items punk@33: punk@33: // Services Samples punk@33: ClientStub_AUDIOCORERRR client_stub <- mkClientStub_AUDIOCORERRR(); punk@33: // Make this big enough so that several outstanding requests may be supported punk@33: FIFO#(Bit#(MainMemTagSz)) tags <- mkSizedFIFO(8); punk@33: punk@33: // this is for the tracing punk@33: rule printCycles; punk@33: cycle <= cycle+1; punk@33: $fdisplay(stderr, " => Cycle = %d", cycle); punk@33: endrule punk@33: punk@33: rule sendMemReq; punk@33: let coreReq <- core.mmem_client.request.get; punk@33: case (coreReq) matches punk@33: tagged LoadReq .load: begin punk@33: //Allocate ROB space punk@33: memory.readReq(truncate(load.addr>>2)); punk@33: tags.enq(load.tag); punk@33: end punk@33: tagged StoreReq .store: begin punk@33: memory.write(truncate(store.addr>>2),store.data); punk@33: end punk@33: endcase punk@33: endrule punk@33: punk@33: rule receiveMemResp; punk@33: let memResp <- memory.readRsp(); punk@33: tags.deq; punk@33: core.mmem_client.response.put(tagged LoadResp {data:memResp, punk@33: tag: tags.first}); punk@33: endrule punk@33: punk@33: rule feedOutput; punk@33: let pipelineData <- core.sampleOutput.get(); punk@33: AudioProcessorControl endOfFileTag = EndOfFile; punk@33: AudioProcessorControl sampleTag = Data; punk@33: punk@33: case (pipelineData) matches punk@33: tagged EndOfFile: punk@33: client_stub.makeRequest_SendProcessedStream(zeroExtend(pack(endOfFileTag)),?); punk@33: tagged Sample .sample:client_stub.makeRequest_SendProcessedStream(zeroExtend(pack(sampleTag)), zeroExtend(pack(sample))); punk@33: endcase punk@33: endrule punk@33: punk@33: endmodule