diff modules/bluespec/Pygar/core/audioCorePipeline.bsv @ 68:44cc00df1168 pygar svn.69

[svn r69] runs separate eofs (I think)
author punk
date Wed, 12 May 2010 00:06:05 -0400
parents 9b4f237e77e1
children
line wrap: on
line diff
     1.1 --- a/modules/bluespec/Pygar/core/audioCorePipeline.bsv	Tue May 11 23:23:21 2010 -0400
     1.2 +++ b/modules/bluespec/Pygar/core/audioCorePipeline.bsv	Wed May 12 00:06:05 2010 -0400
     1.3 @@ -50,19 +50,18 @@
     1.4  
     1.5  module [CONNECTED_MODULE] mkConnectedApplication ();
     1.6  
     1.7 - //  Core core <- mkCore(`VDEV_SCRATCH_MEMORYA);
     1.8 - //  Core anotherCore <- mkCore(`VDEV_SCRATCH_MEMORYB);
     1.9     Vector#(`MAX_VOICES, Volume) channelVols = replicate(127);
    1.10     Mixer mixer <- mkMixer(`MAX_VOICES, channelVols); //should be max voices but 2 for now
    1.11 -   
    1.12 -   Reg#(int) cycle <- mkReg(0);
    1.13 -   Reg#(int) sampleCount <-mkReg(0);
    1.14 -   Vector#(2, Reg#(Bool)) ac_fini <- replicateM(mkReg(False));
    1.15 +
    1.16 +   Reg#(Bit#(32)) cycle <- mkReg(0);
    1.17 +   Reg#(Bit#(32)) sampleCountIn <-mkReg(0);
    1.18 +   Reg#(Bit#(32)) sampleCountOut <-mkReg(0);
    1.19 +   Vector#(`MAX_VOICES, Reg#(Bit#(32))) pc <-replicateM(mkReg(0)); //tracks pcs from cores for debug purposes
    1.20 +   Vector#(`MAX_VOICES, Reg#(Bool)) channelFini <- replicateM(mkReg(False));
    1.21  
    1.22     // Services Samples 
    1.23     ClientStub_AUDIOCORERRR client_stub <- mkClientStub_AUDIOCORERRR();   
    1.24    
    1.25 -
    1.26     //-----------------------------------------------------------
    1.27     // Debug port
    1.28     
    1.29 @@ -75,15 +74,55 @@
    1.30  	 case (n)
    1.31  	    0 : cores[n] <- mkCore(`VDEV_SCRATCH_MEMORYA);
    1.32  	    1 : cores[n] <- mkCore(`VDEV_SCRATCH_MEMORYB);
    1.33 +	    2 : cores[n] <- mkCore(`VDEV_SCRATCH_MEMORYC);
    1.34 +	    3 : cores[n] <- mkCore(`VDEV_SCRATCH_MEMORYD);
    1.35 +	    4 : cores[n] <- mkCore(`VDEV_SCRATCH_MEMORYE);
    1.36 +	    5 : cores[n] <- mkCore(`VDEV_SCRATCH_MEMORYF);
    1.37 +	    6 : cores[n] <- mkCore(`VDEV_SCRATCH_MEMORYG);
    1.38 +	    7 : cores[n] <- mkCore(`VDEV_SCRATCH_MEMORYH);
    1.39 +	    8 : cores[n] <- mkCore(`VDEV_SCRATCH_MEMORYI);
    1.40 +	    9 : cores[n] <- mkCore(`VDEV_SCRATCH_MEMORYJ);
    1.41 +	    10 : cores[n] <- mkCore(`VDEV_SCRATCH_MEMORYK);
    1.42 +	    11 : cores[n] <- mkCore(`VDEV_SCRATCH_MEMORYL);
    1.43 +	    12 : cores[n] <- mkCore(`VDEV_SCRATCH_MEMORYM);
    1.44 +	    13 : cores[n] <- mkCore(`VDEV_SCRATCH_MEMORYN);
    1.45 +	    14 : cores[n] <- mkCore(`VDEV_SCRATCH_MEMORYO);
    1.46 +	    15 : cores[n] <- mkCore(`VDEV_SCRATCH_MEMORYP);
    1.47 +	    16 : cores[n] <- mkCore(`VDEV_SCRATCH_MEMORYQ);
    1.48 +	    17 : cores[n] <- mkCore(`VDEV_SCRATCH_MEMORYR);
    1.49 +	    18 : cores[n] <- mkCore(`VDEV_SCRATCH_MEMORYS);
    1.50 +	    19 : cores[n] <- mkCore(`VDEV_SCRATCH_MEMORYT);
    1.51 +	    20 : cores[n] <- mkCore(`VDEV_SCRATCH_MEMORYU);
    1.52 +	    21 : cores[n] <- mkCore(`VDEV_SCRATCH_MEMORYV);
    1.53 +	    22 : cores[n] <- mkCore(`VDEV_SCRATCH_MEMORYW);
    1.54 +	    23 : cores[n] <- mkCore(`VDEV_SCRATCH_MEMORYX);
    1.55 +	    24 : cores[n] <- mkCore(`VDEV_SCRATCH_MEMORYY);
    1.56 +	    25 : cores[n] <- mkCore(`VDEV_SCRATCH_MEMORYZ);
    1.57  	 endcase
    1.58       end
    1.59 -   
    1.60 +
    1.61 +   function Integer countFiniVoices();
    1.62 +      Integer count = 0;
    1.63 +      for (Integer i = 0; i < `MAX_VOICES; i = i + 1)
    1.64 +	if (channelFini[i]) count = count + 1;
    1.65 +      return count;
    1.66 +   endfunction
    1.67 +      
    1.68    // this is for the tracing
    1.69    rule printCycles;
    1.70      cycle <= cycle+1;
    1.71      $fdisplay(stderr, " => Cycle = %d", cycle);
    1.72    endrule
    1.73  
    1.74 +  // get the pc for trace purposes
    1.75 +   rule getPC;
    1.76 +     for (Integer i = 0; i < `MAX_VOICES; i = i + 1)
    1.77 +	begin
    1.78 +	   let val <- cores[i].pc.get(); 
    1.79 +	   pc[i] <= val;
    1.80 +	end 
    1.81 +   endrule
    1.82 +
    1.83    // Send to Mixer
    1.84    // Right now this is sorta retarded in that I pass from the output fifo into a new fifo
    1.85    // But I have to mod a bunch of things to fix this and I am not sure I understand
    1.86 @@ -92,28 +131,27 @@
    1.87        for (Integer i = 0; i < `MAX_VOICES; i = i + 1)
    1.88          begin
    1.89  	   let coreOut <- cores[i].sampleOutput.get();
    1.90 -	   mixer.toMixer(AudioStream {voice : fromInteger(i), data: tagged Valid coreOut});
    1.91 +	   mixer.toMixer(AudioStream {voice : fromInteger(i), data:coreOut.data});
    1.92  	end
    1.93 -      
    1.94 -//     let coreOut <- core.sampleOutput.get();
    1.95 -//    mixer.toMixer(AudioStream {voice : 0, data : tagged Valid coreOut});
    1.96 -//    mixer.toMixer(AudioStream {voice : 1, data : tagged Valid anotherOut});
    1.97 -  endrule
    1.98 -
    1.99 +   endrule
   1.100 +   
   1.101    rule feedOutput;
   1.102       let pipeOut <- mixer.mainOut.get();
   1.103       
   1.104       AudioProcessorControl endOfFileTag = EndOfFile;
   1.105       AudioProcessorControl sampleTag = Data;
   1.106  
   1.107 -     sampleCount <= sampleCount+1;
   1.108 +     sampleCountOut <= sampleCountOut+1;
   1.109       
   1.110 -     $display("PIPE writes sample %d", sampleCount);
   1.111 +     $display("PIPE writes sample %d", sampleCountOut);
   1.112       case (pipeOut) matches
   1.113  	tagged EndOfFile:
   1.114  	   begin
   1.115  	      client_stub.makeRequest_SendProcessedStream(zeroExtend(pack(endOfFileTag)),?);
   1.116 -	      ac_fini[0] <= True;
   1.117 +	      for (Integer i = 1; i < `MAX_VOICES; i = i+1) channelFini[i] <= False; 
   1.118 +	            //This will report conflict with
   1.119 +		    //the other setting of channelFini at input except they are mutually
   1.120 +		    //exclusive since this is only hit after all input finished
   1.121  	   end
   1.122         tagged Sample .sample:
   1.123  	  client_stub.makeRequest_SendProcessedStream(zeroExtend(pack(sampleTag)), zeroExtend(pack(sample)));
   1.124 @@ -134,31 +172,55 @@
   1.125  */
   1.126  
   1.127     //*****  SERVER Side  *****
   1.128 -
   1.129 +  // this requires me to switch the processor to handle this which I will do later.
   1.130 +   // When a file has finished, want the system to pass invalid audiostreams
   1.131 +   rule fillFinished;
   1.132 +      for (Integer i = 1; i < `MAX_VOICES; i = i+1)
   1.133 +	 begin
   1.134 +	    if (channelFini[i])
   1.135 +	       cores[i].sampleInput.put(AudioStream {voice : fromInteger(i), data: tagged Invalid});
   1.136 +	 end
   1.137 +   endrule
   1.138 +   
   1.139     (* conservative_implicit_conditions *)
   1.140     rule feedInput;
   1.141       let command <- server_stub.acceptRequest_SendUnprocessedStream();
   1.142       AudioProcessorControl ctrl = unpack(truncate(command.ctrl));
   1.143  
   1.144       VoiceId channel = unpack(truncate(command.channel));
   1.145 -//      $display("rlm: %x", test);
   1.146 +//     $display("PIPE: Incoming sample to channel %x", channel);
   1.147  	   
   1.148       AudioProcessorUnit inSample;
   1.149        
   1.150       if(ctrl == EndOfFile)
   1.151         begin
   1.152  	   $display("lsp: PIPE received EOF   ");
   1.153 -	   inSample = tagged EndOfFile;
   1.154 -//           core.sampleInput.put(tagged EndOfFile);
   1.155 +	  inSample = tagged EndOfFile;
   1.156 +          channelFini[channel] <= True;
   1.157         end
   1.158       else 
   1.159  	begin
   1.160  //	   $display("lsp: PIPE received Data   ");
   1.161 -//           core.sampleInput.put(tagged Sample unpack(truncate(command.sample)));	   
   1.162             inSample = tagged Sample unpack(truncate(command.sample));
   1.163  	end
   1.164  
   1.165 -      cores[channel].sampleInput.put(inSample);
   1.166 +      if (!channelFini[channel])
   1.167 +	 cores[channel].sampleInput.put(AudioStream {voice: channel, data: tagged Valid inSample });
   1.168 +      else $display("PIPE ERROR: Trying to send to Stream officially done");
   1.169        
   1.170 -   endrule     
   1.171 +   endrule
   1.172 +
   1.173 +   (* conservative_implicit_conditions *)
   1.174 +   rule handleCPUToHost;
   1.175 +      let req <- server_stub.acceptRequest_ReadCPUToHost();
   1.176 +      case (req) 
   1.177 +	 1: server_stub.sendResponse_ReadCPUToHost(cycle);
   1.178 +	 2: server_stub.sendResponse_ReadCPUToHost(sampleCountIn);
   1.179 +	 3: server_stub.sendResponse_ReadCPUToHost(sampleCountOut);
   1.180 +	 4: server_stub.sendResponse_ReadCPUToHost(fromInteger(countFiniVoices()));
   1.181 +	 default : if (req < 10 + `MAX_VOICES) 
   1.182 +		      server_stub.sendResponse_ReadCPUToHost(pc[req-10]);  
   1.183 +      endcase
   1.184 +  endrule
   1.185 +
   1.186  endmodule