changeset 52:49049f97312c pygar svn.53

[svn r53] sends to two cores (but has issues)
author punk
date Thu, 06 May 2010 08:57:53 -0400
parents 9fe5ed4af92d
children 2991344775f8
files modules/bluespec/Pygar/core/AudioCoreRRR.cpp modules/bluespec/Pygar/core/AudioCoreRRR.h modules/bluespec/Pygar/core/AudioCoreRRR.rrr modules/bluespec/Pygar/core/AudioCoreSystem.cpp modules/bluespec/Pygar/core/AudioPipeTypes.bsv modules/bluespec/Pygar/core/audioCorePipeline.bsv
diffstat 6 files changed, 88 insertions(+), 54 deletions(-) [+]
line wrap: on
line diff
     1.1 --- a/modules/bluespec/Pygar/core/AudioCoreRRR.cpp	Wed May 05 17:01:04 2010 -0400
     1.2 +++ b/modules/bluespec/Pygar/core/AudioCoreRRR.cpp	Thu May 06 08:57:53 2010 -0400
     1.3 @@ -24,6 +24,7 @@
     1.4      outputFile = NULL;
     1.5      memory = NULL;
     1.6      fflush(stdout);
     1.7 +    count = 0;
     1.8  }
     1.9  
    1.10  // destructor
    1.11 @@ -90,6 +91,13 @@
    1.12  */
    1.13  
    1.14  void
    1.15 +AUDIOCORERRR_SERVER_CLASS::SendTerminate(UINT32 flag)
    1.16 +{
    1.17 +  printf("lsp: Received Process Termination\n");
    1.18 +  CONNECTED_APPLICATION_CLASS::EndSimulation(); 
    1.19 +}
    1.20 +
    1.21 +void
    1.22  
    1.23  AUDIOCORERRR_SERVER_CLASS::SendProcessedStream(UINT16 control, UINT16 data)
    1.24  {
    1.25 @@ -112,7 +120,9 @@
    1.26        }
    1.27  
    1.28        // Long term this should be in the data portion.  But until I have code running, keep it here.
    1.29 -      CONNECTED_APPLICATION_CLASS::EndSimulation(); 
    1.30 +      count++;
    1.31 +      if (count == 2)
    1.32 +        CONNECTED_APPLICATION_CLASS::EndSimulation(); 
    1.33      break;
    1.34  
    1.35      case Data:
     2.1 --- a/modules/bluespec/Pygar/core/AudioCoreRRR.h	Wed May 05 17:01:04 2010 -0400
     2.2 +++ b/modules/bluespec/Pygar/core/AudioCoreRRR.h	Thu May 06 08:57:53 2010 -0400
     2.3 @@ -10,7 +10,6 @@
     2.4  #include "asim/provides/rrr.h"
     2.5  
     2.6  
     2.7 -
     2.8  typedef class AUDIOCORERRR_SERVER_CLASS* AUDIOCORERRR_SERVER;
     2.9  class AUDIOCORERRR_SERVER_CLASS: public RRR_SERVER_CLASS, public PLATFORMS_MODULE_CLASS
    2.10  {
    2.11 @@ -45,7 +44,7 @@
    2.12     UINT32 MemoryRequestLoad  (UINT32 address);
    2.13     void   MemoryRequestStore (UINT32 address, UINT32 data);
    2.14     */
    2.15 -
    2.16 +   void   SendTerminate(UINT32 flag);
    2.17     void   SendProcessedStream(UINT16 control, UINT16 data0);
    2.18  };
    2.19  
     3.1 --- a/modules/bluespec/Pygar/core/AudioCoreRRR.rrr	Wed May 05 17:01:04 2010 -0400
     3.2 +++ b/modules/bluespec/Pygar/core/AudioCoreRRR.rrr	Thu May 06 08:57:53 2010 -0400
     3.3 @@ -3,14 +3,14 @@
     3.4      server hw (bsv, connection) <- sw (cpp, method)
     3.5      {
     3.6          method ReadCPUToHost  (out UINT32[32] regValue, in UINT32[32] dummy);
     3.7 -        method   SendUnprocessedStream (in UINT32[32] channel, in UINT32[32] ctrl, in UINT32[32] sample);
     3.8 +        method SendUnprocessedStream (in UINT32[32] channel, in UINT32[32] ctrl, in UINT32[32] sample);
     3.9  
    3.10      };
    3.11  
    3.12      server sw (cpp, method) <- hw (bsv, connection) 
    3.13      {
    3.14         method SendProcessedStream (in UINT32[32] ctrl, in UINT32[32] sample);
    3.15 -
    3.16 +       method SendTerminate(in UINT32[32] flag);
    3.17  
    3.18      };
    3.19  
     4.1 --- a/modules/bluespec/Pygar/core/AudioCoreSystem.cpp	Wed May 05 17:01:04 2010 -0400
     4.2 +++ b/modules/bluespec/Pygar/core/AudioCoreSystem.cpp	Thu May 06 08:57:53 2010 -0400
     4.3 @@ -64,13 +64,13 @@
     4.4  {
     4.5    //rlm: two files
     4.6    FILE *inputFile;
     4.7 -//  FILE *inputFile1;
     4.8 +  FILE *inputFile1;
     4.9    UINT16 sample;
    4.10 -//UINT16 sample1;
    4.11 +  UINT16 sample1;
    4.12  
    4.13    //rlm: not sure if normal ints are ok here; using UINT16 because I know it works
    4.14 -  UINT16 channel0 = 5;
    4.15 -  //UINT16 channel1 = 1;
    4.16 +  UINT16 channel0 = 0;
    4.17 +  UINT16 channel1 = 1;
    4.18  
    4.19    //init processor 
    4.20    int sleepCount = 0;
    4.21 @@ -86,15 +86,15 @@
    4.22    //rlm: for now we are going to going to just have 2 files with "common names"
    4.23  
    4.24    generate_pcm("input.wav","input.pcm");
    4.25 -  //generate_pcm("input1.wav", "input1.pcm");
    4.26 +  generate_pcm("input1.wav", "input1.pcm");
    4.27  
    4.28  
    4.29    //Send data to the machine here.
    4.30    //rlm: two files
    4.31    inputFile = fopen("input.pcm","r");
    4.32 -  // inputFile = fopen("input1.pcm", "r");
    4.33 +  inputFile = fopen("input1.pcm", "r");
    4.34    
    4.35 -  //assert(inputFile1);
    4.36 +  assert(inputFile1);
    4.37    assert(inputFile);
    4.38  
    4.39    int count = 0;
    4.40 @@ -103,20 +103,12 @@
    4.41  
    4.42    //rlm: here we read both files. later refactor into a function.
    4.43    // also, this will terminate when the FIRST file reaches its end.
    4.44 -  while( fread(&sample, 2, 1, inputFile)) //&& (fread(&sample1, 2 , 1, inputFile1))) 
    4.45 +  while( (fread(&sample, 2, 1, inputFile)) || (fread(&sample1, 2 , 1, inputFile1))) 
    4.46    { /*
    4.47      printf("hi\n");
    4.48       if (!coreFin && (result = clientStub->ReadCPUToHost(0)) != 1) 
    4.49       {
    4.50         sleepCount++;
    4.51 -       if(sleepCount == 200) {
    4.52 -	 printf("Failed to get response from hardware, bailing\n\n");
    4.53 -	 printf("This means that either your hardware is hanging\n");
    4.54 -	 printf("or that the software hasn't given it enough time\n");
    4.55 -	 printf("to complete.  If you think it needs more time, then\n");
    4.56 -	 printf("edit CONNECTED_APPLICATION_CLASS::Main() in ProcessorSystem.cpp\n");
    4.57 -	 printf("(connected_application)\n");
    4.58 -      }
    4.59       }
    4.60       else if (!coreFin && result == 1) 
    4.61         {
    4.62 @@ -132,9 +124,8 @@
    4.63      
    4.64      //rlm: two files.
    4.65      // clientStub->SendUnprocessedStream( Data,(UINT32)sample);
    4.66 -               clientStub->SendUnprocessedStream((UINT32)channel0 , Data,(UINT32)sample);
    4.67 -     //clientStub->SendUnprocessedStream(channel1 , Data,(UINT32)sample1);
    4.68 -
    4.69 +     clientStub->SendUnprocessedStream((UINT32)channel0 , Data,(UINT32)sample);
    4.70 +     clientStub->SendUnprocessedStream((UINT32)channel1 , Data,(UINT32)sample1);
    4.71    } 
    4.72  
    4.73    printf("main: out of loop\n");
    4.74 @@ -146,7 +137,7 @@
    4.75    // all of these operations wil eventually be moved into functions.
    4.76    //clientStub->SendUnprocessedStream(EndOfFile,0);
    4.77    clientStub->SendUnprocessedStream((UINT32)channel0, EndOfFile,0);
    4.78 -  // clientStub->SendUnprocessedStream(channel1, EndOfFile,0);
    4.79 +  clientStub->SendUnprocessedStream((UINT32)channel1, EndOfFile,0);
    4.80  
    4.81    printf("main: wait for end of file\n");
    4.82  
     5.1 --- a/modules/bluespec/Pygar/core/AudioPipeTypes.bsv	Wed May 05 17:01:04 2010 -0400
     5.2 +++ b/modules/bluespec/Pygar/core/AudioPipeTypes.bsv	Thu May 06 08:57:53 2010 -0400
     5.3 @@ -29,6 +29,7 @@
     5.4  import ClientServer::*;
     5.5  
     5.6  typedef Int#(16) Sample;
     5.7 +typedef Int#(16) Channel;
     5.8  
     5.9  typedef enum {
    5.10    EndOfFile = 0,
     6.1 --- a/modules/bluespec/Pygar/core/audioCorePipeline.bsv	Wed May 05 17:01:04 2010 -0400
     6.2 +++ b/modules/bluespec/Pygar/core/audioCorePipeline.bsv	Thu May 06 08:57:53 2010 -0400
     6.3 @@ -27,6 +27,7 @@
     6.4  import ClientServer::*;
     6.5  import FIFO::*;
     6.6  import SpecialFIFOs::*;
     6.7 +import Vector::*;
     6.8  
     6.9  //AWB includes
    6.10  `include "asim/provides/low_level_platform_interface.bsh"
    6.11 @@ -48,18 +49,9 @@
    6.12  module [CONNECTED_MODULE] mkConnectedApplication ();
    6.13     Core core <- mkCore(`VDEV_SCRATCH_MEMORYA);
    6.14     Core anotherCore <- mkCore(`VDEV_SCRATCH_MEMORYB);
    6.15 -   // RLM::
    6.16 -   // the simple existance of this additional core causes the dreaded
    6.17 -   // beast to emerge --- the ASSERTION FAILURE: sw/model/stats-device.cpp:317 Cycle:0
    6.18 -   //stats device: Duplicate entry DATA_CACHE_NUM_WRITEBACKS, postion 0
    6.19 -   //Core core1 <- mkCore;
    6.20 +
    6.21     Reg#(int) cycle <- mkReg(0);
    6.22 -
    6.23 -//   Reg#(Bit#(32)) ac_fini <- mkReg(0);
    6.24 -
    6.25 -  //External memory 
    6.26 -  // I'm not comfortable assuming that the memory subsystem is in order  
    6.27 -  // So I'll insert a completion buffer here.
    6.28 +   Vector#(2, Reg#(Bool)) ac_fini <- replicateM(mkReg(False));
    6.29  
    6.30    // Services Samples 
    6.31    ClientStub_AUDIOCORERRR client_stub <- mkClientStub_AUDIOCORERRR();   
    6.32 @@ -82,40 +74,81 @@
    6.33       AudioProcessorControl endOfFileTag = EndOfFile;
    6.34       AudioProcessorControl sampleTag = Data;
    6.35  
    6.36 +     $display("PIPE writes sample\n");
    6.37       case (pipelineData) matches
    6.38 -       tagged EndOfFile: 
    6.39 -       client_stub.makeRequest_SendProcessedStream(zeroExtend(pack(endOfFileTag)),?);
    6.40 -       tagged Sample .sample:client_stub.makeRequest_SendProcessedStream(zeroExtend(pack(sampleTag)), zeroExtend(pack(sample)));
    6.41 +	tagged EndOfFile:
    6.42 +	   begin
    6.43 +	      client_stub.makeRequest_SendProcessedStream(zeroExtend(pack(endOfFileTag)),?);
    6.44 +	      ac_fini[0] <= True;
    6.45 +	   end
    6.46 +       tagged Sample .sample:
    6.47 +	  client_stub.makeRequest_SendProcessedStream(zeroExtend(pack(sampleTag)), zeroExtend(pack(sample)));
    6.48       endcase
    6.49     endrule
    6.50  
    6.51 +   // Programming ghetto style!
    6.52 +   // right now I am repeating this rule for my second core.
    6.53 +    (* conservative_implicit_conditions *)
    6.54 +    rule feedAnotherOutput;
    6.55 +     let pipelineData <- anotherCore.sampleOutput.get();
    6.56 +     AudioProcessorControl endOfFileTag = EndOfFile;
    6.57 +     AudioProcessorControl sampleTag = Data;
    6.58 +
    6.59 +     $display("PIPE writes another sample\n");
    6.60 +     case (pipelineData) matches
    6.61 +	tagged EndOfFile:
    6.62 +	   begin
    6.63 +	      client_stub.makeRequest_SendProcessedStream(zeroExtend(pack(endOfFileTag)),?);
    6.64 +	      ac_fini[1] <= True;
    6.65 +	   end
    6.66 +	tagged Sample .sample:
    6.67 +	   client_stub.makeRequest_SendProcessedStream(zeroExtend(pack(sampleTag)), zeroExtend(pack(sample)));
    6.68 +     endcase
    6.69 +   endrule
    6.70 +
    6.71 +
    6.72 +   // Can generally just stick with the EOF but since I have two Cores no mixer...
    6.73 +  /*(* conservative_implicit_conditions *)
    6.74 +   rule sendTerminate;
    6.75 +      Bool done = True;
    6.76 +      for (Integer i = 1; i < 2; i = i+1)
    6.77 +	 done = ac_fini[i] && done;
    6.78 +
    6.79 +      if (done)
    6.80 +	 client_stub.makeRequest_SendTerminate(zeroExtend(pack(1)));
    6.81 +      
    6.82 +   endrule
    6.83 +*/
    6.84 +
    6.85     //*****  SERVER Side  *****
    6.86  
    6.87 -/*   (* conservative_implicit_conditions *)
    6.88 -  rule handleCPUToHost;
    6.89 -   let req <- server_stub.acceptRequest_ReadCPUToHost();
    6.90 -    case (req)
    6.91 -     0: server_stub.sendResponse_ReadCPUToHost(cp0_tohost);
    6.92 -    endcase
    6.93 -  endrule
    6.94 -*/   
    6.95 +   (* conservative_implicit_conditions *)
    6.96     rule feedInput;
    6.97       let command <- server_stub.acceptRequest_SendUnprocessedStream();
    6.98       AudioProcessorControl ctrl = unpack(truncate(command.ctrl));
    6.99  
   6.100 -      Bit#(32) test = unpack(truncate(command.channel));
   6.101 +     VoiceId channel = unpack(truncate(command.channel));
   6.102  //      $display("rlm: %x", test);
   6.103  	   
   6.104 -
   6.105 -      if(ctrl == EndOfFile)
   6.106 -	begin
   6.107 +     AudioProcessorUnit inSample;
   6.108 +      
   6.109 +     if(ctrl == EndOfFile)
   6.110 +       begin
   6.111  	   $display("lsp: PIPE received EOF   ");
   6.112 -           core.sampleInput.put(tagged EndOfFile);
   6.113 +	   inSample = tagged EndOfFile;
   6.114 +//           core.sampleInput.put(tagged EndOfFile);
   6.115         end
   6.116       else 
   6.117  	begin
   6.118  //	   $display("lsp: PIPE received Data   ");
   6.119 -           core.sampleInput.put(tagged Sample unpack(truncate(command.sample)));
   6.120 -       end
   6.121 +//           core.sampleInput.put(tagged Sample unpack(truncate(command.sample)));	   
   6.122 +           inSample = tagged Sample unpack(truncate(command.sample));
   6.123 +	end
   6.124 +
   6.125 +      case (channel)
   6.126 +	 0 : core.sampleInput.put(inSample);
   6.127 +	 1 : anotherCore.sampleInput.put(inSample);
   6.128 +      endcase
   6.129 +      
   6.130     endrule     
   6.131  endmodule