comparison 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
comparison
equal deleted inserted replaced
32:0c775e733b81 33:2c8166d205d5
248 248
249 // Pipelines 249 // Pipelines
250 FIFO#(PCStat) pcQ <-mkSizedFIFO(3); 250 FIFO#(PCStat) pcQ <-mkSizedFIFO(3);
251 SFIFO#(WBResult, Rindx) wbQ <-mkSFIFO(findwbf); 251 SFIFO#(WBResult, Rindx) wbQ <-mkSFIFO(findwbf);
252 252
253 // NEED TO ADD CAPABILITY FOR RESET (should be able to just say if I get valid in and these are flagged, clear them.
253 Reg#(Bit#(32)) cp0_tohost <- mkReg(0); 254 Reg#(Bit#(32)) cp0_tohost <- mkReg(0);
254 Reg#(Bit#(32)) cp0_fromhost <- mkReg(0); 255 Reg#(Bit#(32)) cp0_fromhost <- mkReg(0);
255 Reg#(Bool) cp0_statsEn <- mkReg(False); 256 Reg#(Bool) cp0_statsEn <- mkReg(False);
256 257 Reg#(Bool) cp0_audioEOF <- mkReg(False); // Register to let code that EOF is reached
258 Reg#(Bool) cp0_progComp <- mkReg(False); // Register to let processor know that the program is complete (as this terminates)
259
257 // Memory request/response state 260 // Memory request/response state
258 261
259 FIFO#(InstReq) instReqQ <- mkBFIFO1(); 262 FIFO#(InstReq) instReqQ <- mkBFIFO1();
260 FIFO#(InstResp) instRespQ <- mkFIFO(); 263 FIFO#(InstResp) instRespQ <- mkFIFO();
261 264
486 branchTaken = True; 489 branchTaken = True;
487 end 490 end
488 491
489 // -- Cop0 ------------------------------------------------------ 492 // -- Cop0 ------------------------------------------------------
490 493
491 tagged MTC0 .it : 494 tagged MTC0 .it : //Recieve things from host computer
492 begin 495 begin
496 $display( " PROCESSOR MTC0 call\n");
493 case ( it.cop0dst ) 497 case ( it.cop0dst )
494 5'd10 : cp0_statsEn <= unpack(truncate(rf.rd1(it.rsrc))); 498 5'd10 : cp0_statsEn <= unpack(truncate(rf.rd1(it.rsrc)));
495 5'd21 : cp0_tohost <= truncate(rf.rd1(it.rsrc)); 499 5'd21 : cp0_tohost <= truncate(rf.rd1(it.rsrc));
500 5'd26 : cp0_progComp <= unpack(truncate(rf.rd1(it.rsrc))); //states audio program completed and termination okay
501 5'd27 : outAudioFifo.enq(tagged Sample unpack(truncate(rf.rd1(it.rsrc)))); //Bit size is 16 not 32
496 default : 502 default :
497 $display( " RTL-ERROR : %m : Illegal MTC0 cop0dst register!" ); 503 $display( " RTL-ERROR : %m : Illegal MTC0 cop0dst register!" );
498 endcase 504 endcase
499 wbQ.enq(tagged WB_Host 0); //no idea wwhat this actually should be. 505 wbQ.enq(tagged WB_Host 0); //no idea wwhat this actually should be.
500 end 506 end
501 507
502 //this is host stuff? 508 //this is host stuff?
503 tagged MFC0 .it : 509 tagged MFC0 .it : //Things out
504 begin 510 begin
511 $display( " PROCESSOR MFC0 call\n");
505 case ( it.cop0src ) 512 case ( it.cop0src )
506 // not actually an ALU instruction but don't have the format otherwise 513 // not actually an ALU instruction but don't have the format otherwise
507 5'd10 : wbQ.enq(tagged WB_ALU {dest:it.rdst, data:zext(pack(cp0_statsEn)) }); 514 5'd10 : wbQ.enq(tagged WB_ALU {dest:it.rdst, data:zext(pack(cp0_statsEn)) });
508 5'd20 : wbQ.enq(tagged WB_ALU {dest:it.rdst, data:cp0_fromhost }); 515 5'd20 : wbQ.enq(tagged WB_ALU {dest:it.rdst, data:cp0_fromhost });
509 5'd21 : wbQ.enq(tagged WB_ALU {dest:it.rdst, data:cp0_tohost }); 516 5'd21 : wbQ.enq(tagged WB_ALU {dest:it.rdst, data:cp0_tohost });
517 5'd25 : begin
518 $display( "**** EOF Requested\n ");
519 wbQ.enq(tagged WB_ALU {dest:it.rdst, data:zext(pack(cp0_audioEOF)) }); // Reading clears bit
520 cp0_audioEOF <= False;
521 end
522 5'd28 : begin
523 $display( "***** Reqesting Sample \n");
524 let sample = inAudioFifo.first(); // is this going to cause perf. delay?
525 if (sample matches tagged Sample .audio) // if it is EOF another rule sets the cp0_audioEOF
526 wbQ.enq(tagged WB_ALU {dest:it.rdst, data:zext(pack(audio)) }); // do I need pack?
527 else $display ( "Audio File EOF Reached. Invalid sample request.");
528 inAudioFifo.deq();
529 end
510 default : 530 default :
511 $display( " RTL-ERROR : %m : Illegal MFC0 cop0src register!" ); 531 $display( " RTL-ERROR : %m : Illegal MFC0 cop0src register!" );
512 endcase 532 endcase
513 end 533 end
514 534
570 2: server_stub.sendResponse_ReadCPUToHost(zeroExtend(pack(stage))); 590 2: server_stub.sendResponse_ReadCPUToHost(zeroExtend(pack(stage)));
571 endcase 591 endcase
572 endrule 592 endrule
573 593
574 // for now, we don't do anything. 594 // for now, we don't do anything.
575 rule connectAudioReqResp; 595 // rule connectAudioReqResp;
576 // $display("rlm: PROCESSOR copies a datum\n"); 596 // $display("rlm: PROCESSOR copies a datum\n");
577 outAudioFifo.enq(inAudioFifo.first()); 597 // outAudioFifo.enq(inAudioFifo.first());
578 inAudioFifo.deq; 598 // inAudioFifo.deq;
599 // endrule
600
601 rule flagAudioEnd (inAudioFifo.first() matches tagged EndOfFile);
602 $display (" Proc Says End Audio Flag Set ");
603 cp0_audioEOF <= True;
604 inAudioFifo.deq;
605 endrule
606
607 rule sendAudioEnd (cp0_progComp);
608 $display (" PROCESSOR Says Program Complete ");
609 outAudioFifo.enq(tagged EndOfFile);
610 cp0_progComp <= False; //only send one. And functions to reset
579 endrule 611 endrule
580 612
581 // Server items & rules: 613 // Server items & rules:
582 614
583 rule feedInput; 615 rule feedInput;
584 let command <- server_stub.acceptRequest_SendUnprocessedStream(); 616 let command <- server_stub.acceptRequest_SendUnprocessedStream();
585 AudioProcessorControl ctrl = unpack(truncate(command.ctrl)); 617 AudioProcessorControl ctrl = unpack(truncate(command.ctrl));
586 if(ctrl == EndOfFile) 618 if(ctrl == EndOfFile)
587 begin 619 begin
588 // $display("lsp: PROCESSOR received EOF "); 620 $display("lsp: PROCESSOR received EOF ");
589 inAudioFifo.enq(tagged EndOfFile); 621 inAudioFifo.enq(tagged EndOfFile);
590 end 622 end
591 else 623 else
592 begin 624 begin
593 // $display("lsp: PROCESSOR received Data "); 625 $display("lsp: PROCESSOR received Data ");
594 inAudioFifo.enq(tagged Sample unpack(truncate(command.sample))); 626 inAudioFifo.enq(tagged Sample unpack(truncate(command.sample)));
595 end 627 end
596 endrule 628 endrule
597 629
598 630