comparison 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
comparison
equal deleted inserted replaced
7:7393cd19371e 8:74716e9a81cc
1 import Connectable::*;
2 import GetPut::*;
3 import ClientServer::*;
4
5 `include "asim/provides/librl_bsv_storage.bsh"
6
7 typedef SCOREBOARD_FIFO_ENTRY_ID#(t) CBUFFToken#(type t);
8
9 interface CBUFF #(numeric type n, type element_type);
10 interface Get#(CBUFFToken#(n)) reserve;
11 interface Put#(Tuple2 #(CBUFFToken#(n), element_type)) complete;
12 interface Get#(element_type) drain;
13 endinterface
14
15 module mkCBUFF(CBUFF#(n, element_type))
16 provisos(Bits#(element_type,a__));
17
18 SCOREBOARD_FIFOF#(n,element_type) cbuff <- mkScoreboardFIFOF();
19
20 let res = interface Get;
21 method ActionValue#(CBUFFToken#(n)) get();
22 let tok <- cbuff.enq();
23 return tok;
24 endmethod
25 endinterface;
26
27 let comp = interface Put;
28 method Action put(Tuple2#(CBUFFToken#(n),element_type) t);
29 cbuff.setValue(tpl_1(t), tpl_2(t));
30 endmethod
31 endinterface;
32
33 let dr = interface Get;
34 method ActionValue#(element_type) get();
35 cbuff.deq();
36 return cbuff.first();
37 endmethod
38 endinterface;
39
40 interface Get reserve = res;
41 interface Put complete = comp;
42 interface Get drain = dr;
43
44 endmodule