diff modules/bluespec/Pygar/lab4/CBUFF.bsv @ 8:74716e9a81cc pygar svn.9

[svn r9] Pygar now has the proper directory structure to play nicely with awb. Also, the apm file for audio-core willcompile successfully.
author rlm
date Fri, 23 Apr 2010 02:32:05 -0400
parents
children
line wrap: on
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/modules/bluespec/Pygar/lab4/CBUFF.bsv	Fri Apr 23 02:32:05 2010 -0400
     1.3 @@ -0,0 +1,44 @@
     1.4 +import Connectable::*;
     1.5 +import GetPut::*;
     1.6 +import ClientServer::*;
     1.7 +
     1.8 +`include "asim/provides/librl_bsv_storage.bsh"
     1.9 +
    1.10 +typedef SCOREBOARD_FIFO_ENTRY_ID#(t) CBUFFToken#(type t);
    1.11 +
    1.12 +interface CBUFF #(numeric type n, type element_type);
    1.13 +   interface Get#(CBUFFToken#(n)) reserve;
    1.14 +   interface Put#(Tuple2 #(CBUFFToken#(n), element_type)) complete;
    1.15 +   interface Get#(element_type) drain;
    1.16 +endinterface
    1.17 +
    1.18 +module mkCBUFF(CBUFF#(n, element_type))
    1.19 +   provisos(Bits#(element_type,a__));
    1.20 +   
    1.21 +   SCOREBOARD_FIFOF#(n,element_type) cbuff <- mkScoreboardFIFOF();
    1.22 +
    1.23 +   let res = interface Get;
    1.24 +		method ActionValue#(CBUFFToken#(n)) get();
    1.25 +		   let tok <- cbuff.enq();
    1.26 +		   return tok;
    1.27 +		endmethod
    1.28 +	     endinterface;
    1.29 +   
    1.30 +   let comp = interface Put;
    1.31 +		 method Action put(Tuple2#(CBUFFToken#(n),element_type) t);
    1.32 +		    cbuff.setValue(tpl_1(t), tpl_2(t));
    1.33 +		 endmethod
    1.34 +	      endinterface;
    1.35 +   
    1.36 +   let dr = interface Get;
    1.37 +	       method ActionValue#(element_type) get();
    1.38 +		  cbuff.deq();
    1.39 +		  return cbuff.first();
    1.40 +	       endmethod
    1.41 +	    endinterface;
    1.42 +
    1.43 +   interface Get reserve = res;
    1.44 +   interface Put complete = comp;
    1.45 +   interface Get drain = dr;
    1.46 +
    1.47 +endmodule
    1.48 \ No newline at end of file