Mercurial > pygar
changeset 36:99519a031813 pygar svn.37
[svn r37] moved the server into audioCorePipeline
author | punk |
---|---|
date | Tue, 04 May 2010 18:54:54 -0400 |
parents | 14f7a7ace3f5 |
children | 0475235d1513 |
files | modules/bluespec/Pygar/core/#Processor.bsv# modules/bluespec/Pygar/core/AudioCoreRRR.rrr modules/bluespec/Pygar/core/AudioCoreSystem.cpp modules/bluespec/Pygar/core/Processor.bsv modules/bluespec/Pygar/core/audioCore.bsv modules/bluespec/Pygar/core/audioCorePipeline.bsv modules/bluespec/Pygar/lab4/processor_library.awb |
diffstat | 7 files changed, 120 insertions(+), 114 deletions(-) [+] |
line wrap: on
line diff
1.1 --- a/modules/bluespec/Pygar/core/#Processor.bsv# Tue May 04 12:14:24 2010 -0400 1.2 +++ b/modules/bluespec/Pygar/core/#Processor.bsv# Tue May 04 18:54:54 2010 -0400 1.3 @@ -30,8 +30,10 @@ 1.4 import FIFOF::*; 1.5 import SFIFO::*; 1.6 import RWire::*; 1.7 + 1.8 import Trace::*; 1.9 import BFIFO::*; 1.10 +import MemTypes::*; 1.11 import ProcTypes::*; 1.12 import BRegFile::*; 1.13 import BranchPred::*; 1.14 @@ -44,7 +46,7 @@ 1.15 1.16 // Local includes 1.17 //`include "asim/provides/processor_library.bsh" (included above directly) 1.18 -`include "asim/rrr/remote_server_stub_AUDIOCORERRR.bsh" 1.19 + 1.20 `include "asim/provides/common_services.bsh" 1.21 `include "asim/dict/STATS_PROCESSOR.bsh" 1.22 `include "asim/provides/processor_library.bsh" 1.23 @@ -75,6 +77,7 @@ 1.24 1.25 // Interface to Audio Pipeline 1.26 interface Get#(AudioProcessorUnit) sampleOutput; 1.27 + interface Put#(AudioProcessorUnit) sampleInput; 1.28 1.29 endinterface 1.30 1.31 @@ -225,12 +228,6 @@ 1.32 module [CONNECTED_MODULE] mkProc( Proc ); 1.33 1.34 //----------------------------------------------------------- 1.35 - // Debug port 1.36 - 1.37 - ServerStub_AUDIOCORERRR server_stub <- mkServerStub_AUDIOCORERRR(); 1.38 - 1.39 - 1.40 - //----------------------------------------------------------- 1.41 // State 1.42 1.43 // Standard processor state 1.44 @@ -248,10 +245,13 @@ 1.45 FIFO#(PCStat) pcQ <-mkSizedFIFO(3); 1.46 SFIFO#(WBResult, Rindx) wbQ <-mkSFIFO(findwbf); 1.47 1.48 + // NEED TO ADD CAPABILITY FOR RESET (should be able to just say if I get valid in and these are flagged, clear them. 1.49 Reg#(Bit#(32)) cp0_tohost <- mkReg(0); 1.50 Reg#(Bit#(32)) cp0_fromhost <- mkReg(0); 1.51 Reg#(Bool) cp0_statsEn <- mkReg(False); 1.52 - 1.53 + Reg#(Bool) cp0_audioEOF <- mkReg(False); // Register to let code that EOF is reached 1.54 + Reg#(Bool) cp0_progComp <- mkReg(False); // Register to let processor know that the program is complete (as this terminates) 1.55 + 1.56 // Memory request/response state 1.57 1.58 FIFO#(InstReq) instReqQ <- mkBFIFO1(); 1.59 @@ -266,8 +266,8 @@ 1.60 1.61 1.62 // Statistics state (2010) 1.63 -// Reg#(Stat) num_cycles <- mkReg(0); 1.64 -// Reg#(Stat) num_inst <- mkReg(0); 1.65 + // Reg#(Stat) num_cycles <- mkReg(0); 1.66 + // Reg#(Stat) num_inst <- mkReg(0); 1.67 1.68 //Or: 1.69 // Statistics state 1.70 @@ -486,11 +486,14 @@ 1.71 1.72 // -- Cop0 ------------------------------------------------------ 1.73 1.74 - tagged MTC0 .it : 1.75 + tagged MTC0 .it : //Recieve things from host computer 1.76 begin 1.77 + $display( " PROCESSOR MTC0 call\n"); 1.78 case ( it.cop0dst ) 1.79 5'd10 : cp0_statsEn <= unpack(truncate(rf.rd1(it.rsrc))); 1.80 5'd21 : cp0_tohost <= truncate(rf.rd1(it.rsrc)); 1.81 + 5'd26 : cp0_progComp <= unpack(truncate(rf.rd1(it.rsrc))); //states audio program completed and termination okay 1.82 + 5'd27 : outAudioFifo.enq(tagged Sample unpack(truncate(rf.rd1(it.rsrc)))); //Bit size is 16 not 32 1.83 default : 1.84 $display( " RTL-ERROR : %m : Illegal MTC0 cop0dst register!" ); 1.85 endcase 1.86 @@ -498,13 +501,27 @@ 1.87 end 1.88 1.89 //this is host stuff? 1.90 - tagged MFC0 .it : 1.91 + tagged MFC0 .it : //Things out 1.92 begin 1.93 + $display( " PROCESSOR MFC0 call\n"); 1.94 case ( it.cop0src ) 1.95 // not actually an ALU instruction but don't have the format otherwise 1.96 5'd10 : wbQ.enq(tagged WB_ALU {dest:it.rdst, data:zext(pack(cp0_statsEn)) }); 1.97 5'd20 : wbQ.enq(tagged WB_ALU {dest:it.rdst, data:cp0_fromhost }); 1.98 5'd21 : wbQ.enq(tagged WB_ALU {dest:it.rdst, data:cp0_tohost }); 1.99 + 5'd25 : begin 1.100 + $display( "**** EOF Requested\n "); 1.101 + wbQ.enq(tagged WB_ALU {dest:it.rdst, data:zext(pack(cp0_audioEOF)) }); // Reading clears bit 1.102 + cp0_audioEOF <= False; 1.103 + end 1.104 + 5'd28 : begin 1.105 + $display( "***** Reqesting Sample \n"); 1.106 + let sample = inAudioFifo.first(); // is this going to cause perf. delay? 1.107 + if (sample matches tagged Sample .audio) // if it is EOF another rule sets the cp0_audioEOF 1.108 + wbQ.enq(tagged WB_ALU {dest:it.rdst, data:zext(pack(audio)) }); // do I need pack? 1.109 + else $display ( "Audio File EOF Reached. Invalid sample request."); 1.110 + inAudioFifo.deq(); 1.111 + end 1.112 default : 1.113 $display( " RTL-ERROR : %m : Illegal MFC0 cop0src register!" ); 1.114 endcase 1.115 @@ -559,41 +576,27 @@ 1.116 num_cycles.incr(); 1.117 endrule 1.118 1.119 -(* conservative_implicit_conditions *) 1.120 - rule handleCPUToHost; 1.121 - let req <- server_stub.acceptRequest_ReadCPUToHost(); 1.122 - case (req) 1.123 - 0: server_stub.sendResponse_ReadCPUToHost(cp0_tohost); 1.124 - 1: server_stub.sendResponse_ReadCPUToHost(pc); 1.125 - 2: server_stub.sendResponse_ReadCPUToHost(zeroExtend(pack(stage))); 1.126 - endcase 1.127 + 1.128 + // for now, we don't do anything. 1.129 +// rule connectAudioReqResp; 1.130 +// $display("rlm: PROCESSOR copies a datum\n"); 1.131 +// outAudioFifo.enq(inAudioFifo.first()); 1.132 +// inAudioFifo.deq; 1.133 +// endrule 1.134 + 1.135 + rule flagAudioEnd (inAudioFifo.first() matches tagged EndOfFile); 1.136 + $display (" Proc Says End Audio Flag Set "); 1.137 + cp0_audioEOF <= True; 1.138 + inAudioFifo.deq; 1.139 endrule 1.140 1.141 - // for now, we don't do anything. 1.142 - rule connectAudioReqResp; 1.143 -// $display("rlm: PROCESSOR copies a datum\n"); 1.144 - outAudioFifo.enq(inAudioFifo.first()); 1.145 - inAudioFifo.deq; 1.146 + rule sendAudioEnd (cp0_progComp); 1.147 + $display (" PROCESSOR Says Program Complete "); 1.148 + outAudioFifo.enq(tagged EndOfFile); 1.149 + cp0_progComp <= False; //only send one. And functions to reset 1.150 endrule 1.151 1.152 - // Server items & rules: 1.153 1.154 - rule feedInput; 1.155 - let command <- server_stub.acceptRequest_SendUnprocessedStream(); 1.156 - AudioProcessorControl ctrl = unpack(truncate(command.ctrl)); 1.157 - if(ctrl == EndOfFile) 1.158 - begin 1.159 -// $display("lsp: PROCESSOR received EOF "); 1.160 - inAudioFifo.enq(tagged EndOfFile); 1.161 - end 1.162 - else 1.163 - begin 1.164 -// $display("lsp: PROCESSOR received Data "); 1.165 - inAudioFifo.enq(tagged Sample unpack(truncate(command.sample))); 1.166 - end 1.167 - endrule 1.168 - 1.169 - 1.170 //----------------------------------------------------------- 1.171 // Methods 1.172 1.173 @@ -609,17 +612,20 @@ 1.174 1.175 interface Get statsEn_get = toGet(asReg(cp0_statsEn)); 1.176 1.177 -// interface CPUToHost tohost; 1.178 -// method Bit#(32) cpuToHost(int req); 1.179 -// return (case (req) 1.180 -// 0: cp0_tohost; 1.181 -// 1: pc; 1.182 -// 2: zeroExtend(pack(stage)); 1.183 -// endcase); 1.184 -// endmethod 1.185 -// endinterface 1.186 - 1.187 + /* 1.188 + interface CPUToHost tohost; 1.189 + method Bit#(32) cpuToHost(int req); 1.190 + return (case (req) 1.191 + 0: cp0_tohost; 1.192 + 1: pc; 1.193 + 2: zeroExtend(pack(stage)); 1.194 + endcase); 1.195 + endmethod 1.196 + endinterface 1.197 + */ 1.198 + 1.199 interface Get sampleOutput = fifoToGet(outAudioFifo); 1.200 + interface Put sampleInput = fifoToPut(inAudioFifo); 1.201 1.202 endmodule 1.203
2.1 --- a/modules/bluespec/Pygar/core/AudioCoreRRR.rrr Tue May 04 12:14:24 2010 -0400 2.2 +++ b/modules/bluespec/Pygar/core/AudioCoreRRR.rrr Tue May 04 18:54:54 2010 -0400 2.3 @@ -3,9 +3,9 @@ 2.4 server hw (bsv, connection) <- sw (cpp, method) 2.5 { 2.6 method ReadCPUToHost (out UINT32[32] regValue, in UINT32[32] dummy); 2.7 - //method SendUnprocessedStream (in UINT32[32] ctrl, in UINT32[32] sample); 2.8 + method SendUnprocessedStream (in UINT32[32] ctrl, in UINT32[32] sample); 2.9 //rlm: here it is modified to take N 2.10 - method SendUnprocessedStream (in UINT32[32] channel, in UINT32[32] ctrl, in UINT32[32] sample); 2.11 +// method SendUnprocessedStream (in UINT32[32] channel, in UINT32[32] ctrl, in UINT32[32] sample); 2.12 2.13 }; 2.14
3.1 --- a/modules/bluespec/Pygar/core/AudioCoreSystem.cpp Tue May 04 12:14:24 2010 -0400 3.2 +++ b/modules/bluespec/Pygar/core/AudioCoreSystem.cpp Tue May 04 18:54:54 2010 -0400 3.3 @@ -64,13 +64,13 @@ 3.4 { 3.5 //rlm: two files 3.6 FILE *inputFile; 3.7 - FILE *inputFile1; 3.8 + // FILE *inputFile1; 3.9 UINT16 sample; 3.10 - UINT16 sample1; 3.11 + //UINT16 sample1; 3.12 3.13 //rlm: not sure if normal ints are ok here; using UINT16 because I know it works 3.14 UINT16 channel0 = 0; 3.15 - UINT16 channel1 = 1; 3.16 + //UINT16 channel1 = 1; 3.17 3.18 //init processor 3.19 int sleepCount = 0; 3.20 @@ -78,8 +78,6 @@ 3.21 3.22 bool coreFin = false; 3.23 3.24 - 3.25 - 3.26 fflush(stdout); 3.27 3.28 // Convert input wav to pcm 3.29 @@ -88,16 +86,15 @@ 3.30 //rlm: for now we are going to going to just have 2 files with "common names" 3.31 3.32 generate_pcm("input.wav","input.pcm"); 3.33 - generate_pcm("input1.wav", "input1.pcm"); 3.34 - 3.35 + //generate_pcm("input1.wav", "input1.pcm"); 3.36 3.37 3.38 //Send data to the machine here. 3.39 //rlm: two files 3.40 inputFile = fopen("input.pcm","r"); 3.41 - inputFile = fopen("input1.pcm", "r"); 3.42 + // inputFile = fopen("input1.pcm", "r"); 3.43 3.44 - assert(inputFile1); 3.45 + //assert(inputFile1); 3.46 assert(inputFile); 3.47 3.48 int count = 0; 3.49 @@ -106,7 +103,8 @@ 3.50 3.51 //rlm: here we read both files. later refactor into a function. 3.52 // also, this will terminate when the FIRST file reaches its end. 3.53 - while( (fread(&sample, 2, 1, inputFile)) && (fread(&sample1, 2 , 1, inputFile1))) { 3.54 + while( (fread(&sample, 2, 1, inputFile)) )//&& (fread(&sample1, 2 , 1, inputFile1))) 3.55 + { 3.56 if (!coreFin && (result = clientStub->ReadCPUToHost(0)) != 1) 3.57 { 3.58 sleepCount++; 3.59 @@ -131,8 +129,9 @@ 3.60 sem_wait(&throttle); 3.61 3.62 //rlm: two files. 3.63 - clientStub->SendUnprocessedStream(channel0 , Data,(UINT32)sample); 3.64 - clientStub->SendUnprocessedStream(channel1 , Data,(UINT32)sample1); 3.65 + clientStub->SendUnprocessedStream( Data,(UINT32)sample); 3.66 + //clientStub->SendUnprocessedStream(channel0 , Data,(UINT32)sample); 3.67 + //clientStub->SendUnprocessedStream(channel1 , Data,(UINT32)sample1); 3.68 3.69 } 3.70 3.71 @@ -143,8 +142,9 @@ 3.72 3.73 //rlm: have to send end-files to both voices. 3.74 // all of these operations wil eventually be moved into functions. 3.75 - clientStub->SendUnprocessedStream(channel0, EndOfFile,0); 3.76 - clientStub->SendUnprocessedStream(channel1, EndOfFile,0); 3.77 + clientStub->SendUnprocessedStream(EndOfFile,0); 3.78 + //clientStub->SendUnprocessedStream(channel0, EndOfFile,0); 3.79 + // clientStub->SendUnprocessedStream(channel1, EndOfFile,0); 3.80 3.81 printf("main: wait for end of file\n"); 3.82
4.1 --- a/modules/bluespec/Pygar/core/Processor.bsv Tue May 04 12:14:24 2010 -0400 4.2 +++ b/modules/bluespec/Pygar/core/Processor.bsv Tue May 04 18:54:54 2010 -0400 4.3 @@ -46,7 +46,7 @@ 4.4 4.5 // Local includes 4.6 //`include "asim/provides/processor_library.bsh" (included above directly) 4.7 -`include "asim/rrr/remote_server_stub_AUDIOCORERRR.bsh" 4.8 + 4.9 `include "asim/provides/common_services.bsh" 4.10 `include "asim/dict/STATS_PROCESSOR.bsh" 4.11 `include "asim/provides/processor_library.bsh" 4.12 @@ -77,6 +77,7 @@ 4.13 4.14 // Interface to Audio Pipeline 4.15 interface Get#(AudioProcessorUnit) sampleOutput; 4.16 + interface Put#(AudioProcessorUnit) sampleInput; 4.17 4.18 endinterface 4.19 4.20 @@ -227,12 +228,6 @@ 4.21 module [CONNECTED_MODULE] mkProc( Proc ); 4.22 4.23 //----------------------------------------------------------- 4.24 - // Debug port 4.25 - 4.26 - ServerStub_AUDIOCORERRR server_stub <- mkServerStub_AUDIOCORERRR(); 4.27 - 4.28 - 4.29 - //----------------------------------------------------------- 4.30 // State 4.31 4.32 // Standard processor state 4.33 @@ -581,15 +576,6 @@ 4.34 num_cycles.incr(); 4.35 endrule 4.36 4.37 -(* conservative_implicit_conditions *) 4.38 - rule handleCPUToHost; 4.39 - let req <- server_stub.acceptRequest_ReadCPUToHost(); 4.40 - case (req) 4.41 - 0: server_stub.sendResponse_ReadCPUToHost(cp0_tohost); 4.42 - 1: server_stub.sendResponse_ReadCPUToHost(pc); 4.43 - 2: server_stub.sendResponse_ReadCPUToHost(zeroExtend(pack(stage))); 4.44 - endcase 4.45 - endrule 4.46 4.47 // for now, we don't do anything. 4.48 // rule connectAudioReqResp; 4.49 @@ -610,24 +596,7 @@ 4.50 cp0_progComp <= False; //only send one. And functions to reset 4.51 endrule 4.52 4.53 - // Server items & rules: 4.54 4.55 - rule feedInput; 4.56 - let command <- server_stub.acceptRequest_SendUnprocessedStream(); 4.57 - AudioProcessorControl ctrl = unpack(truncate(command.ctrl)); 4.58 - if(ctrl == EndOfFile) 4.59 - begin 4.60 - $display("lsp: PROCESSOR received EOF "); 4.61 - inAudioFifo.enq(tagged EndOfFile); 4.62 - end 4.63 - else 4.64 - begin 4.65 - $display("lsp: PROCESSOR received Data "); 4.66 - inAudioFifo.enq(tagged Sample unpack(truncate(command.sample))); 4.67 - end 4.68 - endrule 4.69 - 4.70 - 4.71 //----------------------------------------------------------- 4.72 // Methods 4.73 4.74 @@ -643,17 +612,20 @@ 4.75 4.76 interface Get statsEn_get = toGet(asReg(cp0_statsEn)); 4.77 4.78 -// interface CPUToHost tohost; 4.79 -// method Bit#(32) cpuToHost(int req); 4.80 -// return (case (req) 4.81 -// 0: cp0_tohost; 4.82 -// 1: pc; 4.83 -// 2: zeroExtend(pack(stage)); 4.84 -// endcase); 4.85 -// endmethod 4.86 -// endinterface 4.87 - 4.88 + /* 4.89 + interface CPUToHost tohost; 4.90 + method Bit#(32) cpuToHost(int req); 4.91 + return (case (req) 4.92 + 0: cp0_tohost; 4.93 + 1: pc; 4.94 + 2: zeroExtend(pack(stage)); 4.95 + endcase); 4.96 + endmethod 4.97 + endinterface 4.98 + */ 4.99 + 4.100 interface Get sampleOutput = fifoToGet(outAudioFifo); 4.101 + interface Put sampleInput = fifoToPut(inAudioFifo); 4.102 4.103 endmodule 4.104
5.1 --- a/modules/bluespec/Pygar/core/audioCore.bsv Tue May 04 12:14:24 2010 -0400 5.2 +++ b/modules/bluespec/Pygar/core/audioCore.bsv Tue May 04 18:54:54 2010 -0400 5.3 @@ -46,7 +46,10 @@ 5.4 interface Client#(MainMemReq,MainMemResp) mmem_client; 5.5 5.6 interface Get#(AudioProcessorUnit) sampleOutput; 5.7 - 5.8 + interface Put#(AudioProcessorUnit) sampleInput; 5.9 + 5.10 +// interface CPUToHost tohost; 5.11 + 5.12 endinterface 5.13 5.14 module [CONNECTED_MODULE] mkCore( Core ); 5.15 @@ -72,5 +75,8 @@ 5.16 interface mmem_client = marb.mmem_client; 5.17 5.18 interface sampleOutput = proc.sampleOutput; 5.19 + interface sampleInput = proc.sampleInput; 5.20 + 5.21 +// interface CPUToHost tohost = proc.tohost; 5.22 5.23 endmodule
6.1 --- a/modules/bluespec/Pygar/core/audioCorePipeline.bsv Tue May 04 12:14:24 2010 -0400 6.2 +++ b/modules/bluespec/Pygar/core/audioCorePipeline.bsv Tue May 04 18:54:54 2010 -0400 6.3 @@ -44,7 +44,7 @@ 6.4 `include "asim/dict/VDEV_SCRATCH.bsh" 6.5 6.6 `include "asim/rrr/remote_client_stub_AUDIOCORERRR.bsh" 6.7 -//`include "asim/rrr/remote_server_stub_AUDIOCORERRR.bsh" 6.8 +`include "asim/rrr/remote_server_stub_AUDIOCORERRR.bsh" 6.9 6.10 module [CONNECTED_MODULE] mkConnectedApplication (); 6.11 Core core <- mkCore; 6.12 @@ -60,6 +60,12 @@ 6.13 // Make this big enough so that several outstanding requests may be supported 6.14 FIFO#(Bit#(MainMemTagSz)) tags <- mkSizedFIFO(8); 6.15 6.16 + //----------------------------------------------------------- 6.17 + // Debug port 6.18 + 6.19 + ServerStub_AUDIOCORERRR server_stub <- mkServerStub_AUDIOCORERRR(); 6.20 + 6.21 + 6.22 // this is for the tracing 6.23 rule printCycles; 6.24 cycle <= cycle+1; 6.25 @@ -99,4 +105,20 @@ 6.26 endcase 6.27 endrule 6.28 6.29 + //***** SERVER Side ***** 6.30 + 6.31 + rule feedInput; 6.32 + let command <- server_stub.acceptRequest_SendUnprocessedStream(); 6.33 + AudioProcessorControl ctrl = unpack(truncate(command.ctrl)); 6.34 + if(ctrl == EndOfFile) 6.35 + begin 6.36 + $display("lsp: PROCESSOR received EOF "); 6.37 + core.sampleInput.put(tagged EndOfFile); 6.38 + end 6.39 + else 6.40 + begin 6.41 + $display("lsp: PROCESSOR received Data "); 6.42 + core.sampleInput.put(tagged Sample unpack(truncate(command.sample))); 6.43 + end 6.44 + endrule 6.45 endmodule
7.1 --- a/modules/bluespec/Pygar/lab4/processor_library.awb Tue May 04 12:14:24 2010 -0400 7.2 +++ b/modules/bluespec/Pygar/lab4/processor_library.awb Tue May 04 18:54:54 2010 -0400 7.3 @@ -5,4 +5,4 @@ 7.4 7.5 %attributes PYGAR 7.6 7.7 -%public Trace.bsv BFIFO.bsv MemTypes.bsv FIFOUtility.bsv GetPutExt.bsv SFIFO.bsv CBUFF.bsv BRegFile.bsv BranchPred.bsv 7.8 +%public Trace.bsv BFIFO.bsv MemTypes.bsv FIFOUtility.bsv GetPutExt.bsv SFIFO.bsv CBUFF.bsv BRegFile.bsv BranchPred.bsv Divider.bsv