diff modules/bluespec/Pygar/core/Processor.bsv @ 33:2c8166d205d5 pygar svn.34

[svn r34] uses scratchpad, set up for audio through c
author punk
date Tue, 04 May 2010 10:13:53 -0400
parents f5dfbe28fa59
children 14f7a7ace3f5
line wrap: on
line diff
     1.1 --- a/modules/bluespec/Pygar/core/Processor.bsv	Mon May 03 09:53:56 2010 -0400
     1.2 +++ b/modules/bluespec/Pygar/core/Processor.bsv	Tue May 04 10:13:53 2010 -0400
     1.3 @@ -250,10 +250,13 @@
     1.4     FIFO#(PCStat)           pcQ <-mkSizedFIFO(3);
     1.5     SFIFO#(WBResult, Rindx) wbQ <-mkSFIFO(findwbf);
     1.6  
     1.7 +   // NEED TO ADD CAPABILITY FOR RESET (should be able to just say if I get valid in and these are flagged, clear them.
     1.8     Reg#(Bit#(32)) cp0_tohost   <- mkReg(0);
     1.9     Reg#(Bit#(32)) cp0_fromhost <- mkReg(0);
    1.10     Reg#(Bool)     cp0_statsEn  <- mkReg(False);
    1.11 -
    1.12 +   Reg#(Bool)     cp0_audioEOF <- mkReg(False);  // Register to let code that EOF is reached
    1.13 +   Reg#(Bool)     cp0_progComp <- mkReg(False);  // Register to let processor know that the program is complete (as this terminates)
    1.14 +    
    1.15     // Memory request/response state
    1.16     
    1.17     FIFO#(InstReq)  instReqQ    <- mkBFIFO1();
    1.18 @@ -488,11 +491,14 @@
    1.19  
    1.20        // -- Cop0 ------------------------------------------------------
    1.21        
    1.22 -      tagged MTC0  .it : 
    1.23 +      tagged MTC0  .it : //Recieve things from host computer
    1.24  	 begin
    1.25 +	    $display( " PROCESSOR MTC0 call\n");
    1.26              case ( it.cop0dst )
    1.27  	       5'd10 : cp0_statsEn <= unpack(truncate(rf.rd1(it.rsrc)));
    1.28  	       5'd21 : cp0_tohost  <= truncate(rf.rd1(it.rsrc));
    1.29 +	       5'd26 : cp0_progComp <= unpack(truncate(rf.rd1(it.rsrc))); //states audio program completed and termination okay
    1.30 + 	       5'd27 : outAudioFifo.enq(tagged Sample unpack(truncate(rf.rd1(it.rsrc))));  //Bit size is 16 not 32 
    1.31  	       default :
    1.32  	       $display( " RTL-ERROR : %m : Illegal MTC0 cop0dst register!" );
    1.33  	    endcase
    1.34 @@ -500,13 +506,27 @@
    1.35  	 end
    1.36  
    1.37  //this is host stuff?
    1.38 -      tagged MFC0  .it :
    1.39 +      tagged MFC0  .it :  //Things out
    1.40  	 begin
    1.41 +	    $display( " PROCESSOR MFC0 call\n");
    1.42              case ( it.cop0src )
    1.43  	    // not actually an ALU instruction but don't have the format otherwise
    1.44                 5'd10 : wbQ.enq(tagged WB_ALU {dest:it.rdst, data:zext(pack(cp0_statsEn)) });
    1.45                 5'd20 : wbQ.enq(tagged WB_ALU {dest:it.rdst, data:cp0_fromhost });
    1.46                 5'd21 : wbQ.enq(tagged WB_ALU {dest:it.rdst, data:cp0_tohost   });
    1.47 +	       5'd25 : begin
    1.48 +			  $display( "**** EOF Requested\n ");
    1.49 +			  wbQ.enq(tagged WB_ALU {dest:it.rdst, data:zext(pack(cp0_audioEOF)) });  // Reading clears bit
    1.50 +			  cp0_audioEOF <= False;
    1.51 +		       end
    1.52 +	       5'd28 : begin
    1.53 +			  $display( "***** Reqesting Sample \n");
    1.54 +			  let sample = inAudioFifo.first();        // is this going to cause perf. delay?
    1.55 +			  if (sample matches tagged Sample .audio) // if it is EOF another rule sets the cp0_audioEOF  
    1.56 +	      		     wbQ.enq(tagged WB_ALU {dest:it.rdst, data:zext(pack(audio)) });  // do I need pack?
    1.57 +			  else $display ( "Audio File EOF Reached.  Invalid sample request.");
    1.58 +			  inAudioFifo.deq();
    1.59 +		       end
    1.60                default : 
    1.61                  $display( " RTL-ERROR : %m : Illegal MFC0 cop0src register!" );
    1.62              endcase
    1.63 @@ -572,10 +592,22 @@
    1.64    endrule
    1.65  
    1.66   // for now, we don't do anything.
    1.67 -  rule connectAudioReqResp;
    1.68 +//  rule connectAudioReqResp;
    1.69  //    $display("rlm: PROCESSOR copies a datum\n");
    1.70 -    outAudioFifo.enq(inAudioFifo.first());
    1.71 -    inAudioFifo.deq;
    1.72 +//    outAudioFifo.enq(inAudioFifo.first());
    1.73 +//    inAudioFifo.deq;
    1.74 +//  endrule
    1.75 +
    1.76 +  rule flagAudioEnd (inAudioFifo.first() matches tagged EndOfFile);
    1.77 +     $display (" Proc Says End Audio Flag Set ");
    1.78 +     cp0_audioEOF <= True;
    1.79 +     inAudioFifo.deq;
    1.80 +  endrule
    1.81 +
    1.82 +  rule sendAudioEnd (cp0_progComp);
    1.83 +     $display (" PROCESSOR Says Program Complete ");
    1.84 +     outAudioFifo.enq(tagged EndOfFile);
    1.85 +     cp0_progComp <= False;  //only send one.  And functions to reset
    1.86    endrule
    1.87  
    1.88    // Server items & rules:
    1.89 @@ -585,12 +617,12 @@
    1.90       AudioProcessorControl ctrl = unpack(truncate(command.ctrl));
    1.91       if(ctrl == EndOfFile)
    1.92  	begin
    1.93 -//	  $display("lsp: PROCESSOR received EOF   ");
    1.94 +	  $display("lsp: PROCESSOR received EOF   ");
    1.95            inAudioFifo.enq(tagged EndOfFile);
    1.96         end
    1.97       else 
    1.98  	begin
    1.99 -//	  $display("lsp: PROCESSOR received Data   ");
   1.100 +	  $display("lsp: PROCESSOR received Data   ");
   1.101            inAudioFifo.enq(tagged Sample unpack(truncate(command.sample)));
   1.102         end
   1.103     endrule